From bee74680e607c2e29b038329f62181238911cd83 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Sun, 14 Jan 2024 11:04:49 +0100 Subject: add remapped patches as a test --- .../TransientCraftingContainer.java.patch | 170 +++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch (limited to 'patch-remap/mache-vineflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch') 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 items; + private final int width; + private final int height; + private final AbstractContainerMenu menu; + ++ // CraftBukkit start - add fields ++ public List transaction = new java.util.ArrayList(); ++ private RecipeHolder currentRecipe; ++ public Container resultInventory; ++ private Player owner; ++ private int maxStack = MAX_STACK; ++ ++ public List 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 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); + } ++ + } + } -- cgit v1.2.3