當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。