3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 23:00:08 +01:00
Paper/nms-patches/InventoryCrafting.patch
2018-07-15 10:00:00 +10:00

82 Zeilen
2.2 KiB
Diff

--- a/net/minecraft/server/InventoryCrafting.java
+++ b/net/minecraft/server/InventoryCrafting.java
@@ -2,6 +2,14 @@
import java.util.Iterator;
import javax.annotation.Nullable;
+// 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 {
@@ -10,6 +18,63 @@
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();
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ resultInventory.setMaxStackSize(size);
+ }
+
+ @Override
+ public Location getLocation() {
+ return 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;