Files
2019-02-24 22:29:41 +08:00

65 lines
2.3 KiB
Diff

--- ../src-base/minecraft/net/minecraft/inventory/ContainerChest.java
+++ ../src-work/minecraft/net/minecraft/inventory/ContainerChest.java
@@ -1,13 +1,19 @@
package net.minecraft.inventory;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
public class ContainerChest extends Container
{
private final IInventory lowerChestInventory;
private final int numRows;
+ private CraftInventoryView bukkitEntity = null;
+ private InventoryPlayer player;
+
public ContainerChest(IInventory playerInventory, IInventory chestInventory, EntityPlayer player)
{
this.lowerChestInventory = chestInventory;
@@ -15,6 +21,9 @@
chestInventory.openInventory(player);
int i = (this.numRows - 4) * 18;
+ // TODO: Should we check to make sure it really is an InventoryPlayer?
+ this.player = (InventoryPlayer) playerInventory;
+
for (int j = 0; j < this.numRows; ++j)
{
for (int k = 0; k < 9; ++k)
@@ -39,6 +48,7 @@
public boolean canInteractWith(EntityPlayer playerIn)
{
+ if (!this.checkReachable) return true;
return this.lowerChestInventory.isUsableByPlayer(playerIn);
}
@@ -87,4 +97,23 @@
{
return this.lowerChestInventory;
}
+
+ @Override
+ 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;
+ }
}