2011-01-10 22:07:56 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
import java.util.Random;
|
|
|
|
|
2013-03-17 21:46:48 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
2011-01-10 22:07:56 +01:00
|
|
|
|
|
|
|
public class BlockStationary extends BlockFluids {
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
protected BlockStationary(int i, Material material) {
|
|
|
|
super(i, material);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(false);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (material == Material.LAVA) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(true);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
|
2012-03-01 11:49:23 +01:00
|
|
|
return this.material != Material.LAVA;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
|
|
|
super.doPhysics(world, i, j, k, l);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (world.getTypeId(i, j, k) == this.id) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.k(world, i, j, k);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
private void k(World world, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
int l = world.getData(i, j, k);
|
2011-01-10 22:07:56 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setTypeIdAndData(i, j, k, this.id - 1, l, 2);
|
|
|
|
world.a(i, j, k, this.id - 1, this.a(world));
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.material == Material.LAVA) {
|
|
|
|
int l = random.nextInt(3);
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
int i1;
|
|
|
|
int j1;
|
|
|
|
|
2013-03-17 21:46:48 +01:00
|
|
|
// CraftBukkit start - prevent lava putting something on fire, remember igniter block coords
|
|
|
|
int x = i;
|
|
|
|
int y = j;
|
|
|
|
int z = k;
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
for (i1 = 0; i1 < l; ++i1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
i += random.nextInt(3) - 1;
|
|
|
|
++j;
|
2011-01-14 14:31:10 +01:00
|
|
|
k += random.nextInt(3) - 1;
|
2012-03-01 11:49:23 +01:00
|
|
|
j1 = world.getTypeId(i, j, k);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (j1 == 0) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.m(world, i - 1, j, k) || this.m(world, i + 1, j, k) || this.m(world, i, j, k - 1) || this.m(world, i, j, k + 1) || this.m(world, i, j - 1, k) || this.m(world, i, j + 1, k)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start - prevent lava putting something on fire
|
2013-03-17 21:46:48 +01:00
|
|
|
if (world.getTypeId(i, j, k) != Block.FIRE.id) {
|
|
|
|
if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, x, y, z).isCancelled()) {
|
2011-01-18 22:44:01 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setTypeIdUpdate(i, j, k, Block.FIRE.id);
|
2011-01-10 22:07:56 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (Block.byId[j1].material.isSolid()) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return;
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
|
|
|
if (l == 0) {
|
|
|
|
i1 = i;
|
|
|
|
j1 = k;
|
|
|
|
|
|
|
|
for (int k1 = 0; k1 < 3; ++k1) {
|
|
|
|
i = i1 + random.nextInt(3) - 1;
|
|
|
|
k = j1 + random.nextInt(3) - 1;
|
2013-03-13 23:33:27 +01:00
|
|
|
if (world.isEmpty(i, j + 1, k) && this.m(world, i, j, k)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start - prevent lava putting something on fire
|
2013-03-17 21:46:48 +01:00
|
|
|
if (world.getTypeId(i, j + 1, k) != Block.FIRE.id) {
|
|
|
|
if (CraftEventFactory.callBlockIgniteEvent(world, i, j + 1, k, x, y, z).isCancelled()) {
|
2012-03-11 06:56:55 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setTypeIdUpdate(i, j + 1, k, Block.FIRE.id);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
private boolean m(World world, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return world.getMaterial(i, j, k).isBurnable();
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|