Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 155 lines 5.1 kB view raw
1package net.minecraft.server; 2 3import java.util.ArrayList; 4import java.util.Random; 5 6public class BlockPistonExtension extends Block { 7 8 private int a = -1; 9 10 public BlockPistonExtension(int i, int j) { 11 super(i, j, Material.PISTON); 12 this.a(h); 13 this.c(0.5F); 14 } 15 16 public void remove(World world, int i, int j, int k) { 17 super.remove(world, i, j, k); 18 int l = world.getData(i, j, k); 19 if (l < 0 || l == 6 || l == 7 || l > 13) return; // CraftBukkit - fixed a piston AIOOBE issue. 20 int i1 = PistonBlockTextures.a[b(l)]; 21 22 i += PistonBlockTextures.b[i1]; 23 j += PistonBlockTextures.c[i1]; 24 k += PistonBlockTextures.d[i1]; 25 int j1 = world.getTypeId(i, j, k); 26 27 if (j1 == Block.PISTON.id || j1 == Block.PISTON_STICKY.id) { 28 l = world.getData(i, j, k); 29 if (BlockPiston.d(l)) { 30 Block.byId[j1].g(world, i, j, k, l); 31 world.setTypeId(i, j, k, 0); 32 } 33 } 34 } 35 36 public int a(int i, int j) { 37 int k = b(j); 38 39 return i == k ? (this.a >= 0 ? this.a : ((j & 8) != 0 ? this.textureId - 1 : this.textureId)) : (i == PistonBlockTextures.a[k] ? 107 : 108); 40 } 41 42 public boolean a() { 43 return false; 44 } 45 46 public boolean b() { 47 return false; 48 } 49 50 public boolean canPlace(World world, int i, int j, int k) { 51 return false; 52 } 53 54 public boolean canPlace(World world, int i, int j, int k, int l) { 55 return false; 56 } 57 58 public int a(Random random) { 59 return 0; 60 } 61 62 public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) { 63 int l = world.getData(i, j, k); 64 65 switch (b(l)) { 66 case 0: 67 this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); 68 super.a(world, i, j, k, axisalignedbb, arraylist); 69 this.a(0.375F, 0.25F, 0.375F, 0.625F, 1.0F, 0.625F); 70 super.a(world, i, j, k, axisalignedbb, arraylist); 71 break; 72 73 case 1: 74 this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); 75 super.a(world, i, j, k, axisalignedbb, arraylist); 76 this.a(0.375F, 0.0F, 0.375F, 0.625F, 0.75F, 0.625F); 77 super.a(world, i, j, k, axisalignedbb, arraylist); 78 break; 79 80 case 2: 81 this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F); 82 super.a(world, i, j, k, axisalignedbb, arraylist); 83 this.a(0.25F, 0.375F, 0.25F, 0.75F, 0.625F, 1.0F); 84 super.a(world, i, j, k, axisalignedbb, arraylist); 85 break; 86 87 case 3: 88 this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F); 89 super.a(world, i, j, k, axisalignedbb, arraylist); 90 this.a(0.25F, 0.375F, 0.0F, 0.75F, 0.625F, 0.75F); 91 super.a(world, i, j, k, axisalignedbb, arraylist); 92 break; 93 94 case 4: 95 this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F); 96 super.a(world, i, j, k, axisalignedbb, arraylist); 97 this.a(0.375F, 0.25F, 0.25F, 0.625F, 0.75F, 1.0F); 98 super.a(world, i, j, k, axisalignedbb, arraylist); 99 break; 100 101 case 5: 102 this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); 103 super.a(world, i, j, k, axisalignedbb, arraylist); 104 this.a(0.0F, 0.375F, 0.25F, 0.75F, 0.625F, 0.75F); 105 super.a(world, i, j, k, axisalignedbb, arraylist); 106 } 107 108 this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); 109 } 110 111 public void a(IBlockAccess iblockaccess, int i, int j, int k) { 112 int l = iblockaccess.getData(i, j, k); 113 114 switch (b(l)) { 115 case 0: 116 this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); 117 break; 118 119 case 1: 120 this.a(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); 121 break; 122 123 case 2: 124 this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F); 125 break; 126 127 case 3: 128 this.a(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F); 129 break; 130 131 case 4: 132 this.a(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F); 133 break; 134 135 case 5: 136 this.a(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); 137 } 138 } 139 140 public void doPhysics(World world, int i, int j, int k, int l) { 141 int i1 = b(world.getData(i, j, k)); 142 if (i1 > 5 || i1 < 0) return; // CraftBukkit - fixed a piston AIOOBE issue. 143 int j1 = world.getTypeId(i - PistonBlockTextures.b[i1], j - PistonBlockTextures.c[i1], k - PistonBlockTextures.d[i1]); 144 145 if (j1 != Block.PISTON.id && j1 != Block.PISTON_STICKY.id) { 146 world.setTypeId(i, j, k, 0); 147 } else { 148 Block.byId[j1].doPhysics(world, i - PistonBlockTextures.b[i1], j - PistonBlockTextures.c[i1], k - PistonBlockTextures.d[i1], l); 149 } 150 } 151 152 public static int b(int i) { 153 return i & 7; 154 } 155}