当前位置: 首页>>代码示例>>Java>>正文


Java Material.DIRT属性代码示例

本文整理汇总了Java中org.bukkit.Material.DIRT属性的典型用法代码示例。如果您正苦于以下问题:Java Material.DIRT属性的具体用法?Java Material.DIRT怎么用?Java Material.DIRT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.DIRT属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerInteract

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.useInteractedBlock() == Result.DENY)
        return;

    //For using a hoe for farming
    if (event.getItem() != null &&
            event.getItem().getType() != null &&
            (event.getMaterial() == Material.DIRT || event.getMaterial() == Material.GRASS) &&
            ((event.getItem().getType() == Material.WOOD_HOE) ||
                    (event.getItem().getType() == Material.IRON_HOE) ||
                    (event.getItem().getType() == Material.GOLD_HOE) ||
                    (event.getItem().getType() == Material.DIAMOND_HOE)))
    {
        BlockUpdate.Update(event.getClickedBlock());
    }
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:17,代码来源:OrebfuscatorPlayerListener.java

示例2: initialize

@Override
public void initialize() {
    terraformItem = new ItemStack(Material.APPLE);
    ItemMeta im = terraformItem.getItemMeta();
    im.setDisplayName(TERRAFORM_NAME);
    ArrayList<String> lore = new ArrayList<String>();
    lore.add(ChatColor.GRAY + "Left-click = paste random loaded schematic");
    lore.add(ChatColor.GRAY + "Right-click = undo last paste");
    terraformItem.setItemMeta(im);

    blockLocItem = new ItemStack(Material.DIRT);
    im = blockLocItem.getItemMeta();
    im.setDisplayName(BLOCK_LOC_NAME);
    blockLocItem.setItemMeta(im);

    mobSpawnItem = new ItemStack(Material.GOLDEN_CARROT);
    im = mobSpawnItem.getItemMeta();
    im.setDisplayName(MOB_SPAWN_NAME);
    mobSpawnItem.setItemMeta(im);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:20,代码来源:SchematicManager.java

示例3: addItem_FullInventoryAddsOneStack_NothingAdded

@Test
public void addItem_FullInventoryAddsOneStack_NothingAdded()
{
	ItemStack filler = new ItemStack(Material.COBBLESTONE, 1);
	for (int i = 0; i < inventory.getSize(); i++)
	{
		inventory.setItem(i, filler);
	}

	ItemStack stack = new ItemStack(Material.DIRT, 64);
	ItemStack remaining = inventory.addItem(stack);
	assertEquals(64, remaining.getAmount());

	for (ItemStack stored : inventory.getContents())
	{
		assertEquals(1, stored.getAmount());
		assertEquals(Material.COBBLESTONE, stored.getType());
	}
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:19,代码来源:PlayerInventoryMockTest.java

示例4: addItem_PartiallyFilled_AddsOneStack_HalfAdded

@Test
public void addItem_PartiallyFilled_AddsOneStack_HalfAdded()
{
	ItemStack filler = new ItemStack(Material.COBBLESTONE, 1);
	for (int i = 2; i < inventory.getSize(); i++)
	{
		inventory.setItem(i, filler);
	}
	ItemStack preset = new ItemStack(Material.DIRT, 48);
	inventory.setItem(0, preset);
	inventory.setItem(2, preset);
	preset.setAmount(64);
	inventory.setItem(1, preset);

	ItemStack store = new ItemStack(Material.DIRT, 64);
	ItemStack remaining = inventory.addItem(store);
	assertNotNull(remaining);
	assertEquals(32, remaining.getAmount());
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:19,代码来源:PlayerInventoryMockTest.java

示例5: addItem_MultipleItems_ItemsAddedCorrectly

@Test
public void addItem_MultipleItems_ItemsAddedCorrectly()
{
	ItemStack filler = new ItemStack(Material.COBBLESTONE, 1);
	for (int i = 1; i < inventory.getSize(); i++)
	{
		inventory.setItem(i, filler);
	}

	ItemStack preset = new ItemStack(Material.DIRT, 48);
	inventory.setItem(0, preset);

	ItemStack item1 = new ItemStack(Material.COBBLESTONE, 64);
	ItemStack item2 = new ItemStack(Material.DIRT, 64);
	HashMap<Integer, ItemStack> map = inventory.addItem(item1, item2);
	assertEquals(1, map.size());
	assertTrue(map.containsKey(1));
	assertEquals(48, map.get(1).getAmount());
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:19,代码来源:PlayerInventoryMockTest.java

示例6: setContents_OneItem_SetAndRestCleared

@Test
public void setContents_OneItem_SetAndRestCleared()
{
	ItemStack filler = new ItemStack(Material.COBBLESTONE, 1);
	for (int i = 1; i < inventory.getSize(); i++)
	{
		inventory.setItem(i, filler);
	}

	ItemStack item = new ItemStack(Material.DIRT, 32);

	inventory.setContents(new ItemStack[] { item });
	
	assertTrue(item.isSimilar(inventory.getItem(0)));
	for (int i = 1; i < inventory.getSize(); i++)
	{
		assertNull(inventory.getItem(i));
	}
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:19,代码来源:PlayerInventoryMockTest.java

示例7: onPlayerInteract

/**
 * Handle blocks that need special treatment
 * Tilling of coarse dirt into dirt using off-hand (regular hand is in 1.8)
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getInventory().getItemInOffHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:42,代码来源:IslandGuard1_9.java

示例8: onPlayerInteract

/**
 * Handle V1.8 blocks that need special treatment
 * Tilling of coarse dirt into dirt
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 *
 * @param e
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getItemInHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:42,代码来源:IslandGuard1_8.java

示例9: isApplicable_StandardItemMetaOnDirtItemStack_True

@Test
public void isApplicable_StandardItemMetaOnDirtItemStack_True()
{
	ItemStack stack = new ItemStack(Material.DIRT);
	ItemMeta meta = factory.getItemMeta(Material.DIRT);
	assertTrue(factory.isApplicable(meta, stack));
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:7,代码来源:ItemFactoryMockTest.java

示例10: asMetaFor_DirtItemMetaOnDirtItemStack_ReturnsCloneOfMeta

@Test
public void asMetaFor_DirtItemMetaOnDirtItemStack_ReturnsCloneOfMeta()
{
	ItemStack stack = new ItemStack(Material.DIRT);
	ItemMeta meta = stack.getItemMeta();
	meta.setDisplayName("My piece of dirt");
	stack.setItemMeta(meta);
	
	ItemMeta newMeta = factory.asMetaFor(meta, stack);
	assertTrue(meta.equals(newMeta));
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:11,代码来源:ItemFactoryMockTest.java

示例11: addItem_EmptyInventoryAddsOneStack_OneStackUsed

@Test
public void addItem_EmptyInventoryAddsOneStack_OneStackUsed()
{
	ItemStack stack = new ItemStack(Material.DIRT, 64);
	ItemStack remaining = inventory.addItem(stack);
	assertNull(remaining);
	ItemStack stored = inventory.getItem(0);
	assertEquals(stored.getAmount(), 64);
	ItemStack next = inventory.getItem(1);
	assertNull(next);
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:11,代码来源:PlayerInventoryMockTest.java

示例12: getBlockAt_StandardWorld_DefaultBlocks

@Test
public void getBlockAt_StandardWorld_DefaultBlocks()
{
	WorldMock world = new WorldMock(Material.DIRT, 3);
	assertEquals(Material.BEDROCK, world.getBlockAt(0, 0, 0).getType());
	assertEquals(Material.DIRT, world.getBlockAt(0, 1, 0).getType());
	assertEquals(Material.DIRT, world.getBlockAt(0, 2, 0).getType());
	assertEquals(Material.DIRT, world.getBlockAt(0, 3, 0).getType());
	assertEquals(Material.AIR, world.getBlockAt(0, 4, 0).getType());
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:10,代码来源:WorldMockTest.java

示例13: getTrampledType

private static Material getTrampledType(Material newType) {
    switch(newType) {
    case SOIL: return Material.DIRT;
    default: return null;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:BlockTransformListener.java

示例14: GUIItemEditor

public GUIItemEditor(Player player, ItemStack item,  Consumer<ItemWrapper> onFinish) {
    super(player, "Item Editor");
    this.original = item != null && item.getType() != Material.AIR ? item : new ItemStack(Material.DIRT);
    this.edit = new DisplayItem(original);
    this.onFinish = onFinish;
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:6,代码来源:GUIItemEditor.java


注:本文中的org.bukkit.Material.DIRT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。