summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorTahg <tahgtahv@gmail.com>2012-01-17 19:37:58 -0500
committerEvilSeph <evilseph@gmail.com>2012-01-24 05:18:23 -0500
commitc7716e1de4eac70725d39994909a23e71b188dab (patch)
tree26d9b87ab8fb04fdca41589bfe1241d303c9692c /src/main/java
parente92bdab57a1bc5a02801fbf1568e746a66678c3a (diff)
downloadcraftbukkit-c7716e1de4eac70725d39994909a23e71b188dab.tar
craftbukkit-c7716e1de4eac70725d39994909a23e71b188dab.tar.gz
craftbukkit-c7716e1de4eac70725d39994909a23e71b188dab.tar.lz
craftbukkit-c7716e1de4eac70725d39994909a23e71b188dab.tar.xz
craftbukkit-c7716e1de4eac70725d39994909a23e71b188dab.zip
[Bleeding] Audit of onPlace methods, Moved to postPlace as appropriate.
Closes BUKKIT-89
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/BlockDiode.java157
-rw-r--r--src/main/java/net/minecraft/server/BlockDragonEgg.java2
-rw-r--r--src/main/java/net/minecraft/server/BlockFluids.java238
-rw-r--r--src/main/java/net/minecraft/server/BlockMinecartTrack.java4
-rw-r--r--src/main/java/net/minecraft/server/BlockPiston.java2
-rw-r--r--src/main/java/net/minecraft/server/BlockPumpkin.java4
-rw-r--r--src/main/java/net/minecraft/server/BlockRedstoneTorch.java5
-rw-r--r--src/main/java/net/minecraft/server/BlockRedstoneWire.java4
-rw-r--r--src/main/java/net/minecraft/server/BlockTNT.java75
-rw-r--r--src/main/java/net/minecraft/server/BlockTorch.java157
-rw-r--r--src/main/java/net/minecraft/server/ItemRedstone.java1
-rw-r--r--src/main/java/net/minecraft/server/TileEntityPiston.java4
12 files changed, 645 insertions, 8 deletions
diff --git a/src/main/java/net/minecraft/server/BlockDiode.java b/src/main/java/net/minecraft/server/BlockDiode.java
new file mode 100644
index 00000000..3ceffb12
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockDiode.java
@@ -0,0 +1,157 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class BlockDiode extends Block {
+
+ public static final double[] a = new double[] { -0.0625D, 0.0625D, 0.1875D, 0.3125D};
+ private static final int[] b = new int[] { 1, 2, 3, 4};
+ private final boolean c;
+
+ protected BlockDiode(int i, boolean flag) {
+ super(i, 6, Material.ORIENTABLE);
+ this.c = flag;
+ this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
+ }
+
+ public boolean b() {
+ return false;
+ }
+
+ public boolean canPlace(World world, int i, int j, int k) {
+ return !world.e(i, j - 1, k) ? false : super.canPlace(world, i, j, k);
+ }
+
+ public boolean f(World world, int i, int j, int k) {
+ return !world.e(i, j - 1, k) ? false : super.f(world, i, j, k);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ int l = world.getData(i, j, k);
+ boolean flag = this.f(world, i, j, k, l);
+
+ if (this.c && !flag) {
+ world.setTypeIdAndData(i, j, k, Block.DIODE_OFF.id, l);
+ } else if (!this.c) {
+ world.setTypeIdAndData(i, j, k, Block.DIODE_ON.id, l);
+ if (!flag) {
+ int i1 = (l & 12) >> 2;
+
+ world.c(i, j, k, Block.DIODE_ON.id, b[i1] * 2);
+ }
+ }
+ }
+
+ public int a(int i, int j) {
+ return i == 0 ? (this.c ? 99 : 115) : (i == 1 ? (this.c ? 147 : 131) : 5);
+ }
+
+ public int c() {
+ return 15;
+ }
+
+ public int a(int i) {
+ return this.a(i, 0);
+ }
+
+ public boolean d(World world, int i, int j, int k, int l) {
+ return this.a(world, i, j, k, l);
+ }
+
+ public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) {
+ if (!this.c) {
+ return false;
+ } else {
+ int i1 = iblockaccess.getData(i, j, k) & 3;
+
+ return i1 == 0 && l == 3 ? true : (i1 == 1 && l == 4 ? true : (i1 == 2 && l == 2 ? true : i1 == 3 && l == 5));
+ }
+ }
+
+ public void doPhysics(World world, int i, int j, int k, int l) {
+ if (!this.f(world, i, j, k)) {
+ this.b(world, i, j, k, world.getData(i, j, k), 0);
+ world.setTypeId(i, j, k, 0);
+ } else {
+ int i1 = world.getData(i, j, k);
+ boolean flag = this.f(world, i, j, k, i1);
+ int j1 = (i1 & 12) >> 2;
+
+ if (this.c && !flag) {
+ world.c(i, j, k, this.id, b[j1] * 2);
+ } else if (!this.c && flag) {
+ world.c(i, j, k, this.id, b[j1] * 2);
+ }
+ }
+ }
+
+ private boolean f(World world, int i, int j, int k, int l) {
+ int i1 = l & 3;
+
+ switch (i1) {
+ case 0:
+ return world.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) || world.getTypeId(i, j, k + 1) == Block.REDSTONE_WIRE.id && world.getData(i, j, k + 1) > 0;
+
+ case 1:
+ return world.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) || world.getTypeId(i - 1, j, k) == Block.REDSTONE_WIRE.id && world.getData(i - 1, j, k) > 0;
+
+ case 2:
+ return world.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) || world.getTypeId(i, j, k - 1) == Block.REDSTONE_WIRE.id && world.getData(i, j, k - 1) > 0;
+
+ case 3:
+ return world.isBlockFaceIndirectlyPowered(i + 1, j, k, 5) || world.getTypeId(i + 1, j, k) == Block.REDSTONE_WIRE.id && world.getData(i + 1, j, k) > 0;
+
+ default:
+ return false;
+ }
+ }
+
+ public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
+ int l = world.getData(i, j, k);
+ int i1 = (l & 12) >> 2;
+
+ i1 = i1 + 1 << 2 & 12;
+ world.setData(i, j, k, i1 | l & 3);
+ return true;
+ }
+
+ public boolean isPowerSource() {
+ return true;
+ }
+
+ public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
+ int l = ((MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4;
+
+ world.setData(i, j, k, l);
+ boolean flag = this.f(world, i, j, k, l);
+
+ if (flag) {
+ world.c(i, j, k, this.id, 1);
+ }
+ }
+
+ public void postPlace(World world, int i, int j, int k, int l) { // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
+ world.applyPhysics(i + 1, j, k, this.id);
+ world.applyPhysics(i - 1, j, k, this.id);
+ world.applyPhysics(i, j, k + 1, this.id);
+ world.applyPhysics(i, j, k - 1, this.id);
+ world.applyPhysics(i, j - 1, k, this.id);
+ world.applyPhysics(i, j + 1, k, this.id);
+ }
+
+ public void postBreak(World world, int i, int j, int k, int l) {
+ if (this.c) {
+ world.applyPhysics(i, j + 1, k, this.id);
+ }
+
+ super.postBreak(world, i, j, k, l);
+ }
+
+ public boolean a() {
+ return false;
+ }
+
+ public int getDropType(int i, Random random, int j) {
+ return Item.DIODE.id;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockDragonEgg.java b/src/main/java/net/minecraft/server/BlockDragonEgg.java
index 9d7988fa..4c1fc419 100644
--- a/src/main/java/net/minecraft/server/BlockDragonEgg.java
+++ b/src/main/java/net/minecraft/server/BlockDragonEgg.java
@@ -8,7 +8,7 @@ public class BlockDragonEgg extends Block {
super(i, j, Material.DRAGON_EGG);
}
- public void onPlace(World world, int i, int j, int k) {
+ public void postPlace(World world, int i, int j, int k, int l) { // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
world.c(i, j, k, this.id, this.d());
}
diff --git a/src/main/java/net/minecraft/server/BlockFluids.java b/src/main/java/net/minecraft/server/BlockFluids.java
new file mode 100644
index 00000000..e3ff4712
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockFluids.java
@@ -0,0 +1,238 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public abstract class BlockFluids extends Block {
+
+ protected BlockFluids(int i, Material material) {
+ super(i, (material == Material.LAVA ? 14 : 12) * 16 + 13, material);
+ float f = 0.0F;
+ float f1 = 0.0F;
+
+ this.a(0.0F + f1, 0.0F + f, 0.0F + f1, 1.0F + f1, 1.0F + f, 1.0F + f1);
+ this.a(true);
+ }
+
+ public static float d(int i) {
+ if (i >= 8) {
+ i = 0;
+ }
+
+ float f = (float) (i + 1) / 9.0F;
+
+ return f;
+ }
+
+ public int a(int i) {
+ return i != 0 && i != 1 ? this.textureId + 1 : this.textureId;
+ }
+
+ protected int g(World world, int i, int j, int k) {
+ return world.getMaterial(i, j, k) != this.material ? -1 : world.getData(i, j, k);
+ }
+
+ protected int b(IBlockAccess iblockaccess, int i, int j, int k) {
+ if (iblockaccess.getMaterial(i, j, k) != this.material) {
+ return -1;
+ } else {
+ int l = iblockaccess.getData(i, j, k);
+
+ if (l >= 8) {
+ l = 0;
+ }
+
+ return l;
+ }
+ }
+
+ public boolean b() {
+ return false;
+ }
+
+ public boolean a() {
+ return false;
+ }
+
+ public boolean a(int i, boolean flag) {
+ return flag && i == 0;
+ }
+
+ public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
+ Material material = iblockaccess.getMaterial(i, j, k);
+
+ return material == this.material ? false : (l == 1 ? true : (material == Material.ICE ? false : super.b(iblockaccess, i, j, k, l)));
+ }
+
+ public AxisAlignedBB e(World world, int i, int j, int k) {
+ return null;
+ }
+
+ public int c() {
+ return 4;
+ }
+
+ public int getDropType(int i, Random random, int j) {
+ return 0;
+ }
+
+ public int a(Random random) {
+ return 0;
+ }
+
+ private Vec3D c(IBlockAccess iblockaccess, int i, int j, int k) {
+ Vec3D vec3d = Vec3D.create(0.0D, 0.0D, 0.0D);
+ int l = this.b(iblockaccess, i, j, k);
+
+ for (int i1 = 0; i1 < 4; ++i1) {
+ int j1 = i;
+ int k1 = k;
+
+ if (i1 == 0) {
+ j1 = i - 1;
+ }
+
+ if (i1 == 1) {
+ k1 = k - 1;
+ }
+
+ if (i1 == 2) {
+ ++j1;
+ }
+
+ if (i1 == 3) {
+ ++k1;
+ }
+
+ int l1 = this.b(iblockaccess, j1, j, k1);
+ int i2;
+
+ if (l1 < 0) {
+ if (!iblockaccess.getMaterial(j1, j, k1).isSolid()) {
+ l1 = this.b(iblockaccess, j1, j - 1, k1);
+ if (l1 >= 0) {
+ i2 = l1 - (l - 8);
+ vec3d = vec3d.add((double) ((j1 - i) * i2), (double) ((j - j) * i2), (double) ((k1 - k) * i2));
+ }
+ }
+ } else if (l1 >= 0) {
+ i2 = l1 - l;
+ vec3d = vec3d.add((double) ((j1 - i) * i2), (double) ((j - j) * i2), (double) ((k1 - k) * i2));
+ }
+ }
+
+ if (iblockaccess.getData(i, j, k) >= 8) {
+ boolean flag = false;
+
+ if (flag || this.b(iblockaccess, i, j, k - 1, 2)) {
+ flag = true;
+ }
+
+ if (flag || this.b(iblockaccess, i, j, k + 1, 3)) {
+ flag = true;
+ }
+
+ if (flag || this.b(iblockaccess, i - 1, j, k, 4)) {
+ flag = true;
+ }
+
+ if (flag || this.b(iblockaccess, i + 1, j, k, 5)) {
+ flag = true;
+ }
+
+ if (flag || this.b(iblockaccess, i, j + 1, k - 1, 2)) {
+ flag = true;
+ }
+
+ if (flag || this.b(iblockaccess, i, j + 1, k + 1, 3)) {
+ flag = true;
+ }
+
+ if (flag || this.b(iblockaccess, i - 1, j + 1, k, 4)) {
+ flag = true;
+ }
+
+ if (flag || this.b(iblockaccess, i + 1, j + 1, k, 5)) {
+ flag = true;
+ }
+
+ if (flag) {
+ vec3d = vec3d.b().add(0.0D, -6.0D, 0.0D);
+ }
+ }
+
+ vec3d = vec3d.b();
+ return vec3d;
+ }
+
+ public void a(World world, int i, int j, int k, Entity entity, Vec3D vec3d) {
+ Vec3D vec3d1 = this.c(world, i, j, k);
+
+ vec3d.a += vec3d1.a;
+ vec3d.b += vec3d1.b;
+ vec3d.c += vec3d1.c;
+ }
+
+ public int d() {
+ return this.material == Material.WATER ? 5 : (this.material == Material.LAVA ? 30 : 0);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ super.a(world, i, j, k, random);
+ }
+
+ public void postPlace(World world, int i, int j, int k, int l) { // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
+ this.i(world, i, j, k);
+ }
+
+ public void doPhysics(World world, int i, int j, int k, int l) {
+ this.i(world, i, j, k);
+ }
+
+ private void i(World world, int i, int j, int k) {
+ if (world.getTypeId(i, j, k) == this.id) {
+ if (this.material == Material.LAVA) {
+ boolean flag = false;
+
+ if (flag || world.getMaterial(i, j, k - 1) == Material.WATER) {
+ flag = true;
+ }
+
+ if (flag || world.getMaterial(i, j, k + 1) == Material.WATER) {
+ flag = true;
+ }
+
+ if (flag || world.getMaterial(i - 1, j, k) == Material.WATER) {
+ flag = true;
+ }
+
+ if (flag || world.getMaterial(i + 1, j, k) == Material.WATER) {
+ flag = true;
+ }
+
+ if (flag || world.getMaterial(i, j + 1, k) == Material.WATER) {
+ flag = true;
+ }
+
+ if (flag) {
+ int l = world.getData(i, j, k);
+
+ if (l == 0) {
+ world.setTypeId(i, j, k, Block.OBSIDIAN.id);
+ } else if (l <= 4) {
+ world.setTypeId(i, j, k, Block.COBBLESTONE.id);
+ }
+
+ this.fizz(world, i, j, k);
+ }
+ }
+ }
+ }
+
+ protected void fizz(World world, int i, int j, int k) {
+ world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
+
+ for (int l = 0; l < 8; ++l) {
+ world.a("largesmoke", (double) i + Math.random(), (double) j + 1.2D, (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockMinecartTrack.java b/src/main/java/net/minecraft/server/BlockMinecartTrack.java
index 335d6a8c..5ce6cb99 100644
--- a/src/main/java/net/minecraft/server/BlockMinecartTrack.java
+++ b/src/main/java/net/minecraft/server/BlockMinecartTrack.java
@@ -77,11 +77,11 @@ public class BlockMinecartTrack extends Block {
return world.e(i, j - 1, k);
}
- public void onPlace(World world, int i, int j, int k) {
+ public void postPlace(World world, int i, int j, int k, int l) { // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
if (!world.isStatic) {
this.a(world, i, j, k, true);
if (this.id == Block.GOLDEN_RAIL.id) {
- //this.doPhysics(world, i, j, k, this.id); // CraftBukkit - Fix dupe with pistons
+ this.doPhysics(world, i, j, k, this.id); // CraftBukkit - Fix dupe with pistons
}
}
}
diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
index e3e42824..17ba1e6f 100644
--- a/src/main/java/net/minecraft/server/BlockPiston.java
+++ b/src/main/java/net/minecraft/server/BlockPiston.java
@@ -53,7 +53,7 @@ public class BlockPiston extends Block {
}
}
- public void onPlace(World world, int i, int j, int k) {
+ public void postPlace(World world, int i, int j, int k, int l) { // CraftBukkit
if (!world.isStatic && world.getTileEntity(i, j, k) == null && !b) {
this.g(world, i, j, k);
}
diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java
index 8babb968..eee735d1 100644
--- a/src/main/java/net/minecraft/server/BlockPumpkin.java
+++ b/src/main/java/net/minecraft/server/BlockPumpkin.java
@@ -33,8 +33,8 @@ public class BlockPumpkin extends Block {
return i == 1 ? this.textureId : (i == 0 ? this.textureId : (i == 3 ? this.textureId + 1 + 16 : this.textureId + 16));
}
- public void onPlace(World world, int i, int j, int k) {
- super.onPlace(world, i, j, k);
+ public void postPlace(World world, int i, int j, int k, int m) { // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
+ super.postPlace(world, i, j, k, m); // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
if (world.getTypeId(i, j - 1, k) == Block.SNOW_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.SNOW_BLOCK.id) {
if (!world.isStatic && world.getServer().getServer().spawnAnimals) { // CraftBukkit - make snowmen obey spawning rules
world.setTypeId(i, j, k, 0);
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
index e9986db9..58e26f19 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
@@ -50,7 +50,12 @@ public class BlockRedstoneTorch extends BlockTorch {
if (world.getData(i, j, k) == 0) {
super.onPlace(world, i, j, k);
}
+ // CraftBukkit start - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
+ }
+ public void postPlace(World world, int i, int j, int k, int l) {
+ super.postPlace(world, i, j, k, l);
+ // CraftBukkit end
if (this.isOn) {
world.applyPhysics(i, j - 1, k, this.id);
world.applyPhysics(i, j + 1, k, this.id);
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
index 07226d18..31145615 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
@@ -195,8 +195,8 @@ public class BlockRedstoneWire extends Block {
}
}
- public void onPlace(World world, int i, int j, int k) {
- super.onPlace(world, i, j, k);
+ public void postPlace(World world, int i, int j, int k, int l) { // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
+ super.postPlace(world, i, j, k, l); // CraftBukkit - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
if (!world.isStatic) {
this.g(world, i, j, k);
world.applyPhysics(i, j + 1, k, this.id);
diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java
new file mode 100644
index 00000000..c4ddec8b
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
@@ -0,0 +1,75 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class BlockTNT extends Block {
+
+ public BlockTNT(int i, int j) {
+ super(i, j, Material.TNT);
+ }
+
+ public int a(int i) {
+ return i == 0 ? this.textureId + 2 : (i == 1 ? this.textureId + 1 : this.textureId);
+ }
+
+ public void onPlace(World world, int i, int j, int k) {
+ super.onPlace(world, i, j, k);
+ // CraftBukkit start - onPlace(World, int, int, int) -> postPlace(World, int, int, int, int)
+ }
+
+ public void postPlace(World world, int i, int j, int k, int l) {
+ super.postPlace(world, i, j, k, l);
+ // CraftBukkit end
+ if (world.isBlockIndirectlyPowered(i, j, k)) {
+ this.postBreak(world, i, j, k, 1);
+ world.setTypeId(i, j, k, 0);
+ }
+ }
+
+ public void doPhysics(World world, int i, int j, int k, int l) {
+ if (l > 0 && Block.byId[l].isPowerSource() && world.isBlockIndirectlyPowered(i, j, k)) {
+ this.postBreak(world, i, j, k, 1);
+ world.setTypeId(i, j, k, 0);
+ }
+ }
+
+ public int a(Random random) {
+ return 0;
+ }
+
+ public void wasExploded(World world, int i, int j, int k) {
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
+
+ entitytntprimed.fuseTicks = world.random.nextInt(entitytntprimed.fuseTicks / 4) + entitytntprimed.fuseTicks / 8;
+ world.addEntity(entitytntprimed);
+ }
+
+ public void postBreak(World world, int i, int j, int k, int l) {
+ if (!world.isStatic) {
+ if ((l & 1) == 0) {
+ this.a(world, i, j, k, new ItemStack(Block.TNT.id, 1, 0));
+ } else {
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F));
+
+ world.addEntity(entitytntprimed);
+ world.makeSound(entitytntprimed, "random.fuse", 1.0F, 1.0F);
+ }
+ }
+ }
+
+ public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {
+ if (entityhuman.Q() != null && entityhuman.Q().id == Item.FLINT_AND_STEEL.id) {
+ world.setRawData(i, j, k, 1);
+ }
+
+ super.attack(world, i, j, k, entityhuman);
+ }
+
+ public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
+ return super.interact(world, i, j, k, entityhuman);
+ }
+
+ protected ItemStack a_(int i) {
+ return null;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockTorch.java b/src/main/java/net/minecraft/server/BlockTorch.java
new file mode 100644
index 00000000..d179824e
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockTorch.java
@@ -0,0 +1,157 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class BlockTorch extends Block {
+
+ protected BlockTorch(int i, int j) {
+ super(i, j, Material.ORIENTABLE);
+ this.a(true);
+ }
+
+ public AxisAlignedBB e(World world, int i, int j, int k) {
+ return null;
+ }
+
+ public boolean a() {
+ return false;
+ }
+
+ public boolean b() {
+ return false;
+ }
+
+ public int c() {
+ return 2;
+ }
+
+ private boolean g(World world, int i, int j, int k) {
+ if (world.b(i, j, k, true)) {
+ return true;
+ } else {
+ int l = world.getTypeId(i, j, k);
+
+ return l == Block.FENCE.id || l == Block.NETHER_FENCE.id;
+ }
+ }
+
+ public boolean canPlace(World world, int i, int j, int k) {
+ return world.b(i - 1, j, k, true) ? true : (world.b(i + 1, j, k, true) ? true : (world.b(i, j, k - 1, true) ? true : (world.b(i, j, k + 1, true) ? true : this.g(world, i, j - 1, k))));
+ }
+
+ public void postPlace(World world, int i, int j, int k, int l) {
+ int i1 = world.getData(i, j, k);
+
+ if (l == 1 && this.g(world, i, j - 1, k)) {
+ i1 = 5;
+ }
+
+ if (l == 2 && world.b(i, j, k + 1, true)) {
+ i1 = 4;
+ }
+
+ if (l == 3 && world.b(i, j, k - 1, true)) {
+ i1 = 3;
+ }
+
+ if (l == 4 && world.b(i + 1, j, k, true)) {
+ i1 = 2;
+ }
+
+ if (l == 5 && world.b(i - 1, j, k, true)) {
+ i1 = 1;
+ }
+
+ world.setData(i, j, k, i1);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ super.a(world, i, j, k, random);
+ if (world.getData(i, j, k) == 0) {
+ this.onPlace(world, i, j, k);
+ }
+ }
+
+ public void onPlace(World world, int i, int j, int k) {
+ /* // CraftBukkit start - we do this, correctly, in postPlace
+ if (world.b(i - 1, j, k, true)) {
+ world.setData(i, j, k, 1);
+ } else if (world.b(i + 1, j, k, true)) {
+ world.setData(i, j, k, 2);
+ } else if (world.b(i, j, k - 1, true)) {
+ world.setData(i, j, k, 3);
+ } else if (world.b(i, j, k + 1, true)) {
+ world.setData(i, j, k, 4);
+ } else if (this.g(world, i, j - 1, k)) {
+ world.setData(i, j, k, 5);
+ }
+
+ this.h(world, i, j, k);
+ */ // CraftBukkit end
+ }
+
+ public void doPhysics(World world, int i, int j, int k, int l) {
+ if (this.h(world, i, j, k)) {
+ int i1 = world.getData(i, j, k);
+ boolean flag = false;
+
+ if (!world.b(i - 1, j, k, true) && i1 == 1) {
+ flag = true;
+ }
+
+ if (!world.b(i + 1, j, k, true) && i1 == 2) {
+ flag = true;
+ }
+
+ if (!world.b(i, j, k - 1, true) && i1 == 3) {
+ flag = true;
+ }
+
+ if (!world.b(i, j, k + 1, true) && i1 == 4) {
+ flag = true;
+ }
+
+ if (!this.g(world, i, j - 1, k) && i1 == 5) {
+ flag = true;
+ }
+
+ if (flag) {
+ this.b(world, i, j, k, world.getData(i, j, k), 0);
+ world.setTypeId(i, j, k, 0);
+ }
+ }
+ }
+
+ private boolean h(World world, int i, int j, int k) {
+ if (!this.canPlace(world, i, j, k)) {
+ if (world.getTypeId(i, j, k) == this.id) {
+ this.b(world, i, j, k, world.getData(i, j, k), 0);
+ world.setTypeId(i, j, k, 0);
+ }
+
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
+ int l = world.getData(i, j, k) & 7;
+ float f = 0.15F;
+
+ if (l == 1) {
+ this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
+ } else if (l == 2) {
+ this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
+ } else if (l == 3) {
+ this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
+ } else if (l == 4) {
+ this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
+ } else {
+ f = 0.1F;
+ this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
+ }
+
+ return super.a(world, i, j, k, vec3d, vec3d1);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java
index 69b70561..4daeedc2 100644
--- a/src/main/java/net/minecraft/server/ItemRedstone.java
+++ b/src/main/java/net/minecraft/server/ItemRedstone.java
@@ -61,6 +61,7 @@ public class ItemRedstone extends Item {
return false;
}
+ Block.REDSTONE_WIRE.postPlace( world, i, j, k, Block.REDSTONE_WIRE.id); // Call postPlace since it is now used.
world.update(i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks.
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java
index ffc3286b..fed3a6aa 100644
--- a/src/main/java/net/minecraft/server/TileEntityPiston.java
+++ b/src/main/java/net/minecraft/server/TileEntityPiston.java
@@ -83,6 +83,8 @@ public class TileEntityPiston extends TileEntity {
this.i();
if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
+ Block block = Block.byId[this.world.getTypeId(this.x, this.y, this.z)];
+ if (block != null) block.postPlace(this.world, this.x, this.y, this.z, 0);
}
}
}
@@ -97,6 +99,8 @@ public class TileEntityPiston extends TileEntity {
this.i();
if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) {
this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b);
+ Block block = Block.byId[this.world.getTypeId(this.x, this.y, this.z)];
+ if (block != null) block.postPlace(this.world, this.x, this.y, this.z, 0);
}
} else {
this.f += 0.5F;