2011-01-10 22:07:56 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-18 22:44:01 +01:00
|
|
|
// CraftBukkit start
|
2011-01-18 08:43:39 +01:00
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.entity.Player;
|
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-10 22:07:56 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
import java.util.Random;
|
2011-01-18 22:44:01 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 22:07:56 +01:00
|
|
|
|
|
|
|
public class BlockFire extends Block {
|
|
|
|
|
|
|
|
private int a[];
|
|
|
|
private int b[];
|
|
|
|
|
|
|
|
protected BlockFire(int i, int j) {
|
|
|
|
super(i, j, Material.l);
|
|
|
|
a = new int[256];
|
|
|
|
b = new int[256];
|
2011-01-14 14:31:10 +01:00
|
|
|
a(Block.x.bi, 5, 20);
|
|
|
|
a(Block.J.bi, 5, 5);
|
|
|
|
a(Block.K.bi, 30, 60);
|
|
|
|
a(Block.an.bi, 30, 20);
|
|
|
|
a(Block.am.bi, 15, 100);
|
|
|
|
a(Block.ab.bi, 30, 60);
|
2011-01-10 22:07:56 +01:00
|
|
|
a(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void a(int i, int j, int k) {
|
|
|
|
a[i] = j;
|
|
|
|
b[i] = k;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AxisAlignedBB d(World world, int i, int j, int k) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(Random random) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int b() {
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
2011-01-14 14:31:10 +01:00
|
|
|
boolean flag = world.a(i, j - 1, k) == Block.bb.bi;
|
|
|
|
int l = world.b(i, j, k);
|
2011-01-10 22:07:56 +01:00
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
if (l < 15) {
|
|
|
|
world.c(i, j, k, l + 1);
|
|
|
|
world.i(i, j, k, bi);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
if (!flag && !g(world, i, j, k)) {
|
2011-01-14 14:31:10 +01:00
|
|
|
if (!world.d(i, j - 1, k) || l > 3) {
|
|
|
|
world.e(i, j, k, 0);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (!flag && !b(((IBlockAccess) (world)), i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
|
|
|
|
world.e(i, j, k, 0);
|
2011-01-10 22:07:56 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (l % 2 == 0 && l > 2) {
|
2011-01-10 22:07:56 +01:00
|
|
|
a(world, i + 1, j, k, 300, random);
|
|
|
|
a(world, i - 1, j, k, 300, random);
|
|
|
|
a(world, i, j - 1, k, 250, random);
|
|
|
|
a(world, i, j + 1, k, 250, random);
|
|
|
|
a(world, i, j, k - 1, 300, random);
|
|
|
|
a(world, i, j, k + 1, 300, random);
|
|
|
|
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) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int l1 = 100;
|
|
|
|
|
|
|
|
if (k1 > j + 1) {
|
|
|
|
l1 += (k1 - (j + 1)) * 100;
|
|
|
|
}
|
|
|
|
int i2 = h(world, i1, k1, j1);
|
|
|
|
|
2011-01-18 22:44:01 +01:00
|
|
|
// CraftBukkit start: Call to stop spread of fire.
|
2011-01-18 08:43:39 +01:00
|
|
|
Server server = ((WorldServer)world).getServer();
|
|
|
|
CraftWorld cworld = ((WorldServer)world).getWorld();
|
|
|
|
|
2011-01-18 22:00:49 +01:00
|
|
|
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i1, j1, k1));
|
2011-01-18 22:44:01 +01:00
|
|
|
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
|
|
|
|
Player thePlayer = null;
|
2011-01-18 08:43:39 +01:00
|
|
|
|
|
|
|
if (theBlock.getTypeId() != Block.ar.bi){
|
2011-01-18 22:44:01 +01:00
|
|
|
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
|
2011-01-18 08:43:39 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
2011-01-18 22:44:01 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 22:07:56 +01:00
|
|
|
if (i2 > 0 && random.nextInt(l1) <= i2) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i1, k1, j1, bi);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void a(World world, int i, int j, int k, int l, Random random) {
|
|
|
|
int i1 = b[world.a(i, j, k)];
|
|
|
|
|
|
|
|
if (random.nextInt(l) < i1) {
|
2011-01-14 14:31:10 +01:00
|
|
|
boolean flag = world.a(i, j, k) == Block.am.bi;
|
2011-01-10 22:07:56 +01:00
|
|
|
|
|
|
|
if (random.nextInt(2) == 0) {
|
2011-01-18 08:43:39 +01:00
|
|
|
// CraftBukkit start: Call to stop very slow spread of fire.
|
|
|
|
Server server = ((WorldServer)world).getServer();
|
2011-01-10 22:07:56 +01:00
|
|
|
CraftWorld cworld = ((WorldServer)world).getWorld();
|
2011-01-18 08:43:39 +01:00
|
|
|
|
|
|
|
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i, j, k));
|
2011-01-18 22:44:01 +01:00
|
|
|
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SLOW_SPREAD;
|
|
|
|
Player thePlayer = null;
|
2011-01-18 08:43:39 +01:00
|
|
|
|
|
|
|
if (theBlock.getTypeId() != Block.ar.bi){
|
2011-01-18 22:44:01 +01:00
|
|
|
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
|
2011-01-18 08:43:39 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
2011-01-18 22:44:01 +01:00
|
|
|
// CraftBukkit end
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, bi);
|
2011-01-10 22:07:56 +01:00
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, 0);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
if (flag) {
|
|
|
|
Block.am.a(world, i, j, k, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean g(World world, int i, int j, int k) {
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b(((IBlockAccess) (world)), i + 1, j, k)) {
|
2011-01-10 22:07:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b(((IBlockAccess) (world)), i - 1, j, k)) {
|
2011-01-10 22:07:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b(((IBlockAccess) (world)), i, j - 1, k)) {
|
2011-01-10 22:07:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b(((IBlockAccess) (world)), i, j + 1, k)) {
|
2011-01-10 22:07:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b(((IBlockAccess) (world)), i, j, k - 1)) {
|
2011-01-10 22:07:56 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
return b(((IBlockAccess) (world)), i, j, k + 1);
|
2011-01-10 22:07:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private int h(World world, int i, int j, int k) {
|
|
|
|
int l = 0;
|
|
|
|
|
|
|
|
if (!world.e(i, j, k)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
l = f(world, i + 1, j, k, l);
|
|
|
|
l = f(world, i - 1, j, k, l);
|
|
|
|
l = f(world, i, j - 1, k, l);
|
|
|
|
l = f(world, i, j + 1, k, l);
|
|
|
|
l = f(world, i, j, k - 1, l);
|
|
|
|
l = f(world, i, j, k + 1, l);
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean d() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
|
|
|
|
return a[iblockaccess.a(i, j, k)] > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int f(World world, int i, int j, int k, int l) {
|
|
|
|
int i1 = a[world.a(i, j, k)];
|
|
|
|
|
|
|
|
if (i1 > l) {
|
|
|
|
return i1;
|
|
|
|
} else {
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(World world, int i, int j, int k) {
|
|
|
|
return world.d(i, j - 1, k) || g(world, i, j, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(World world, int i, int j, int k, int l) {
|
|
|
|
if (!world.d(i, j - 1, k) && !g(world, i, j, k)) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, 0);
|
2011-01-10 22:07:56 +01:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void e(World world, int i, int j, int k) {
|
2011-01-18 08:43:39 +01:00
|
|
|
//TODO this section deals with lighting a block on fire too
|
2011-01-14 14:31:10 +01:00
|
|
|
if (world.a(i, j - 1, k) == Block.ap.bi && Block.be.b_(world, i, j, k)) {
|
2011-01-10 22:07:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!world.d(i, j - 1, k) && !g(world, i, j, k)) {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, 0);
|
2011-01-10 22:07:56 +01:00
|
|
|
return;
|
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
world.i(i, j, k, bi);
|
2011-01-10 22:07:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-01-18 22:44:01 +01:00
|
|
|
}
|