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-01-18 22:44:01 +01:00
|
|
|
// CraftBukkit start
|
2011-01-10 22:07:56 +01:00
|
|
|
import org.bukkit.event.block.BlockIgniteEvent;
|
2011-01-18 08:43:39 +01:00
|
|
|
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
2011-01-26 22:13:27 +01:00
|
|
|
import org.bukkit.event.block.BlockBurnEvent;
|
2011-01-18 22:44:01 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 22:07:56 +01:00
|
|
|
|
|
|
|
public class BlockFire extends Block {
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private int[] a = new int[256];
|
|
|
|
private int[] b = new int[256];
|
2011-01-10 22:07:56 +01:00
|
|
|
|
|
|
|
protected BlockFire(int i, int j) {
|
2011-01-29 22:50:29 +01:00
|
|
|
super(i, j, Material.FIRE);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.a(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void f() {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(Block.WOOD.id, 5, 20);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.a(Block.FENCE.id, 5, 20);
|
|
|
|
this.a(Block.WOOD_STAIRS.id, 5, 20);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(Block.LOG.id, 5, 5);
|
|
|
|
this.a(Block.LEAVES.id, 30, 60);
|
|
|
|
this.a(Block.BOOKSHELF.id, 30, 20);
|
|
|
|
this.a(Block.TNT.id, 15, 100);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.a(Block.LONG_GRASS.id, 60, 100);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(Block.WOOL.id, 30, 60);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void a(int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a[i] = j;
|
|
|
|
this.b[i] = k;
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public AxisAlignedBB d(World world, int i, int j, int k) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean b() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-10 22:07:56 +01:00
|
|
|
public int a(Random random) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public int c() {
|
|
|
|
return 40;
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag = world.getTypeId(i, j - 1, k) == Block.NETHERRACK.id;
|
2011-01-10 22:07:56 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (!this.canPlace(world, i, j, k)) {
|
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag && world.v() && (world.s(i, j, k) || world.s(i - 1, j, k) || world.s(i + 1, j, k) || world.s(i, j, k - 1) || world.s(i, j, k + 1))) {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setTypeId(i, j, k, 0);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-04-26 03:08:52 +02:00
|
|
|
int l = world.getData(i, j, k);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-26 03:08:52 +02:00
|
|
|
if (l < 15) {
|
2011-05-26 14:48:22 +02:00
|
|
|
world.setRawData(i, j, k, l + random.nextInt(3) / 2);
|
2011-04-26 03:08:52 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
world.c(i, j, k, this.id, this.c());
|
2011-04-26 03:08:52 +02:00
|
|
|
if (!flag && !this.g(world, i, j, k)) {
|
|
|
|
if (!world.d(i, j - 1, k) || l > 3) {
|
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
}
|
|
|
|
} else if (!flag && !this.b(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
|
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.a(world, i + 1, j, k, 300, random, l);
|
|
|
|
this.a(world, i - 1, j, k, 300, random, l);
|
|
|
|
this.a(world, i, j - 1, k, 250, random, l);
|
|
|
|
this.a(world, i, j + 1, k, 250, random, l);
|
|
|
|
this.a(world, i, j, k - 1, 300, random, l);
|
|
|
|
this.a(world, i, j, k + 1, 300, random, l);
|
|
|
|
|
|
|
|
// CraftBukkit start - Call to stop spread of fire.
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.Server server = world.getServer();
|
|
|
|
org.bukkit.World bworld = world.getWorld();
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
|
|
|
|
// CraftBukkit
|
|
|
|
|
|
|
|
for (int i1 = i - 1; i1 <= i + 1; ++i1) {
|
|
|
|
for (int j1 = k - 1; j1 <= k + 1; ++j1) {
|
|
|
|
for (int k1 = j - 1; k1 <= j + 4; ++k1) {
|
|
|
|
if (i1 != i || k1 != j || j1 != k) {
|
|
|
|
int l1 = 100;
|
|
|
|
|
|
|
|
if (k1 > j + 1) {
|
|
|
|
l1 += (k1 - (j + 1)) * 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i2 = this.h(world, i1, k1, j1);
|
|
|
|
|
|
|
|
if (i2 > 0) {
|
|
|
|
int j2 = (i2 + 40) / (l + 30);
|
2011-04-26 03:08:52 +02:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.v() || !world.s(i1, k1, j1)) && !world.s(i1 - 1, k1, k) && !world.s(i1 + 1, k1, j1) && !world.s(i1, k1, j1 - 1) && !world.s(i1, k1, j1 + 1)) {
|
|
|
|
int k2 = l + random.nextInt(5) / 4;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (k2 > 15) {
|
|
|
|
k2 = 15;
|
|
|
|
}
|
2011-04-26 03:08:52 +02:00
|
|
|
// CraftBukkit start - Call to stop spread of fire.
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.block.Block block = bworld.getBlockAt(i1, k1, j1);
|
2011-04-26 03:08:52 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (block.getTypeId() != Block.FIRE.id) {
|
|
|
|
BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null);
|
2011-04-26 03:08:52 +02:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-06-27 00:25:01 +02:00
|
|
|
|
2011-04-26 03:08:52 +02:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
world.setTypeIdAndData(i1, k1, j1, this.id, k2);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-04-26 03:08:52 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-18 08:43:39 +01:00
|
|
|
}
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
2011-02-01 12:43:31 +01:00
|
|
|
}
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
private void a(World world, int i, int j, int k, int l, Random random, int i1) {
|
|
|
|
int j1 = this.b[world.getTypeId(i, j, k)];
|
2011-01-10 22:07:56 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (random.nextInt(l) < j1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag = world.getTypeId(i, j, k) == Block.TNT.id;
|
2011-02-02 00:32:18 +01:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(i, j, k);
|
|
|
|
|
2011-02-02 00:32:18 +01:00
|
|
|
BlockBurnEvent event = new BlockBurnEvent(theBlock);
|
2011-06-27 00:25:01 +02:00
|
|
|
world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
if (event.isCancelled()) {
|
2011-02-21 23:30:01 +01:00
|
|
|
return;
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
2011-02-02 00:32:18 +01:00
|
|
|
// CraftBukkit end
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (random.nextInt(i1 + 10) < 5 && !world.s(i, j, k)) {
|
|
|
|
int k1 = i1 + random.nextInt(5) / 4;
|
|
|
|
|
|
|
|
if (k1 > 15) {
|
|
|
|
k1 = 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
world.setTypeIdAndData(i, j, k, this.id, k1);
|
2011-02-21 23:30:01 +01:00
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setTypeId(i, j, k, 0);
|
2011-02-21 23:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Block.TNT.postBreak(world, i, j, k, 0);
|
2011-02-21 23:30:01 +01:00
|
|
|
}
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
private boolean g(World world, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.b(world, i + 1, j, k) ? true : (this.b(world, i - 1, j, k) ? true : (this.b(world, i, j - 1, k) ? true : (this.b(world, i, j + 1, k) ? true : (this.b(world, i, j, k - 1) ? true : this.b(world, i, j, k + 1)))));
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private int h(World world, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
byte b0 = 0;
|
2011-01-10 22:07:56 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!world.isEmpty(i, j, k)) {
|
2011-01-10 22:07:56 +01:00
|
|
|
return 0;
|
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
int l = this.g(world, i + 1, j, k, b0);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
l = this.g(world, i - 1, j, k, l);
|
|
|
|
l = this.g(world, i, j - 1, k, l);
|
|
|
|
l = this.g(world, i, j + 1, k, l);
|
|
|
|
l = this.g(world, i, j, k - 1, l);
|
|
|
|
l = this.g(world, i, j, k + 1, l);
|
2011-01-10 22:07:56 +01:00
|
|
|
return l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
public boolean m_() {
|
2011-01-10 22:07:56 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.a[iblockaccess.getTypeId(i, j, k)] > 0;
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public int g(World world, int i, int j, int k, int l) {
|
2011-01-29 22:50:29 +01:00
|
|
|
int i1 = this.a[world.getTypeId(i, j, k)];
|
2011-01-10 22:07:56 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
return i1 > l ? i1 : l;
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean canPlace(World world, int i, int j, int k) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return world.d(i, j - 1, k) || this.g(world, i, j, k);
|
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) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setTypeId(i, j, k, 0);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void e(World world, int i, int j, int k) {
|
2011-02-23 03:37:56 +01:00
|
|
|
if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.a_(world, i, j, k)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
world.setTypeId(i, j, k, 0);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
world.c(i, j, k, this.id, this.c());
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-18 22:44:01 +01:00
|
|
|
}
|