diff options
author | md_5 <git@md-5.net> | 2016-12-02 09:29:33 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-12-02 09:29:33 +1100 |
commit | b6ad714e853042def52620befe9bc85d0137cd71 (patch) | |
tree | 88c4943eb76a566534e0e96b46b32281c6cfb9d2 /src/test/java/org | |
parent | 4d99feddd02b4402a9c6fe9514525e0534a3135d (diff) | |
download | craftbukkit-b6ad714e853042def52620befe9bc85d0137cd71.tar craftbukkit-b6ad714e853042def52620befe9bc85d0137cd71.tar.gz craftbukkit-b6ad714e853042def52620befe9bc85d0137cd71.tar.lz craftbukkit-b6ad714e853042def52620befe9bc85d0137cd71.tar.xz craftbukkit-b6ad714e853042def52620befe9bc85d0137cd71.zip |
SPIGOT-2871: Improve BlockStates + BlockStateMeta
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 41a00527..8c479a68 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -5,6 +5,11 @@ import static org.hamcrest.Matchers.*; import java.util.Arrays; import java.util.List; +import net.minecraft.server.Block; +import net.minecraft.server.ITileEntity; +import net.minecraft.server.Item; +import net.minecraft.server.ItemBlock; +import net.minecraft.server.ItemReed; import org.bukkit.Bukkit; import org.bukkit.Color; @@ -21,6 +26,7 @@ import org.bukkit.craftbukkit.inventory.ItemStackTest.CraftWrapper; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.FireworkEffectMeta; @@ -128,6 +134,38 @@ public class ItemMetaTest extends AbstractTestingBase { } @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()); + } + } + } + } + + @Test public void testEachExtraData() { final List<StackProvider> providers = Arrays.asList( new StackProvider(Material.BOOK_AND_QUILL) { @@ -209,7 +247,7 @@ public class ItemMetaTest extends AbstractTestingBase { return cleanStack; } }, - new StackProvider(Material.BANNER) { + new StackProvider(Material.BANNER) { @Override ItemStack operate(ItemStack cleanStack) { final BannerMeta meta = (BannerMeta) cleanStack.getItemMeta(); meta.setBaseColor(DyeColor.CYAN); |