diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch new file mode 100644 index 0000000000..d23f3abafa --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/TransientCraftingContainer.java.patch @@ -0,0 +1,207 @@ +--- a/net/minecraft/world/inventory/TransientCraftingContainer.java ++++ b/net/minecraft/world/inventory/TransientCraftingContainer.java +@@ -3,37 +3,107 @@ + 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; + +- public TransientCraftingContainer(AbstractContainerMenu abstractcontainermenu, int i, int j) { +- this(abstractcontainermenu, i, j, NonNullList.withSize(i * j, ItemStack.EMPTY)); ++ // 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 TransientCraftingContainer(AbstractContainerMenu abstractcontainermenu, int i, int j, NonNullList<ItemStack> nonnulllist) { +- this.items = nonnulllist; +- this.menu = abstractcontainermenu; +- this.width = i; +- this.height = j; ++ 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)); ++ } ++ ++ public TransientCraftingContainer(AbstractContainerMenu menu, int width, int height, NonNullList<ItemStack> items) { ++ this.items = items; ++ this.menu = menu; ++ this.width = width; ++ this.height = height; ++ } ++ ++ @Override + public int getContainerSize() { + return this.items.size(); + } + + @Override +- @Override + public boolean isEmpty() { + Iterator iterator = this.items.iterator(); + +@@ -51,21 +121,18 @@ + } + + @Override +- @Override +- public ItemStack getItem(int i) { +- return i >= this.getContainerSize() ? ItemStack.EMPTY : (ItemStack) this.items.get(i); ++ public ItemStack getItem(int slot) { ++ return slot >= this.getContainerSize() ? ItemStack.EMPTY : (ItemStack) this.items.get(slot); + } + + @Override +- @Override +- public ItemStack removeItemNoUpdate(int i) { +- return ContainerHelper.takeItem(this.items, i); ++ public ItemStack removeItemNoUpdate(int slot) { ++ return ContainerHelper.takeItem(this.items, slot); + } + + @Override +- @Override +- public ItemStack removeItem(int i, int j) { +- ItemStack itemstack = ContainerHelper.removeItem(this.items, i, j); ++ public ItemStack removeItem(int slot, int amount) { ++ ItemStack itemstack = ContainerHelper.removeItem(this.items, slot, amount); + + if (!itemstack.isEmpty()) { + this.menu.slotsChanged(this); +@@ -75,55 +142,47 @@ + } + + @Override +- @Override +- public void setItem(int i, ItemStack itemstack) { +- this.items.set(i, itemstack); ++ public void setItem(int slot, ItemStack stack) { ++ this.items.set(slot, stack); + this.menu.slotsChanged(this); + } + + @Override +- @Override + public void setChanged() {} + + @Override +- @Override + public boolean stillValid(Player player) { + return true; + } + + @Override +- @Override + public void clearContent() { + this.items.clear(); + } + + @Override +- @Override + public int getHeight() { + return this.height; + } + + @Override +- @Override + public int getWidth() { + return this.width; + } + + @Override +- @Override + public List<ItemStack> getItems() { + return List.copyOf(this.items); + } + + @Override +- @Override +- public void fillStackedContents(StackedContents stackedcontents) { ++ public void fillStackedContents(StackedContents contents) { + Iterator iterator = this.items.iterator(); + + while (iterator.hasNext()) { + ItemStack itemstack = (ItemStack) iterator.next(); + +- stackedcontents.accountSimpleStack(itemstack); ++ contents.accountSimpleStack(itemstack); + } + + } |