2024-12-11 22:26:55 +01:00
|
|
|
--- a/net/minecraft/world/CompoundContainer.java
|
|
|
|
+++ b/net/minecraft/world/CompoundContainer.java
|
2021-03-15 23:00:00 +01:00
|
|
|
@@ -3,11 +3,62 @@
|
2024-12-11 22:26:55 +01:00
|
|
|
import net.minecraft.world.entity.player.Player;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.item.ItemStack;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2016-11-17 02:41:03 +01:00
|
|
|
+import java.util.ArrayList;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import java.util.List;
|
2016-02-29 22:32:46 +01:00
|
|
|
+import org.bukkit.Location;
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
+import org.bukkit.entity.HumanEntity;
|
|
|
|
+// CraftBukkit end
|
2019-04-23 04:00:00 +02:00
|
|
|
+
|
2024-12-11 22:26:55 +01:00
|
|
|
public class CompoundContainer implements Container {
|
2018-07-15 02:00:00 +02:00
|
|
|
|
2024-12-11 22:26:55 +01:00
|
|
|
public final Container container1;
|
|
|
|
public final Container container2;
|
2015-06-06 11:33:48 +02:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - add fields and methods
|
|
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
|
|
+
|
2016-11-17 02:41:03 +01:00
|
|
|
+ public List<ItemStack> getContents() {
|
2021-11-21 23:00:00 +01:00
|
|
|
+ List<ItemStack> result = new ArrayList<ItemStack>(this.getContainerSize());
|
|
|
|
+ for (int i = 0; i < this.getContainerSize(); i++) {
|
2016-11-17 02:41:03 +01:00
|
|
|
+ result.add(this.getItem(i));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onOpen(CraftHumanEntity who) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.container1.onOpen(who);
|
|
|
|
+ this.container2.onOpen(who);
|
2024-12-11 22:26:55 +01:00
|
|
|
+ this.transaction.add(who);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onClose(CraftHumanEntity who) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.container1.onClose(who);
|
|
|
|
+ this.container2.onClose(who);
|
2024-12-11 22:26:55 +01:00
|
|
|
+ this.transaction.remove(who);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<HumanEntity> getViewers() {
|
2024-12-11 22:26:55 +01:00
|
|
|
+ return this.transaction;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.container1.setMaxStackSize(size);
|
|
|
|
+ this.container2.setMaxStackSize(size);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Location getLocation() {
|
2024-12-11 22:26:55 +01:00
|
|
|
+ return this.container1.getLocation(); // TODO: right?
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2015-06-06 11:33:48 +02:00
|
|
|
+
|
2024-12-11 22:26:55 +01:00
|
|
|
public CompoundContainer(Container first, Container second) {
|
|
|
|
this.container1 = first;
|
|
|
|
this.container2 = second;
|
2021-11-21 23:00:00 +01:00
|
|
|
@@ -54,7 +105,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2014-11-25 22:32:16 +01:00
|
|
|
public int getMaxStackSize() {
|
2021-06-11 07:00:00 +02:00
|
|
|
- return this.container1.getMaxStackSize();
|
|
|
|
+ return Math.min(this.container1.getMaxStackSize(), this.container2.getMaxStackSize()); // CraftBukkit - check both sides
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|