From bfea4559685433cbbfbd4791c79ecfe56ce62df5 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 27 Aug 2020 18:32:52 +1000 Subject: [PATCH] SPIGOT-6111: NPE in CraftHumanEntity#openWorkbench & CraftHumanEntity#openEnchanting --- .../bukkit/craftbukkit/entity/CraftHumanEntity.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 1f1f53bfdf..af41d9f11c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -326,15 +326,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public InventoryView openWorkbench(Location location, boolean force) { + if (location == null) { + location = getLocation(); + } if (!force) { Block block = location.getBlock(); if (block.getType() != Material.CRAFTING_TABLE) { return null; } } - if (location == null) { - location = getLocation(); - } getHandle().openContainer(((BlockWorkbench) Blocks.CRAFTING_TABLE).getInventory(null, getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); if (force) { getHandle().activeContainer.checkReachable = false; @@ -344,15 +344,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public InventoryView openEnchanting(Location location, boolean force) { + if (location == null) { + location = getLocation(); + } if (!force) { Block block = location.getBlock(); if (block.getType() != Material.ENCHANTING_TABLE) { return null; } } - if (location == null) { - location = getLocation(); - } // If there isn't an enchant table we can force create one, won't be very useful though. BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());