From 4b61c24b361426cf8cdf09b19b27070234ea8697 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 5 Jan 2015 10:05:01 +1100 Subject: [PATCH] SPIGOT-323: Allow force creating enchant table containers. Usefullness is not guaranteed. By: md_5 --- .../org/bukkit/craftbukkit/entity/CraftHumanEntity.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index f045e1c73b..0e84185696 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -294,7 +294,14 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { if (location == null) { location = getLocation(); } - getHandle().openTileEntity((ITileEntityContainer) getHandle().world.getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); + + // If there isn't an enchant table we can force create one, won't be very useful though. + TileEntity container = getHandle().world.getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())); + if (container == null && force) { + container = new TileEntityEnchantTable(); + } + getHandle().openTileEntity((ITileEntityContainer) container); + if (force) { getHandle().activeContainer.checkReachable = false; }