Files
CatServer/patches/net/minecraft/inventory/ContainerChest.java.patch

61 lines
2.4 KiB
Diff

--- ../src-base/minecraft/net/minecraft/inventory/ContainerChest.java
+++ ../src-work/minecraft/net/minecraft/inventory/ContainerChest.java
@@ -2,19 +2,49 @@
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
public class ContainerChest extends Container
{
private final IInventory lowerChestInventory;
private final int numRows;
+ private CraftInventoryView bukkitEntity = null;
+ private InventoryPlayer player;
+ // CraftBukkit start
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity != null) {
+ return bukkitEntity;
+ }
+
+ CraftInventory inventory;
+ if (this.lowerChestInventory instanceof InventoryPlayer) {
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryPlayer((InventoryPlayer) this.lowerChestInventory);
+ } else if (this.lowerChestInventory instanceof InventoryLargeChest) {
+ inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) this.lowerChestInventory);
+ } else {
+ inventory = new CraftInventory(this.lowerChestInventory);
+ }
+
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
public ContainerChest(IInventory playerInventory, IInventory chestInventory, EntityPlayer player)
{
this.lowerChestInventory = chestInventory;
this.numRows = chestInventory.getSizeInventory() / 9;
chestInventory.openInventory(player);
int i = (this.numRows - 4) * 18;
+ // CraftBukkit start - Save player
+ // TODO: Should we check to make sure it really is an InventoryPlayer?
+ this.player = (InventoryPlayer) playerInventory;
+ // CraftBukkit end
for (int j = 0; j < this.numRows; ++j)
{
@@ -40,6 +70,7 @@
public boolean canInteractWith(EntityPlayer playerIn)
{
+ if (!this.checkReachable) return true; // CraftBukkit
return this.lowerChestInventory.isUseableByPlayer(playerIn);
}