diff options
author | Celtic Minstrel <celtic.minstrel.ca@some.place> | 2012-02-29 13:56:35 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-02-29 15:19:07 -0500 |
commit | 0842bab48b1c24f113c61606a294f5bcdf2e1315 (patch) | |
tree | e10864f22a8c54129d4e670ec15b8da594c333eb /src/main/java/net/minecraft/server/ContainerWorkbench.java | |
parent | 10e593649c224db2f0a4227bdf6eef44bfa16865 (diff) | |
download | craftbukkit-0842bab48b1c24f113c61606a294f5bcdf2e1315.tar craftbukkit-0842bab48b1c24f113c61606a294f5bcdf2e1315.tar.gz craftbukkit-0842bab48b1c24f113c61606a294f5bcdf2e1315.tar.lz craftbukkit-0842bab48b1c24f113c61606a294f5bcdf2e1315.tar.xz craftbukkit-0842bab48b1c24f113c61606a294f5bcdf2e1315.zip |
[Bleeding] Implementation of inventory framework. Addresses BUKKIT-856
See the corresponding Bukkit commit for details.
Implementation details:
- Any packets that include an itemstack will send air stacks as null; maybe this will even eliminate the client crash that occurs if the client receives an air stack
- Better handling of null itemstacks in general (ie less converting them to air stacks)
- Inventory.setContents() can now take an array smaller than the inventory without error
- Player.updateInventory() should now correctly update the result slot in a crafting inventory
Some small credit goes to Afforess (initial implementation of openInventory() methods) and Drakia (initial implementation of InventoryOpenEvent and InventoryCloseEvent).
Diffstat (limited to 'src/main/java/net/minecraft/server/ContainerWorkbench.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ContainerWorkbench.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/ContainerWorkbench.java b/src/main/java/net/minecraft/server/ContainerWorkbench.java index 46c5c074..b007690e 100644 --- a/src/main/java/net/minecraft/server/ContainerWorkbench.java +++ b/src/main/java/net/minecraft/server/ContainerWorkbench.java @@ -1,15 +1,30 @@ package net.minecraft.server; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + public class ContainerWorkbench extends Container { - public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3); - public IInventory resultInventory = new InventoryCraftResult(); + public InventoryCrafting craftInventory; // CraftBukkit - move initialization into constructor + public IInventory resultInventory; // CraftBukkit - move initialization into constructor private World c; private int h; private int i; private int j; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; + // CraftBukkit end public ContainerWorkbench(PlayerInventory playerinventory, World world, int i, int j, int k) { + // CraftBukkit start - switched order of IInventory construction and stored player + this.resultInventory = new InventoryCraftResult(); + this.craftInventory = new InventoryCrafting(this, 3, 3); + this.craftInventory.resultInventory = this.resultInventory; + this.player = playerinventory; + // CraftBukkit end this.c = world; this.h = i; this.i = j; @@ -40,6 +55,7 @@ public class ContainerWorkbench extends Container { public void a(IInventory iinventory) { // CraftBukkit start + CraftingManager.getInstance().lastCraftView = getBukkitView(); ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory); this.resultInventory.setItem(0, craftResult); if (super.listeners.size() < 1) { @@ -65,6 +81,7 @@ public class ContainerWorkbench extends Container { } public boolean b(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return this.c.getTypeId(this.h, this.i, this.j) != Block.WORKBENCH.id ? false : entityhuman.e((double) this.h + 0.5D, (double) this.i + 0.5D, (double) this.j + 0.5D) <= 64.0D; } @@ -107,4 +124,15 @@ public class ContainerWorkbench extends Container { return itemstack; } + + // CraftBukkit start + public CraftInventoryView getBukkitView() { + if (bukkitEntity != null) { + return bukkitEntity; + } + CraftInventoryCrafting inventory = new CraftInventoryCrafting(this.craftInventory, this.resultInventory); + bukkitEntity = new CraftInventoryView(this.player.d.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end } |