Paper/nms-patches/InventoryCrafting.patch
2019-05-28 06:30:00 +10:00

87 lines
2.4 KiB
Diff

--- a/net/minecraft/server/InventoryCrafting.java
+++ b/net/minecraft/server/InventoryCrafting.java
@@ -1,6 +1,14 @@
package net.minecraft.server;
import java.util.Iterator;
+// CraftBukkit start
+import java.util.List;
+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 InventoryCrafting implements IInventory, AutoRecipeOutput {
@@ -9,6 +17,68 @@
private final int c;
public final Container container;
+ // CraftBukkit start - add fields
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private IRecipe currentRecipe;
+ public IInventory resultInventory;
+ private EntityHuman 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 container instanceof ContainerWorkbench ? ((ContainerWorkbench) container).containerAccess.getLocation() : owner.getBukkitEntity().getLocation();
+ }
+
+ @Override
+ public IRecipe getCurrentRecipe() {
+ return currentRecipe;
+ }
+
+ @Override
+ public void setCurrentRecipe(IRecipe currentRecipe) {
+ this.currentRecipe = currentRecipe;
+ }
+
+ public InventoryCrafting(Container container, int i, int j, EntityHuman player) {
+ this(container, i, j);
+ this.owner = player;
+ }
+ // CraftBukkit end
+
public InventoryCrafting(Container container, int i, int j) {
this.items = NonNullList.a(i * j, ItemStack.a);
this.container = container;