From 4309566390dbe0f399ccd2a244d912ac9c5b6094 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 5 Jul 2020 11:35:20 +1000 Subject: [PATCH] SPIGOT-5943: Calling get BlockStateMeta#getBlockState causes NPE with shield with banner --- .../org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index a2100aa6e3..844dcc0ff7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -268,10 +268,12 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta @Override public BlockState getBlockState() { + Material stateMaterial = material; // Only actually used for jigsaws if (blockEntityTag != null) { switch (material) { case SHIELD: blockEntityTag.setString("id", "banner"); + stateMaterial = shieldToBannerHack(blockEntityTag); break; case SHULKER_BOX: case WHITE_SHULKER_BOX: @@ -298,7 +300,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta break; } } - TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(CraftMagicNumbers.getBlock(material).getBlockData(), blockEntityTag); + TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(CraftMagicNumbers.getBlock(stateMaterial).getBlockData(), blockEntityTag); switch (material) { case ACACIA_SIGN: