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
|
package net.minecraft.server;
import java.util.Random;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
// CraftBukkit start
import org.bukkit.block.BlockState;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.BlockFadeEvent;
// CraftBukkit end
public class BlockGrass extends Block implements IBlockFragilePlantElement {
private static final Logger a = LogManager.getLogger();
protected BlockGrass() {
super(Material.GRASS);
this.a(true);
this.a(CreativeModeTab.b);
}
public void a(World world, int i, int j, int k, Random random) {
if (!world.isStatic) {
if (world.getLightLevel(i, j + 1, k) < 4 && world.getType(i, j + 1, k).k() > 2) {
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
BlockState blockState = bworld.getBlockAt(i, j, k).getState();
blockState.setTypeId(Block.b(Blocks.DIRT));
BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
} else if (world.getLightLevel(i, j + 1, k) >= 9) {
for (int l = 0; l < 4; ++l) {
int i1 = i + random.nextInt(3) - 1;
int j1 = j + random.nextInt(5) - 3;
int k1 = k + random.nextInt(3) - 1;
Block block = world.getType(i1, j1 + 1, k1);
if (world.getType(i1, j1, k1) == Blocks.DIRT && world.getData(i1, j1, k1) == 0 && world.getLightLevel(i1, j1 + 1, k1) >= 4 && block.k() <= 2) {
// CraftBukkit start
org.bukkit.World bworld = world.getWorld();
BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState();
blockState.setTypeId(Block.b(Blocks.GRASS));
BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
}
}
}
}
}
public Item getDropType(int i, Random random, int j) {
return Blocks.DIRT.getDropType(0, random, j);
}
public boolean a(World world, int i, int j, int k, boolean flag) {
return true;
}
public boolean a(World world, Random random, int i, int j, int k) {
return true;
}
public void b(World world, Random random, int i, int j, int k) {
int l = 0;
while (l < 128) {
int i1 = i;
int j1 = j + 1;
int k1 = k;
int l1 = 0;
while (true) {
if (l1 < l / 16) {
i1 += random.nextInt(3) - 1;
j1 += (random.nextInt(3) - 1) * random.nextInt(3) / 2;
k1 += random.nextInt(3) - 1;
if (world.getType(i1, j1 - 1, k1) == Blocks.GRASS && !world.getType(i1, j1, k1).r()) {
++l1;
continue;
}
} else if (world.getType(i1, j1, k1).material == Material.AIR) {
if (random.nextInt(8) != 0) {
if (Blocks.LONG_GRASS.j(world, i1, j1, k1)) {
world.setTypeAndData(i1, j1, k1, Blocks.LONG_GRASS, 1, 3);
}
} else {
String s = world.getBiome(i1, k1).a(random, i1, j1, k1);
a.debug("Flower in " + world.getBiome(i1, k1).af + ": " + s);
BlockFlowers blockflowers = BlockFlowers.e(s);
if (blockflowers != null && blockflowers.j(world, i1, j1, k1)) {
int i2 = BlockFlowers.f(s);
world.setTypeAndData(i1, j1, k1, blockflowers, i2, 3);
}
}
}
++l;
break;
}
}
}
}
|