From 7a6b1433e2315a97327ca9fcbabad4322285c5bc Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 24 Apr 2016 16:20:53 +1000 Subject: [PATCH] SPIGOT-2213: Fix custom anvil inventory --- .../craftbukkit/inventory/CraftContainer.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index 85b416ced9..c086975ece 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -143,6 +143,9 @@ public class CraftContainer extends Container { case HOPPER: setupHopper(top, bottom); break; + case ANVIL: + setupAnvil(top, bottom); + break; } } @@ -241,7 +244,8 @@ public class CraftContainer extends Container { private void setupEnchanting(IInventory top, IInventory bottom) { // This code copied from ContainerEnchantTable - this.a((new Slot(top, 0, 25, 47))); + this.a((new Slot(top, 0, 15, 47))); + this.a((new Slot(top, 0, 35, 47))); int row; @@ -300,6 +304,26 @@ public class CraftContainer extends Container { // End copy from ContainerHopper } + private void setupAnvil(IInventory top, IInventory bottom) { + // This code copied from ContainerAnvil + this.a(new Slot(top, 0, 27, 47)); + this.a(new Slot(top, 1, 76, 47)); + this.a(new Slot(top, 2, 134, 47)); + + int i; + + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { + this.a(new Slot(bottom, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) { + this.a(new Slot(bottom, i, 8 + i * 18, 142)); + } + // End copy from ContainerAnvil + } + public boolean a(EntityHuman entity) { return true; }