diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/CompoundContainer.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/CompoundContainer.java.patch | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/CompoundContainer.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/CompoundContainer.java.patch new file mode 100644 index 0000000000..af3a93c2fd --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/CompoundContainer.java.patch @@ -0,0 +1,175 @@ +--- a/net/minecraft/world/CompoundContainer.java ++++ b/net/minecraft/world/CompoundContainer.java +@@ -3,102 +3,140 @@ + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + ++// CraftBukkit start ++import java.util.ArrayList; ++import java.util.List; ++import org.bukkit.Location; ++ ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++// CraftBukkit end ++ + public class CompoundContainer implements Container { + +- private final Container container1; +- private final Container container2; ++ public final Container container1; ++ public final Container container2; + +- public CompoundContainer(Container container, Container container1) { +- this.container1 = container; +- this.container2 = container1; ++ // CraftBukkit start - add fields and methods ++ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); ++ ++ public List<ItemStack> getContents() { ++ List<ItemStack> result = new ArrayList<ItemStack>(this.getContainerSize()); ++ for (int i = 0; i < this.getContainerSize(); i++) { ++ result.add(this.getItem(i)); ++ } ++ return result; + } + ++ public void onOpen(CraftHumanEntity who) { ++ this.container1.onOpen(who); ++ this.container2.onOpen(who); ++ transaction.add(who); ++ } ++ ++ public void onClose(CraftHumanEntity who) { ++ this.container1.onClose(who); ++ this.container2.onClose(who); ++ transaction.remove(who); ++ } ++ ++ public List<HumanEntity> getViewers() { ++ return transaction; ++ } ++ ++ public org.bukkit.inventory.InventoryHolder getOwner() { ++ return null; // This method won't be called since CraftInventoryDoubleChest doesn't defer to here ++ } ++ ++ public void setMaxStackSize(int size) { ++ this.container1.setMaxStackSize(size); ++ this.container2.setMaxStackSize(size); ++ } ++ + @Override ++ public Location getLocation() { ++ return container1.getLocation(); // TODO: right? ++ } ++ // CraftBukkit end ++ ++ public CompoundContainer(Container container1, Container container2) { ++ this.container1 = container1; ++ this.container2 = container2; ++ } ++ + @Override + public int getContainerSize() { + return this.container1.getContainerSize() + this.container2.getContainerSize(); + } + + @Override +- @Override + public boolean isEmpty() { + return this.container1.isEmpty() && this.container2.isEmpty(); + } + +- public boolean contains(Container container) { +- return this.container1 == container || this.container2 == container; ++ public boolean contains(Container inventory) { ++ return this.container1 == inventory || this.container2 == inventory; + } + + @Override +- @Override +- public ItemStack getItem(int i) { +- return i >= this.container1.getContainerSize() ? this.container2.getItem(i - this.container1.getContainerSize()) : this.container1.getItem(i); ++ public ItemStack getItem(int index) { ++ return index >= this.container1.getContainerSize() ? this.container2.getItem(index - this.container1.getContainerSize()) : this.container1.getItem(index); + } + + @Override +- @Override +- public ItemStack removeItem(int i, int j) { +- return i >= this.container1.getContainerSize() ? this.container2.removeItem(i - this.container1.getContainerSize(), j) : this.container1.removeItem(i, j); ++ public ItemStack removeItem(int index, int count) { ++ return index >= this.container1.getContainerSize() ? this.container2.removeItem(index - this.container1.getContainerSize(), count) : this.container1.removeItem(index, count); + } + + @Override +- @Override +- public ItemStack removeItemNoUpdate(int i) { +- return i >= this.container1.getContainerSize() ? this.container2.removeItemNoUpdate(i - this.container1.getContainerSize()) : this.container1.removeItemNoUpdate(i); ++ public ItemStack removeItemNoUpdate(int index) { ++ return index >= this.container1.getContainerSize() ? this.container2.removeItemNoUpdate(index - this.container1.getContainerSize()) : this.container1.removeItemNoUpdate(index); + } + + @Override +- @Override +- public void setItem(int i, ItemStack itemstack) { +- if (i >= this.container1.getContainerSize()) { +- this.container2.setItem(i - this.container1.getContainerSize(), itemstack); ++ public void setItem(int index, ItemStack stack) { ++ if (index >= this.container1.getContainerSize()) { ++ this.container2.setItem(index - this.container1.getContainerSize(), stack); + } else { +- this.container1.setItem(i, itemstack); ++ this.container1.setItem(index, stack); + } + + } + + @Override +- @Override + public int getMaxStackSize() { +- return this.container1.getMaxStackSize(); ++ return Math.min(this.container1.getMaxStackSize(), this.container2.getMaxStackSize()); // CraftBukkit - check both sides + } + + @Override +- @Override + public void setChanged() { + this.container1.setChanged(); + this.container2.setChanged(); + } + + @Override +- @Override + public boolean stillValid(Player player) { + return this.container1.stillValid(player) && this.container2.stillValid(player); + } + + @Override +- @Override + public void startOpen(Player player) { + this.container1.startOpen(player); + this.container2.startOpen(player); + } + + @Override +- @Override + public void stopOpen(Player player) { + this.container1.stopOpen(player); + this.container2.stopOpen(player); + } + + @Override +- @Override +- public boolean canPlaceItem(int i, ItemStack itemstack) { +- return i >= this.container1.getContainerSize() ? this.container2.canPlaceItem(i - this.container1.getContainerSize(), itemstack) : this.container1.canPlaceItem(i, itemstack); ++ public boolean canPlaceItem(int index, ItemStack stack) { ++ return index >= this.container1.getContainerSize() ? this.container2.canPlaceItem(index - this.container1.getContainerSize(), stack) : this.container1.canPlaceItem(index, stack); + } + + @Override +- @Override + public void clearContent() { + this.container1.clearContent(); + this.container2.clearContent(); |