From b9a71db046cc11d4678cc9e5f8a4654658e86cfa Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 13 Mar 2012 22:50:09 -0400 Subject: [PATCH] [Bleeding] Make crafting and enchanting inventories keep track of their owner rather than returning null. Addresses BUKKIT-1209 --- .../java/net/minecraft/server/ContainerEnchantTable.java | 5 ++++- .../minecraft/server/ContainerEnchantTableSubcontainer.java | 2 +- src/main/java/net/minecraft/server/ContainerPlayer.java | 2 +- src/main/java/net/minecraft/server/ContainerWorkbench.java | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTable.java b/src/main/java/net/minecraft/server/ContainerEnchantTable.java index dd550c1a09..a2eb347311 100644 --- a/src/main/java/net/minecraft/server/ContainerEnchantTable.java +++ b/src/main/java/net/minecraft/server/ContainerEnchantTable.java @@ -50,7 +50,10 @@ public class ContainerEnchantTable extends Container { for (l = 0; l < 9; ++l) { this.a(new Slot(playerinventory, l, 8 + l * 18, 142)); } - player = (Player) playerinventory.player.bukkitEntity; // CraftBukkit + // CraftBukkit start + player = (Player) playerinventory.player.bukkitEntity; + enchantSlots.player = player; + // CraftBukkit end } public void addSlotListener(ICrafting icrafting) { diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTableSubcontainer.java b/src/main/java/net/minecraft/server/ContainerEnchantTableSubcontainer.java index 9fff6acf70..400feb56de 100644 --- a/src/main/java/net/minecraft/server/ContainerEnchantTableSubcontainer.java +++ b/src/main/java/net/minecraft/server/ContainerEnchantTableSubcontainer.java @@ -38,7 +38,7 @@ public class ContainerEnchantTableSubcontainer implements IInventory { } public InventoryHolder getOwner() { - return null; // TODO: Enchanting tables don't really have an owner? Maybe they should? + return this.player; } public void setMaxStackSize(int size) { diff --git a/src/main/java/net/minecraft/server/ContainerPlayer.java b/src/main/java/net/minecraft/server/ContainerPlayer.java index 809f8d408a..374da50265 100644 --- a/src/main/java/net/minecraft/server/ContainerPlayer.java +++ b/src/main/java/net/minecraft/server/ContainerPlayer.java @@ -21,7 +21,7 @@ public class ContainerPlayer extends Container { public ContainerPlayer(PlayerInventory playerinventory, boolean flag) { this.resultInventory = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction - this.craftInventory = new InventoryCrafting(this, 2, 2); + this.craftInventory = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player this.craftInventory.resultInventory = this.resultInventory; // CraftBukkit - let InventoryCrafting know about its result slot this.player = playerinventory; // CraftBukkit - save player this.c = false; diff --git a/src/main/java/net/minecraft/server/ContainerWorkbench.java b/src/main/java/net/minecraft/server/ContainerWorkbench.java index d40ab0737d..0d298e852c 100644 --- a/src/main/java/net/minecraft/server/ContainerWorkbench.java +++ b/src/main/java/net/minecraft/server/ContainerWorkbench.java @@ -21,7 +21,7 @@ public class ContainerWorkbench extends Container { public ContainerWorkbench(PlayerInventory playerinventory, World world, int i, int j, int k) { // CraftBukkit start - switched order of IInventory construction and stored player this.resultInventory = new InventoryCraftResult(); - this.craftInventory = new InventoryCrafting(this, 3, 3); + this.craftInventory = new InventoryCrafting(this, 3, 3, playerinventory.player); // CraftBukkit - pass player this.craftInventory.resultInventory = this.resultInventory; this.player = playerinventory; // CraftBukkit end