aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/SimpleContainer.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/SimpleContainer.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/SimpleContainer.java.patch361
1 files changed, 361 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/SimpleContainer.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/SimpleContainer.java.patch
new file mode 100644
index 0000000000..5b0227ad71
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/SimpleContainer.java.patch
@@ -0,0 +1,361 @@
+--- a/net/minecraft/world/SimpleContainer.java
++++ b/net/minecraft/world/SimpleContainer.java
+@@ -14,42 +14,99 @@
+ import net.minecraft.world.item.Item;
+ import net.minecraft.world.item.ItemStack;
+
++// CraftBukkit start
++import org.bukkit.Location;
++import org.bukkit.craftbukkit.entity.CraftHumanEntity;
++import org.bukkit.entity.HumanEntity;
++// CraftBukkit end
++
+ public class SimpleContainer implements Container, StackedContentsCompatible {
+
+ private final int size;
+- private final NonNullList<ItemStack> items;
++ public final NonNullList<ItemStack> items;
+ @Nullable
+ private List<ContainerListener> listeners;
+
+- public SimpleContainer(int i) {
++ // CraftBukkit start - add fields and methods
++ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
++ private int maxStack = MAX_STACK;
++ protected org.bukkit.inventory.InventoryHolder bukkitOwner;
++
++ public List<ItemStack> getContents() {
++ return this.items;
++ }
++
++ public void onOpen(CraftHumanEntity who) {
++ transaction.add(who);
++ }
++
++ public void onClose(CraftHumanEntity who) {
++ transaction.remove(who);
++ }
++
++ public List<HumanEntity> getViewers() {
++ return transaction;
++ }
++
++ @Override
++ public int getMaxStackSize() {
++ return maxStack;
++ }
++
++ public void setMaxStackSize(int i) {
++ maxStack = i;
++ }
++
++ public org.bukkit.inventory.InventoryHolder getOwner() {
++ return bukkitOwner;
++ }
++
++ @Override
++ public Location getLocation() {
++ return null;
++ }
++
++ public SimpleContainer(SimpleContainer original) {
++ this(original.size);
++ for (int slot = 0; slot < original.size; slot++) {
++ this.items.set(slot, original.items.get(slot).copy());
++ }
++ }
++
++ public SimpleContainer(int size) {
++ this(size, null);
++ }
++
++ public SimpleContainer(int i, org.bukkit.inventory.InventoryHolder owner) {
++ this.bukkitOwner = owner;
++ // CraftBukkit end
+ this.size = i;
+ this.items = NonNullList.withSize(i, ItemStack.EMPTY);
+ }
+
+- public SimpleContainer(ItemStack... aitemstack) {
+- this.size = aitemstack.length;
+- this.items = NonNullList.of(ItemStack.EMPTY, aitemstack);
++ public SimpleContainer(ItemStack... items) {
++ this.size = items.length;
++ this.items = NonNullList.of(ItemStack.EMPTY, items);
+ }
+
+- public void addListener(ContainerListener containerlistener) {
++ public void addListener(ContainerListener listener) {
+ if (this.listeners == null) {
+ this.listeners = Lists.newArrayList();
+ }
+
+- this.listeners.add(containerlistener);
++ this.listeners.add(listener);
+ }
+
+- public void removeListener(ContainerListener containerlistener) {
++ public void removeListener(ContainerListener listener) {
+ if (this.listeners != null) {
+- this.listeners.remove(containerlistener);
++ this.listeners.remove(listener);
+ }
+
+ }
+
+ @Override
+- @Override
+- public ItemStack getItem(int i) {
+- return i >= 0 && i < this.items.size() ? (ItemStack) this.items.get(i) : ItemStack.EMPTY;
++ public ItemStack getItem(int index) {
++ return index >= 0 && index < this.items.size() ? (ItemStack) this.items.get(index) : ItemStack.EMPTY;
+ }
+
+ public List<ItemStack> removeAllItems() {
+@@ -62,9 +119,8 @@
+ }
+
+ @Override
+- @Override
+- public ItemStack removeItem(int i, int j) {
+- ItemStack itemstack = ContainerHelper.removeItem(this.items, i, j);
++ public ItemStack removeItem(int index, int count) {
++ ItemStack itemstack = ContainerHelper.removeItem(this.items, index, count);
+
+ if (!itemstack.isEmpty()) {
+ this.setChanged();
+@@ -73,18 +129,18 @@
+ return itemstack;
+ }
+
+- public ItemStack removeItemType(Item item, int i) {
++ public ItemStack removeItemType(Item item, int amount) {
+ ItemStack itemstack = new ItemStack(item, 0);
+
+ for (int j = this.size - 1; j >= 0; --j) {
+ ItemStack itemstack1 = this.getItem(j);
+
+ if (itemstack1.getItem().equals(item)) {
+- int k = i - itemstack.getCount();
++ int k = amount - itemstack.getCount();
+ ItemStack itemstack2 = itemstack1.split(k);
+
+ itemstack.grow(itemstack2.getCount());
+- if (itemstack.getCount() == i) {
++ if (itemstack.getCount() == amount) {
+ break;
+ }
+ }
+@@ -97,11 +153,11 @@
+ return itemstack;
+ }
+
+- public ItemStack addItem(ItemStack itemstack) {
+- if (itemstack.isEmpty()) {
++ public ItemStack addItem(ItemStack stack) {
++ if (stack.isEmpty()) {
+ return ItemStack.EMPTY;
+ } else {
+- ItemStack itemstack1 = itemstack.copy();
++ ItemStack itemstack1 = stack.copy();
+
+ this.moveItemToOccupiedSlotsWithSameType(itemstack1);
+ if (itemstack1.isEmpty()) {
+@@ -113,14 +169,14 @@
+ }
+ }
+
+- public boolean canAddItem(ItemStack itemstack) {
++ public boolean canAddItem(ItemStack stack) {
+ boolean flag = false;
+ Iterator iterator = this.items.iterator();
+
+ while (iterator.hasNext()) {
+ ItemStack itemstack1 = (ItemStack) iterator.next();
+
+- if (itemstack1.isEmpty() || ItemStack.isSameItemSameTags(itemstack1, itemstack) && itemstack1.getCount() < itemstack1.getMaxStackSize()) {
++ if (itemstack1.isEmpty() || ItemStack.isSameItemSameTags(itemstack1, stack) && itemstack1.getCount() < itemstack1.getMaxStackSize()) {
+ flag = true;
+ break;
+ }
+@@ -130,37 +186,33 @@
+ }
+
+ @Override
+- @Override
+- public ItemStack removeItemNoUpdate(int i) {
+- ItemStack itemstack = (ItemStack) this.items.get(i);
++ public ItemStack removeItemNoUpdate(int index) {
++ ItemStack itemstack = (ItemStack) this.items.get(index);
+
+ if (itemstack.isEmpty()) {
+ return ItemStack.EMPTY;
+ } else {
+- this.items.set(i, ItemStack.EMPTY);
++ this.items.set(index, ItemStack.EMPTY);
+ return itemstack;
+ }
+ }
+
+ @Override
+- @Override
+- public void setItem(int i, ItemStack itemstack) {
+- this.items.set(i, itemstack);
+- if (!itemstack.isEmpty() && itemstack.getCount() > this.getMaxStackSize()) {
+- itemstack.setCount(this.getMaxStackSize());
++ public void setItem(int index, ItemStack stack) {
++ this.items.set(index, stack);
++ if (!stack.isEmpty() && stack.getCount() > this.getMaxStackSize()) {
++ stack.setCount(this.getMaxStackSize());
+ }
+
+ this.setChanged();
+ }
+
+ @Override
+- @Override
+ public int getContainerSize() {
+ return this.size;
+ }
+
+ @Override
+- @Override
+ public boolean isEmpty() {
+ Iterator iterator = this.items.iterator();
+
+@@ -178,72 +230,67 @@
+ }
+
+ @Override
+- @Override
+ public void setChanged() {
+ if (this.listeners != null) {
+ Iterator iterator = this.listeners.iterator();
+
+ while (iterator.hasNext()) {
+- ContainerListener containerlistener = (ContainerListener) iterator.next();
++ ContainerListener iinventorylistener = (ContainerListener) iterator.next();
+
+- containerlistener.containerChanged(this);
++ iinventorylistener.containerChanged(this);
+ }
+ }
+
+ }
+
+ @Override
+- @Override
+ public boolean stillValid(Player player) {
+ return true;
+ }
+
+ @Override
+- @Override
+ public void clearContent() {
+ this.items.clear();
+ this.setChanged();
+ }
+
+ @Override
+- @Override
+- public void fillStackedContents(StackedContents stackedcontents) {
++ public void fillStackedContents(StackedContents helper) {
+ Iterator iterator = this.items.iterator();
+
+ while (iterator.hasNext()) {
+ ItemStack itemstack = (ItemStack) iterator.next();
+
+- stackedcontents.accountStack(itemstack);
++ helper.accountStack(itemstack);
+ }
+
+ }
+
+- @Override
+ public String toString() {
+ return ((List) this.items.stream().filter((itemstack) -> {
+ return !itemstack.isEmpty();
+ }).collect(Collectors.toList())).toString();
+ }
+
+- private void moveItemToEmptySlots(ItemStack itemstack) {
++ private void moveItemToEmptySlots(ItemStack stack) {
+ for (int i = 0; i < this.size; ++i) {
+ ItemStack itemstack1 = this.getItem(i);
+
+ if (itemstack1.isEmpty()) {
+- this.setItem(i, itemstack.copyAndClear());
++ this.setItem(i, stack.copyAndClear());
+ return;
+ }
+ }
+
+ }
+
+- private void moveItemToOccupiedSlotsWithSameType(ItemStack itemstack) {
++ private void moveItemToOccupiedSlotsWithSameType(ItemStack stack) {
+ for (int i = 0; i < this.size; ++i) {
+ ItemStack itemstack1 = this.getItem(i);
+
+- if (ItemStack.isSameItemSameTags(itemstack1, itemstack)) {
+- this.moveItemsBetweenStacks(itemstack, itemstack1);
+- if (itemstack.isEmpty()) {
++ if (ItemStack.isSameItemSameTags(itemstack1, stack)) {
++ this.moveItemsBetweenStacks(stack, itemstack1);
++ if (stack.isEmpty()) {
+ return;
+ }
+ }
+@@ -251,23 +298,23 @@
+
+ }
+
+- private void moveItemsBetweenStacks(ItemStack itemstack, ItemStack itemstack1) {
+- int i = Math.min(this.getMaxStackSize(), itemstack1.getMaxStackSize());
+- int j = Math.min(itemstack.getCount(), i - itemstack1.getCount());
++ private void moveItemsBetweenStacks(ItemStack stack, ItemStack other) {
++ int i = Math.min(this.getMaxStackSize(), other.getMaxStackSize());
++ int j = Math.min(stack.getCount(), i - other.getCount());
+
+ if (j > 0) {
+- itemstack1.grow(j);
+- itemstack.shrink(j);
++ other.grow(j);
++ stack.shrink(j);
+ this.setChanged();
+ }
+
+ }
+
+- public void fromTag(ListTag listtag) {
++ public void fromTag(ListTag containerNbt) {
+ this.clearContent();
+
+- for (int i = 0; i < listtag.size(); ++i) {
+- ItemStack itemstack = ItemStack.of(listtag.getCompound(i));
++ for (int i = 0; i < containerNbt.size(); ++i) {
++ ItemStack itemstack = ItemStack.of(containerNbt.getCompound(i));
+
+ if (!itemstack.isEmpty()) {
+ this.addItem(itemstack);
+@@ -277,17 +324,17 @@
+ }
+
+ public ListTag createTag() {
+- ListTag listtag = new ListTag();
++ ListTag nbttaglist = new ListTag();
+
+ for (int i = 0; i < this.getContainerSize(); ++i) {
+ ItemStack itemstack = this.getItem(i);
+
+ if (!itemstack.isEmpty()) {
+- listtag.add(itemstack.save(new CompoundTag()));
++ nbttaglist.add(itemstack.save(new CompoundTag()));
+ }
+ }
+
+- return listtag;
++ return nbttaglist;
+ }
+
+ public NonNullList<ItemStack> getItems() {