summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-02-12 08:43:11 +1100
committermd_5 <git@md-5.net>2018-02-12 08:43:11 +1100
commit49ecc7c7a28bf0074690ce2f1a02232b7fb2385b (patch)
tree4e58831133591fff2c85874748800dd841dea14a
parent9ab298de7b0055e0d3dbb64390104ea48a14207b (diff)
downloadcraftbukkit-49ecc7c7a28bf0074690ce2f1a02232b7fb2385b.tar
craftbukkit-49ecc7c7a28bf0074690ce2f1a02232b7fb2385b.tar.gz
craftbukkit-49ecc7c7a28bf0074690ce2f1a02232b7fb2385b.tar.lz
craftbukkit-49ecc7c7a28bf0074690ce2f1a02232b7fb2385b.tar.xz
craftbukkit-49ecc7c7a28bf0074690ce2f1a02232b7fb2385b.zip
SPIGOT-3812: Workbench from Bukkit.createInventory does not update
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
index 97a5143f..38175385 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
@@ -17,12 +17,12 @@ import net.minecraft.server.ContainerEnchantTable;
import net.minecraft.server.ContainerFurnace;
import net.minecraft.server.ContainerHopper;
import net.minecraft.server.ContainerShulkerBox;
-import net.minecraft.server.ContainerWorkbench;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.IInventory;
import net.minecraft.server.ItemStack;
import net.minecraft.server.PacketPlayOutOpenWindow;
import net.minecraft.server.PlayerInventory;
+import net.minecraft.server.Slot;
public class CraftContainer extends Container {
@@ -149,7 +149,7 @@ public class CraftContainer extends Container {
break;
case CRAFTING: // TODO: This should be an error?
case WORKBENCH:
- delegate = new ContainerWorkbench(bottom, entityhuman.world, entityhuman.getChunkCoordinates());
+ setupWorkbench(top, bottom); // SPIGOT-3812 - manually set up slots so we can use the delegated inventory and not the automatically created one
break;
case ENCHANTING:
delegate = new ContainerEnchantTable(bottom, entityhuman.world, entityhuman.getChunkCoordinates());
@@ -177,6 +177,31 @@ public class CraftContainer extends Container {
}
}
+ private void setupWorkbench(IInventory top, IInventory bottom) {
+ // This code copied from ContainerWorkbench
+ this.a(new Slot(top, 0, 124, 35));
+
+ int row;
+ int col;
+
+ for (row = 0; row < 3; ++row) {
+ for (col = 0; col < 3; ++col) {
+ this.a(new Slot(top, 1 + col + row * 3, 30 + col * 18, 17 + row * 18));
+ }
+ }
+
+ for (row = 0; row < 3; ++row) {
+ for (col = 0; col < 9; ++col) {
+ this.a(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18));
+ }
+ }
+
+ for (col = 0; col < 9; ++col) {
+ this.a(new Slot(bottom, col, 8 + col * 18, 142));
+ }
+ // End copy from ContainerWorkbench
+ }
+
@Override
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
return (delegate != null) ? delegate.shiftClick(entityhuman, i) : super.shiftClick(entityhuman, i);