Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 104 lines 3.3 kB view raw
1package net.minecraft.server; 2 3public class ContainerWorkbench extends Container { 4 5 public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3); 6 public IInventory resultInventory = new InventoryCraftResult(); 7 private World c; 8 private int h; 9 private int i; 10 private int j; 11 12 public ContainerWorkbench(InventoryPlayer inventoryplayer, World world, int i, int j, int k) { 13 this.c = world; 14 this.h = i; 15 this.i = j; 16 this.j = k; 17 this.a((Slot) (new SlotResult(inventoryplayer.d, this.craftInventory, this.resultInventory, 0, 124, 35))); 18 19 int l; 20 int i1; 21 22 for (l = 0; l < 3; ++l) { 23 for (i1 = 0; i1 < 3; ++i1) { 24 this.a(new Slot(this.craftInventory, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); 25 } 26 } 27 28 for (l = 0; l < 3; ++l) { 29 for (i1 = 0; i1 < 9; ++i1) { 30 this.a(new Slot(inventoryplayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); 31 } 32 } 33 34 for (l = 0; l < 9; ++l) { 35 this.a(new Slot(inventoryplayer, l, 8 + l * 18, 142)); 36 } 37 38 this.a((IInventory) this.craftInventory); 39 } 40 41 public void a(IInventory iinventory) { 42 // CraftBukkit start 43 ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory); 44 this.resultInventory.setItem(0, craftResult); 45 if (super.listeners.size() < 1) { 46 return; 47 } 48 49 EntityPlayer player = (EntityPlayer) super.listeners.get(0); // TODO: Is this _always_ correct? Seems like it. 50 player.netServerHandler.sendPacket(new Packet103SetSlot(player.activeContainer.windowId, 0, craftResult)); 51 // CraftBukkit end 52 } 53 54 public void a(EntityHuman entityhuman) { 55 super.a(entityhuman); 56 if (!this.c.isStatic) { 57 for (int i = 0; i < 9; ++i) { 58 ItemStack itemstack = this.craftInventory.getItem(i); 59 60 if (itemstack != null) { 61 entityhuman.b(itemstack); 62 } 63 } 64 } 65 } 66 67 public boolean b(EntityHuman entityhuman) { 68 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; 69 } 70 71 public ItemStack a(int i) { 72 ItemStack itemstack = null; 73 Slot slot = (Slot) this.e.get(i); 74 75 if (slot != null && slot.b()) { 76 ItemStack itemstack1 = slot.getItem(); 77 78 itemstack = itemstack1.cloneItemStack(); 79 if (i == 0) { 80 this.a(itemstack1, 10, 46, true); 81 } else if (i >= 10 && i < 37) { 82 this.a(itemstack1, 37, 46, false); 83 } else if (i >= 37 && i < 46) { 84 this.a(itemstack1, 10, 37, false); 85 } else { 86 this.a(itemstack1, 10, 46, false); 87 } 88 89 if (itemstack1.count == 0) { 90 slot.c((ItemStack) null); 91 } else { 92 slot.c(); 93 } 94 95 if (itemstack1.count == itemstack.count) { 96 return null; 97 } 98 99 slot.a(itemstack1); 100 } 101 102 return itemstack; 103 } 104}