Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 150 lines 4.5 kB view raw
1package net.minecraft.server; 2 3import com.legacyminecraft.poseidon.PoseidonConfig; 4 5import java.util.Random; 6 7import uk.betacraft.uberbukkit.UberbukkitConfig; 8 9public class BlockTorch extends Block { 10 11 protected BlockTorch(int i, int j) { 12 super(i, j, Material.ORIENTABLE); 13 this.a(true); 14 } 15 16 public AxisAlignedBB e(World world, int i, int j, int k) { 17 return null; 18 } 19 20 public boolean a() { 21 return false; 22 } 23 24 public boolean b() { 25 return false; 26 } 27 28 private boolean g(World world, int i, int j, int k) { 29 return world.e(i, j, k) || 30 // uberbukkit 31 (UberbukkitConfig.getInstance().getBoolean("mechanics.allow_1_7_fence_placement", true) && world.getTypeId(i, j, k) == Block.FENCE.id); 32 } 33 34 public boolean canPlace(World world, int i, int j, int k) { 35 return world.e(i - 1, j, k) ? true : (world.e(i + 1, j, k) ? true : (world.e(i, j, k - 1) ? true : (world.e(i, j, k + 1) ? true : this.g(world, i, j - 1, k)))); 36 } 37 38 public void postPlace(World world, int i, int j, int k, int l) { 39 if (PoseidonConfig.getInstance().getConfigBoolean("world.settings.pistons.transmutation-fix.enabled", true) && world.getTypeId(i, j, k) != this.id) 40 return; 41 int i1 = world.getData(i, j, k); 42 43 if (l == 1 && this.g(world, i, j - 1, k)) { 44 i1 = 5; 45 } 46 47 if (l == 2 && world.e(i, j, k + 1)) { 48 i1 = 4; 49 } 50 51 if (l == 3 && world.e(i, j, k - 1)) { 52 i1 = 3; 53 } 54 55 if (l == 4 && world.e(i + 1, j, k)) { 56 i1 = 2; 57 } 58 59 if (l == 5 && world.e(i - 1, j, k)) { 60 i1 = 1; 61 } 62 63 world.setData(i, j, k, i1); 64 } 65 66 public void a(World world, int i, int j, int k, Random random) { 67 super.a(world, i, j, k, random); 68 if (world.getData(i, j, k) == 0) { 69 this.c(world, i, j, k); 70 } 71 } 72 73 public void c(World world, int i, int j, int k) { 74 if (world.e(i - 1, j, k)) { 75 world.setData(i, j, k, 1); 76 } else if (world.e(i + 1, j, k)) { 77 world.setData(i, j, k, 2); 78 } else if (world.e(i, j, k - 1)) { 79 world.setData(i, j, k, 3); 80 } else if (world.e(i, j, k + 1)) { 81 world.setData(i, j, k, 4); 82 } else if (this.g(world, i, j - 1, k)) { 83 world.setData(i, j, k, 5); 84 } 85 86 this.h(world, i, j, k); 87 } 88 89 public void doPhysics(World world, int i, int j, int k, int l) { 90 if (this.h(world, i, j, k)) { 91 int i1 = world.getData(i, j, k); 92 boolean flag = false; 93 94 if (!world.e(i - 1, j, k) && i1 == 1) { 95 flag = true; 96 } 97 98 if (!world.e(i + 1, j, k) && i1 == 2) { 99 flag = true; 100 } 101 102 if (!world.e(i, j, k - 1) && i1 == 3) { 103 flag = true; 104 } 105 106 if (!world.e(i, j, k + 1) && i1 == 4) { 107 flag = true; 108 } 109 110 if (!this.g(world, i, j - 1, k) && i1 == 5) { 111 flag = true; 112 } 113 114 if (flag) { 115 this.g(world, i, j, k, world.getData(i, j, k)); 116 world.setTypeId(i, j, k, 0); 117 } 118 } 119 } 120 121 private boolean h(World world, int i, int j, int k) { 122 if (!this.canPlace(world, i, j, k) && (!PoseidonConfig.getInstance().getConfigBoolean("world.settings.pistons.other-fixes.enabled") || world.getTypeId(i, j, k) == this.id)) { 123 this.g(world, i, j, k, world.getData(i, j, k)); 124 world.setTypeId(i, j, k, 0); 125 return false; 126 } else { 127 return true; 128 } 129 } 130 131 public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { 132 int l = world.getData(i, j, k) & 7; 133 float f = 0.15F; 134 135 if (l == 1) { 136 this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); 137 } else if (l == 2) { 138 this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); 139 } else if (l == 3) { 140 this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); 141 } else if (l == 4) { 142 this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); 143 } else { 144 f = 0.1F; 145 this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); 146 } 147 148 return super.a(world, i, j, k, vec3d, vec3d1); 149 } 150}