2011-01-10 22:07:56 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
import java.util.Random;
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
import org.bukkit.event.block.BlockIgniteEvent; // 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);
|
|
|
|
this.a(false);
|
|
|
|
if (material == Material.LAVA) {
|
|
|
|
this.a(true);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
this.i(world, i, j, k);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private void i(World world, int i, int j, int k) {
|
|
|
|
int l = world.getData(i, j, k);
|
2011-01-10 22:07:56 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
world.suppressPhysics = true;
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setRawTypeIdAndData(i, j, k, this.id - 1, l);
|
2011-01-29 22:50:29 +01:00
|
|
|
world.b(i, j, k, i, j, k);
|
2011-05-26 14:48:22 +02:00
|
|
|
world.c(i, j, k, this.id - 1, this.c());
|
2011-06-27 00:25:01 +02:00
|
|
|
world.suppressPhysics = false;
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
|
|
|
if (this.material == Material.LAVA) {
|
|
|
|
int l = random.nextInt(3);
|
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start - prevent lava putting something on fire.
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.World bworld = world.getWorld();
|
|
|
|
BlockIgniteEvent.IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
for (int i1 = 0; i1 < l; ++i1) {
|
|
|
|
i += random.nextInt(3) - 1;
|
|
|
|
++j;
|
2011-01-14 14:31:10 +01:00
|
|
|
k += random.nextInt(3) - 1;
|
2011-01-29 22:50:29 +01:00
|
|
|
int j1 = world.getTypeId(i, j, k);
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (j1 == 0) {
|
|
|
|
if (this.j(world, i - 1, j, k) || this.j(world, i + 1, j, k) || this.j(world, i, j, k - 1) || this.j(world, i, j, k + 1) || this.j(world, i, j - 1, k) || this.j(world, i, j + 1, k)) {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start - prevent lava putting something on fire.
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.block.Block block = bworld.getBlockAt(i, j, k);
|
|
|
|
|
|
|
|
if (block.getTypeId() != Block.FIRE.id) {
|
|
|
|
BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null);
|
|
|
|
world.getServer().getPluginManager().callEvent(event);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-01-18 22:44:01 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setTypeId(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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private boolean j(World world, int i, int j, int k) {
|
|
|
|
return world.getMaterial(i, j, k).isBurnable();
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|