Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 147 lines 4.5 kB view raw
1package net.minecraft.server; 2 3import java.util.Random; 4 5public class BlockFurnace extends BlockContainer { 6 7 private Random a = new Random(); 8 private final boolean b; 9 private static boolean c = false; 10 11 protected BlockFurnace(int i, boolean flag) { 12 super(i, Material.STONE); 13 this.b = flag; 14 this.textureId = 45; 15 } 16 17 public int a(int i, Random random) { 18 return Block.FURNACE.id; 19 } 20 21 public void c(World world, int i, int j, int k) { 22 super.c(world, i, j, k); 23 this.g(world, i, j, k); 24 } 25 26 private void g(World world, int i, int j, int k) { 27 if (!world.isStatic) { 28 int l = world.getTypeId(i, j, k - 1); 29 int i1 = world.getTypeId(i, j, k + 1); 30 int j1 = world.getTypeId(i - 1, j, k); 31 int k1 = world.getTypeId(i + 1, j, k); 32 byte b0 = 3; 33 34 if (Block.o[l] && !Block.o[i1]) { 35 b0 = 3; 36 } 37 38 if (Block.o[i1] && !Block.o[l]) { 39 b0 = 2; 40 } 41 42 if (Block.o[j1] && !Block.o[k1]) { 43 b0 = 5; 44 } 45 46 if (Block.o[k1] && !Block.o[j1]) { 47 b0 = 4; 48 } 49 50 world.setData(i, j, k, b0); 51 } 52 } 53 54 public int a(int i) { 55 return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId - 1 : this.textureId)); 56 } 57 58 public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { 59 if (world.isStatic) { 60 return true; 61 } else { 62 TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k); 63 64 entityhuman.a(tileentityfurnace); 65 return true; 66 } 67 } 68 69 public static void a(boolean flag, World world, int i, int j, int k) { 70 int l = world.getData(i, j, k); 71 TileEntity tileentity = world.getTileEntity(i, j, k); 72 if (tileentity == null) return; // CraftBukkit 73 74 c = true; 75 if (flag) { 76 world.setTypeId(i, j, k, Block.BURNING_FURNACE.id); 77 } else { 78 world.setTypeId(i, j, k, Block.FURNACE.id); 79 } 80 81 c = false; 82 world.setData(i, j, k, l); 83 tileentity.j(); 84 world.setTileEntity(i, j, k, tileentity); 85 } 86 87 protected TileEntity a_() { 88 return new TileEntityFurnace(); 89 } 90 91 public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) { 92 int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3; 93 94 if (l == 0) { 95 world.setData(i, j, k, 2); 96 } 97 98 if (l == 1) { 99 world.setData(i, j, k, 5); 100 } 101 102 if (l == 2) { 103 world.setData(i, j, k, 3); 104 } 105 106 if (l == 3) { 107 world.setData(i, j, k, 4); 108 } 109 } 110 111 public void remove(World world, int i, int j, int k) { 112 if (!c) { 113 TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k); 114 115 if (tileentityfurnace == null) return; // CraftBukkit 116 for (int l = 0; l < tileentityfurnace.getSize(); ++l) { 117 ItemStack itemstack = tileentityfurnace.getItem(l); 118 119 if (itemstack != null) { 120 float f = this.a.nextFloat() * 0.8F + 0.1F; 121 float f1 = this.a.nextFloat() * 0.8F + 0.1F; 122 float f2 = this.a.nextFloat() * 0.8F + 0.1F; 123 124 while (itemstack.count > 0) { 125 int i1 = this.a.nextInt(21) + 10; 126 127 if (i1 > itemstack.count) { 128 i1 = itemstack.count; 129 } 130 131 itemstack.count -= i1; 132 EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData())); 133 float f3 = 0.05F; 134 135 entityitem.motX = (double) ((float) this.a.nextGaussian() * f3); 136 entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F); 137 entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3); 138 world.addEntity(entityitem); 139 } 140 tileentityfurnace.setItem(l, null); 141 } 142 } 143 } 144 145 super.remove(world, i, j, k); 146 } 147}