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
|
package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.block.BlockSpreadEvent;
// CraftBukkit end
public class BlockMushroom extends BlockFlower {
protected BlockMushroom(int i, int j) {
super(i, j);
float f = 0.2F;
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
this.a(true);
}
public void a(World world, int i, int j, int k, Random random) {
if (random.nextInt(100) == 0) {
int l = i + random.nextInt(3) - 1;
int i1 = j + random.nextInt(2) - random.nextInt(2);
int j1 = k + random.nextInt(3) - 1;
if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
int k1 = i + (random.nextInt(3) - 1);
k1 = k + (random.nextInt(3) - 1);
if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
// CraftBukkit start
Server server = world.getServer();
CraftWorld craftworld = world.getWorld();
BlockState blockState = craftworld.getBlockAt(l, i1, j1).getState();
blockState.setTypeId(this.id);
BlockSpreadEvent event = new BlockSpreadEvent(craftworld.getBlockAt(l, i1, j1), craftworld.getBlockAt(i, j, k), blockState);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
}
}
}
}
protected boolean c(int i) {
return Block.o[i];
}
public boolean f(World world, int i, int j, int k) {
return j >= 0 && j < 128 ? world.j(i, j, k) < 13 && this.c(world.getTypeId(i, j - 1, k)) : false;
}
}
|