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

87 Zeilen
2.3 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 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;