1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.LeavesDecayEvent;
// CraftBukkit end
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);
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);
}
}
}
}
}
}
public void a(World world, int i, int j, int k, Random random) {
if (world.z) {
return;
}
int l = world.b(i, j, k);
if ((l & 4) != 0) {
byte byte0 = 4;
int i1 = byte0 + 1;
byte byte1 = 32;
int j1 = byte1 * byte1;
int k1 = byte1 / 2;
if (b == null) {
b = new int[byte1 * byte1 * byte1];
}
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;
continue;
}
if (k3 == Block.K.bi) {
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2;
} else {
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1;
}
}
}
}
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) {
continue;
}
if (b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) {
b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) {
b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) {
b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
}
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) {
b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
}
}
}
}
}
}
int j2 = b[k1 * j1 + k1 * byte1 + k1];
if (j2 >= 0) {
world.c(i, j, k, l & -5);
} else {
g(world, i, j, k);
}
}
}
private void g(World world, int i, int j, int k) {
// CraftBukkit start
CraftServer server = ((WorldServer) world).getServer();
CraftWorld cworld = ((WorldServer) world).getWorld();
LeavesDecayEvent event = new LeavesDecayEvent(Type.LEAVES_DECAY, cworld.getBlockAt(i, j, k));
server.getPluginManager().callEvent(event);
if (event.isCancelled()) return;
// CraftBukkit end
a_(world, i, j, k, world.b(i, j, k));
world.e(i, j, k, 0);
}
public int a(Random random) {
return random.nextInt(16) != 0 ? 0 : 1;
}
public int a(int i, Random random) {
return Block.y.bi;
}
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);
}
}
|