Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 121 lines 4.6 kB view raw
1package net.minecraft.server; 2 3import me.devcody.uberbukkit.math.Vec3i; 4 5import java.util.Random; 6 7public class BlockChest extends BlockContainer { 8 9 private Random a = new Random(); 10 11 protected BlockChest(int i) { 12 super(i, Material.WOOD); 13 this.textureId = 26; 14 } 15 16 public int a(int i) { 17 return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId - 1 : (i == 3 ? this.textureId + 1 : this.textureId)); 18 } 19 20 public boolean canPlace(World world, int i, int j, int k) { 21 int l = 0; 22 23 if (world.getTypeId(i - 1, j, k) == this.id) { 24 ++l; 25 } 26 27 if (world.getTypeId(i + 1, j, k) == this.id) { 28 ++l; 29 } 30 31 if (world.getTypeId(i, j, k - 1) == this.id) { 32 ++l; 33 } 34 35 if (world.getTypeId(i, j, k + 1) == this.id) { 36 ++l; 37 } 38 39 return l > 1 ? false : (this.g(world, i - 1, j, k) ? false : (this.g(world, i + 1, j, k) ? false : (this.g(world, i, j, k - 1) ? false : !this.g(world, i, j, k + 1)))); 40 } 41 42 private boolean g(World world, int i, int j, int k) { 43 return world.getTypeId(i, j, k) != this.id ? false : (world.getTypeId(i - 1, j, k) == this.id ? true : (world.getTypeId(i + 1, j, k) == this.id ? true : (world.getTypeId(i, j, k - 1) == this.id ? true : world.getTypeId(i, j, k + 1) == this.id))); 44 } 45 46 public void remove(World world, int i, int j, int k) { 47 TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(i, j, k); 48 49 for (int l = 0; l < tileentitychest.getSize(); ++l) { 50 ItemStack itemstack = tileentitychest.getItem(l); 51 52 if (itemstack != null) { 53 float f = this.a.nextFloat() * 0.8F + 0.1F; 54 float f1 = this.a.nextFloat() * 0.8F + 0.1F; 55 float f2 = this.a.nextFloat() * 0.8F + 0.1F; 56 57 while (itemstack.count > 0) { 58 int i1 = this.a.nextInt(21) + 10; 59 60 if (i1 > itemstack.count) { 61 i1 = itemstack.count; 62 } 63 64 itemstack.count -= i1; 65 EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData())); 66 float f3 = 0.05F; 67 68 entityitem.motX = (double) ((float) this.a.nextGaussian() * f3); 69 entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F); 70 entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3); 71 world.addEntity(entityitem); 72 } 73 tileentitychest.setItem(l, null); 74 } 75 } 76 77 super.remove(world, i, j, k); 78 } 79 80 public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { 81 Object object = (TileEntityChest) world.getTileEntity(i, j, k); 82 83 if (world.e(i, j + 1, k)) { 84 return true; 85 } else if (world.getTypeId(i - 1, j, k) == this.id && world.e(i - 1, j + 1, k)) { 86 return true; 87 } else if (world.getTypeId(i + 1, j, k) == this.id && world.e(i + 1, j + 1, k)) { 88 return true; 89 } else if (world.getTypeId(i, j, k - 1) == this.id && world.e(i, j + 1, k - 1)) { 90 return true; 91 } else if (world.getTypeId(i, j, k + 1) == this.id && world.e(i, j + 1, k + 1)) { 92 return true; 93 } else { 94 if (world.getTypeId(i - 1, j, k) == this.id) { 95 object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i - 1, j, k), (IInventory) object); 96 } 97 98 if (world.getTypeId(i + 1, j, k) == this.id) { 99 object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i + 1, j, k)); 100 } 101 102 if (world.getTypeId(i, j, k - 1) == this.id) { 103 object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i, j, k - 1), (IInventory) object); 104 } 105 106 if (world.getTypeId(i, j, k + 1) == this.id) { 107 object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i, j, k + 1)); 108 } 109 110 if (!world.isStatic) { 111 entityhuman.a((IInventory) object, new Vec3i(i, j, k)); 112 } 113 114 return true; 115 } 116 } 117 118 protected TileEntity a_() { 119 return new TileEntityChest(); 120 } 121}