mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 08:39:58 +03:00
88 lines
2.8 KiB
Diff
88 lines
2.8 KiB
Diff
--- ../src-base/minecraft/net/minecraft/inventory/InventoryCrafting.java
|
|
+++ ../src-work/minecraft/net/minecraft/inventory/InventoryCrafting.java
|
|
@@ -3,18 +3,83 @@
|
|
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
|
|
+
|
|
+ // CatServer start
|
|
+ @Deprecated // For RealBench compatible, do not call the method
|
|
+ public InventoryCrafting setOwner(EntityPlayer player) {
|
|
+ this.owner = player;
|
|
+ return this;
|
|
+ }
|
|
+ // CatServer end
|
|
+
|
|
public InventoryCrafting(Container eventHandlerIn, int width, int height)
|
|
{
|
|
this.stackList = NonNullList.<ItemStack>withSize(width * height, ItemStack.EMPTY);
|