diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch new file mode 100644 index 0000000000..3293479c5a --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch @@ -0,0 +1,170 @@ +--- a/net/minecraft/world/inventory/TransientCraftingContainer.java ++++ b/net/minecraft/world/inventory/TransientCraftingContainer.java +@@ -1,18 +1,92 @@ + package net.minecraft.world.inventory; + ++import java.util.Iterator; + import java.util.List; + import net.minecraft.core.NonNullList; ++import net.minecraft.world.Container; + import net.minecraft.world.ContainerHelper; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.entity.player.StackedContents; + import net.minecraft.world.item.ItemStack; + +-public class TransientCraftingContainer implements CraftingContainer { ++// CraftBukkit start ++import java.util.List; ++import net.minecraft.world.item.crafting.RecipeHolder; ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.event.inventory.InventoryType; ++// CraftBukkit end ++ ++public class TransientCraftingContainer implements InventoryCrafting { ++ + private final NonNullList<ItemStack> items; + private final int width; + private final int height; + private final AbstractContainerMenu menu; + ++ // CraftBukkit start - add fields ++ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); ++ private RecipeHolder<?> currentRecipe; ++ public Container resultInventory; ++ private Player owner; ++ private int maxStack = MAX_STACK; ++ ++ public List<ItemStack> getContents() { ++ return this.items; ++ } ++ ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ public InventoryType getInvType() { ++ return items.size() == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH; ++ } ++ ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ public List<HumanEntity> getViewers() { ++ return transaction; ++ } ++ ++ public org.bukkit.inventory.InventoryHolder getOwner() { ++ return (owner == null) ? null : owner.getBukkitEntity(); ++ } ++ ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ ++ public void setMaxStackSize(int size) { ++ maxStack = size; ++ resultInventory.setMaxStackSize(size); ++ } ++ ++ @Override ++ public Location getLocation() { ++ return menu instanceof CraftingMenu ? ((CraftingMenu) menu).access.getLocation() : owner.getBukkitEntity().getLocation(); ++ } ++ ++ @Override ++ public RecipeHolder<?> getCurrentRecipe() { ++ return currentRecipe; ++ } ++ ++ @Override ++ public void setCurrentRecipe(RecipeHolder<?> currentRecipe) { ++ this.currentRecipe = currentRecipe; ++ } ++ ++ public TransientCraftingContainer(AbstractContainerMenu container, int i, int j, Player player) { ++ this(container, i, j); ++ this.owner = player; ++ } ++ // CraftBukkit end ++ + public TransientCraftingContainer(AbstractContainerMenu menu, int width, int height) { + this(menu, width, height, NonNullList.withSize(width * height, ItemStack.EMPTY)); + } +@@ -31,18 +105,24 @@ + + @Override + public boolean isEmpty() { +- for (ItemStack itemStack : this.items) { +- if (!itemStack.isEmpty()) { +- return false; ++ Iterator iterator = this.items.iterator(); ++ ++ ItemStack itemstack; ++ ++ do { ++ if (!iterator.hasNext()) { ++ return true; + } +- } + +- return true; ++ itemstack = (ItemStack) iterator.next(); ++ } while (itemstack.isEmpty()); ++ ++ return false; + } + + @Override + public ItemStack getItem(int slot) { +- return slot >= this.getContainerSize() ? ItemStack.EMPTY : this.items.get(slot); ++ return slot >= this.getContainerSize() ? ItemStack.EMPTY : (ItemStack) this.items.get(slot); + } + + @Override +@@ -52,12 +132,13 @@ + + @Override + public ItemStack removeItem(int slot, int amount) { +- ItemStack itemStack = ContainerHelper.removeItem(this.items, slot, amount); +- if (!itemStack.isEmpty()) { ++ ItemStack itemstack = ContainerHelper.removeItem(this.items, slot, amount); ++ ++ if (!itemstack.isEmpty()) { + this.menu.slotsChanged(this); + } + +- return itemStack; ++ return itemstack; + } + + @Override +@@ -67,8 +148,7 @@ + } + + @Override +- public void setChanged() { +- } ++ public void setChanged() {} + + @Override + public boolean stillValid(Player player) { +@@ -97,8 +177,13 @@ + + @Override + public void fillStackedContents(StackedContents contents) { +- for (ItemStack itemStack : this.items) { +- contents.accountSimpleStack(itemStack); ++ Iterator iterator = this.items.iterator(); ++ ++ while (iterator.hasNext()) { ++ ItemStack itemstack = (ItemStack) iterator.next(); ++ ++ contents.accountSimpleStack(itemstack); + } ++ + } + } |