2011-01-04 23:09:40 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
2011-01-11 09:25:13 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-01-04 23:09:40 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
import org.bukkit.event.Event.Type;
|
|
|
|
import org.bukkit.event.block.LeavesDecayEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-04 23:09:40 +01:00
|
|
|
|
|
|
|
public class BlockLeaves extends BlockLeavesBase {
|
|
|
|
|
|
|
|
private int c;
|
|
|
|
int b[];
|
|
|
|
|
|
|
|
protected BlockLeaves(int i, int j) {
|
|
|
|
super(i, j, Material.h, false);
|
|
|
|
c = j;
|
|
|
|
a(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(World world, int i, int j, int k) {
|
|
|
|
int l = 1;
|
|
|
|
int i1 = l + 1;
|
|
|
|
|
|
|
|
if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
|
|
|
|
for (int j1 = -l; j1 <= l; j1++) {
|
|
|
|
for (int k1 = -l; k1 <= l; k1++) {
|
|
|
|
for (int l1 = -l; l1 <= l; l1++) {
|
|
|
|
int i2 = world.a(i + j1, j + k1, k + l1);
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
if (i2 == Block.K.bi) {
|
|
|
|
int j2 = world.b(i + j1, j + k1, k + l1);
|
|
|
|
|
|
|
|
world.d(i + j1, j + k1, k + l1, j2 | 4);
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
|
|
|
if (world.z) {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
int l = world.b(i, j, k);
|
|
|
|
|
|
|
|
if ((l & 4) != 0) {
|
2011-01-04 23:09:40 +01:00
|
|
|
byte byte0 = 4;
|
2011-01-14 14:31:10 +01:00
|
|
|
int i1 = byte0 + 1;
|
2011-01-04 23:09:40 +01:00
|
|
|
byte byte1 = 32;
|
2011-01-14 14:31:10 +01:00
|
|
|
int j1 = byte1 * byte1;
|
|
|
|
int k1 = byte1 / 2;
|
2011-01-04 23:09:40 +01:00
|
|
|
|
|
|
|
if (b == null) {
|
|
|
|
b = new int[byte1 * byte1 * byte1];
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
|
|
|
|
for (int l1 = -byte0; l1 <= byte0; l1++) {
|
|
|
|
for (int k2 = -byte0; k2 <= byte0; k2++) {
|
|
|
|
for (int i3 = -byte0; i3 <= byte0; i3++) {
|
|
|
|
int k3 = world.a(i + l1, j + k2, k + i3);
|
|
|
|
|
|
|
|
if (k3 == Block.J.bi) {
|
|
|
|
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0;
|
2011-01-04 23:09:40 +01:00
|
|
|
continue;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (k3 == Block.K.bi) {
|
|
|
|
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2;
|
2011-01-04 23:09:40 +01:00
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
for (int i2 = 1; i2 <= 4; i2++) {
|
|
|
|
for (int l2 = -byte0; l2 <= byte0; l2++) {
|
|
|
|
for (int j3 = -byte0; j3 <= byte0; j3++) {
|
|
|
|
for (int l3 = -byte0; l3 <= byte0; l3++) {
|
|
|
|
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1) {
|
2011-01-04 23:09:40 +01:00
|
|
|
continue;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
|
|
|
|
b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
|
|
|
|
b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) {
|
|
|
|
b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) {
|
|
|
|
b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) {
|
|
|
|
b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) {
|
|
|
|
b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
int j2 = b[k1 * j1 + k1 * byte1 + k1];
|
2011-01-04 23:09:40 +01:00
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
if (j2 >= 0) {
|
|
|
|
world.c(i, j, k, l & -5);
|
2011-01-04 23:09:40 +01:00
|
|
|
} else {
|
|
|
|
g(world, i, j, k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void g(World world, int i, int j, int k) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
CraftServer server = ((WorldServer) world).getServer();
|
|
|
|
CraftWorld cworld = ((WorldServer) world).getWorld();
|
2011-01-04 23:09:40 +01:00
|
|
|
LeavesDecayEvent event = new LeavesDecayEvent(Type.LEAVES_DECAY, cworld.getBlockAt(i, j, k));
|
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
|
|
|
if (event.isCancelled()) return;
|
|
|
|
// CraftBukkit end
|
2011-01-04 23:09:40 +01:00
|
|
|
|
|
|
|
a_(world, i, j, k, world.b(i, j, k));
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j, k, 0);
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a(Random random) {
|
|
|
|
return random.nextInt(16) != 0 ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(int i, Random random) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return Block.y.bi;
|
2011-01-04 23:09:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a() {
|
|
|
|
return !a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(World world, int i, int j, int k, Entity entity) {
|
|
|
|
super.b(world, i, j, k, entity);
|
|
|
|
}
|
|
|
|
}
|