Search in sources :

Example 1 with ItemBlock

use of net.minecraft.server.v1_12_R1.ItemBlock in project PaperDev by Kamillaova.

the class ItemMetaTest method testBlockStateMeta.

@Test
public void testBlockStateMeta() {
    for (Item item : (Iterable<Item>) Item.REGISTRY) {
        Block block = null;
        if (item instanceof ItemBlock) {
            block = ((ItemBlock) item).getBlock();
        } else if (item instanceof ItemReed) {
            block = ((ItemReed) item).a;
        }
        if (block != null) {
            if (block instanceof ITileEntity) {
                ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block));
                // Command blocks aren't unit testable atm
                if (stack.getType() == Material.AIR || stack.getType() == Material.COMMAND || stack.getType() == Material.COMMAND_CHAIN || stack.getType() == Material.COMMAND_REPEATING) {
                    return;
                }
                ItemMeta meta = stack.getItemMeta();
                assertTrue(stack + " has meta of type " + meta + " expected BlockStateMeta", meta instanceof BlockStateMeta);
                BlockStateMeta blockState = (BlockStateMeta) meta;
                assertNotNull(stack + " has null block state", blockState.getBlockState());
                blockState.setBlockState(blockState.getBlockState());
            }
        }
    }
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) Item(net.minecraft.server.v1_12_R1.Item) ITileEntity(net.minecraft.server.v1_12_R1.ITileEntity) Block(net.minecraft.server.v1_12_R1.Block) ItemBlock(net.minecraft.server.v1_12_R1.ItemBlock) ItemBlock(net.minecraft.server.v1_12_R1.ItemBlock) ItemStack(org.bukkit.inventory.ItemStack) ItemReed(net.minecraft.server.v1_12_R1.ItemReed) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Test(org.junit.Test)

Aggregations

Block (net.minecraft.server.v1_12_R1.Block)1 ITileEntity (net.minecraft.server.v1_12_R1.ITileEntity)1 Item (net.minecraft.server.v1_12_R1.Item)1 ItemBlock (net.minecraft.server.v1_12_R1.ItemBlock)1 ItemReed (net.minecraft.server.v1_12_R1.ItemReed)1 ItemStack (org.bukkit.inventory.ItemStack)1 BlockStateMeta (org.bukkit.inventory.meta.BlockStateMeta)1 ItemMeta (org.bukkit.inventory.meta.ItemMeta)1 Test (org.junit.Test)1