Files
CatServer/patches/net/minecraft/inventory/InventoryCrafting.java.patch
2019-02-24 22:29:41 +08:00

80 lines
2.5 KiB
Diff

--- ../src-base/minecraft/net/minecraft/inventory/InventoryCrafting.java
+++ ../src-work/minecraft/net/minecraft/inventory/InventoryCrafting.java
@@ -3,18 +3,75 @@
import net.minecraft.client.util.RecipeItemHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.inventory.InventoryType;
+import java.util.List;
+
public class InventoryCrafting implements IInventory
{
private final NonNullList<ItemStack> stackList;
private final int inventoryWidth;
private final int inventoryHeight;
- private final Container eventHandler;
+ public final Container eventHandler;
+ // CraftBukkit start - add fields
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ public IRecipe currentRecipe;
+ public IInventory resultInventory;
+ private EntityPlayer owner;
+ private int maxStack = MAX_STACK;
+
+ public List<ItemStack> getContents() {
+ return this.stackList;
+ }
+
+ @Override
+ public void onOpen(CraftHumanEntity who) {
+ transaction.add(who);
+ }
+
+ public InventoryType getInvType() {
+ return stackList.size() == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
+ }
+
+ @Override
+ public void onClose(CraftHumanEntity who) {
+ transaction.remove(who);
+ }
+
+ @Override
+ 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, EntityPlayer player) {
+ this(container, i, j);
+ this.owner = player;
+ }
+ // CraftBukkit end
+
public InventoryCrafting(Container eventHandlerIn, int width, int height)
{
this.stackList = NonNullList.<ItemStack>withSize(width * height, ItemStack.EMPTY);