Paper/nms-patches/InventoryCrafting.patch
2016-11-17 12:41:03 +11:00

72 lines
2.0 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 {
@@ -9,6 +17,53 @@
private final int c;
private final Container d;
+ // CraftBukkit start - add fields
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ public 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();
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ resultInventory.setMaxStackSize(size);
+ }
+
+ @Override
+ public Location getLocation() {
+ return owner.getBukkitEntity().getLocation();
+ }
+
+ 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.d = container;