Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 189 lines 4.8 kB view raw
1package net.minecraft.server; 2 3import org.bukkit.event.block.BlockRedstoneEvent; 4 5public class BlockTrapdoor extends Block { 6 7 protected BlockTrapdoor(int i, Material material) { 8 super(i, material); 9 this.textureId = 84; 10 if (material == Material.ORE) { 11 ++this.textureId; 12 } 13 14 float f = 0.5F; 15 float f1 = 1.0F; 16 17 this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); 18 } 19 20 public boolean a() { 21 return false; 22 } 23 24 public boolean b() { 25 return false; 26 } 27 28 public AxisAlignedBB e(World world, int i, int j, int k) { 29 this.a(world, i, j, k); 30 return super.e(world, i, j, k); 31 } 32 33 public void a(IBlockAccess iblockaccess, int i, int j, int k) { 34 this.c(iblockaccess.getData(i, j, k)); 35 } 36 37 public void c(int i) { 38 float f = 0.1875F; 39 40 this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); 41 if (d(i)) { 42 if ((i & 3) == 0) { 43 this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); 44 } 45 46 if ((i & 3) == 1) { 47 this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); 48 } 49 50 if ((i & 3) == 2) { 51 this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); 52 } 53 54 if ((i & 3) == 3) { 55 this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); 56 } 57 } 58 } 59 60 public void b(World world, int i, int j, int k, EntityHuman entityhuman) { 61 this.interact(world, i, j, k, entityhuman); 62 } 63 64 public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { 65 if (this.material == Material.ORE) { 66 return true; 67 } else { 68 int l = world.getData(i, j, k); 69 70 world.setData(i, j, k, l ^ 4); 71 world.a(entityhuman, 1003, i, j, k, 0); 72 return true; 73 } 74 } 75 76 public void a(World world, int i, int j, int k, boolean flag) { 77 int l = world.getData(i, j, k); 78 boolean flag1 = (l & 4) > 0; 79 80 if (flag1 != flag) { 81 world.setData(i, j, k, l ^ 4); 82 world.a((EntityHuman) null, 1003, i, j, k, 0); 83 } 84 } 85 86 public void doPhysics(World world, int i, int j, int k, int l) { 87 if (!world.isStatic) { 88 int i1 = world.getData(i, j, k); 89 int j1 = i; 90 int k1 = k; 91 92 if ((i1 & 3) == 0) { 93 k1 = k + 1; 94 } 95 96 if ((i1 & 3) == 1) { 97 --k1; 98 } 99 100 if ((i1 & 3) == 2) { 101 j1 = i + 1; 102 } 103 104 if ((i1 & 3) == 3) { 105 --j1; 106 } 107 108 if (!world.e(j1, j, k1)) { 109 world.setTypeId(i, j, k, 0); 110 this.g(world, i, j, k, i1); 111 } 112 113 // CraftBukkit start 114 if (l > 0 && Block.byId[l] != null && Block.byId[l].isPowerSource()) { 115 org.bukkit.World bworld = world.getWorld(); 116 org.bukkit.block.Block block = bworld.getBlockAt(i, j, k); 117 118 int power = block.getBlockPower(); 119 int oldPower = (world.getData(i, j, k) & 4) > 0 ? 15 : 0; 120 121 if (oldPower == 0 ^ power == 0) { 122 BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, oldPower, power); 123 world.getServer().getPluginManager().callEvent(eventRedstone); 124 125 this.a(world, i, j, k, eventRedstone.getNewCurrent() > 0); 126 } 127 // CraftBukkit end 128 } 129 } 130 } 131 132 public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { 133 this.a(world, i, j, k); 134 return super.a(world, i, j, k, vec3d, vec3d1); 135 } 136 137 public void postPlace(World world, int i, int j, int k, int l) { 138 byte b0 = 0; 139 140 if (l == 2) { 141 b0 = 0; 142 } 143 144 if (l == 3) { 145 b0 = 1; 146 } 147 148 if (l == 4) { 149 b0 = 2; 150 } 151 152 if (l == 5) { 153 b0 = 3; 154 } 155 156 world.setData(i, j, k, b0); 157 doPhysics(world, i, j, k, Block.REDSTONE_WIRE.id); // CraftBukkit 158 } 159 160 public boolean canPlace(World world, int i, int j, int k, int l) { 161 if (l == 0) { 162 return false; 163 } else if (l == 1) { 164 return false; 165 } else { 166 if (l == 2) { 167 ++k; 168 } 169 170 if (l == 3) { 171 --k; 172 } 173 174 if (l == 4) { 175 ++i; 176 } 177 178 if (l == 5) { 179 --i; 180 } 181 182 return world.e(i, j, k); 183 } 184 } 185 186 public static boolean d(int i) { 187 return (i & 4) != 0; 188 } 189}