aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/CompoundContainer.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/CompoundContainer.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/CompoundContainer.java.patch119
1 files changed, 119 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/CompoundContainer.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/CompoundContainer.java.patch
new file mode 100644
index 0000000000..e7ef6fbff5
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/CompoundContainer.java.patch
@@ -0,0 +1,119 @@
+--- a/net/minecraft/world/CompoundContainer.java
++++ b/net/minecraft/world/CompoundContainer.java
+@@ -3,10 +3,62 @@
+ 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;
++
++ // 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;
+@@ -28,23 +80,17 @@
+
+ @Override
+ public ItemStack getItem(int index) {
+- return index >= this.container1.getContainerSize()
+- ? this.container2.getItem(index - this.container1.getContainerSize())
+- : this.container1.getItem(index);
++ return index >= this.container1.getContainerSize() ? this.container2.getItem(index - this.container1.getContainerSize()) : this.container1.getItem(index);
+ }
+
+ @Override
+ 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);
++ return index >= this.container1.getContainerSize() ? this.container2.removeItem(index - this.container1.getContainerSize(), count) : this.container1.removeItem(index, count);
+ }
+
+ @Override
+ public ItemStack removeItemNoUpdate(int index) {
+- return index >= this.container1.getContainerSize()
+- ? this.container2.removeItemNoUpdate(index - this.container1.getContainerSize())
+- : this.container1.removeItemNoUpdate(index);
++ return index >= this.container1.getContainerSize() ? this.container2.removeItemNoUpdate(index - this.container1.getContainerSize()) : this.container1.removeItemNoUpdate(index);
+ }
+
+ @Override
+@@ -54,11 +100,12 @@
+ } else {
+ this.container1.setItem(index, stack);
+ }
++
+ }
+
+ @Override
+ public int getMaxStackSize() {
+- return this.container1.getMaxStackSize();
++ return Math.min(this.container1.getMaxStackSize(), this.container2.getMaxStackSize()); // CraftBukkit - check both sides
+ }
+
+ @Override
+@@ -86,9 +133,7 @@
+
+ @Override
+ 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);
++ return index >= this.container1.getContainerSize() ? this.container2.canPlaceItem(index - this.container1.getContainerSize(), stack) : this.container1.canPlaceItem(index, stack);
+ }
+
+ @Override