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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
package gtPlusPlus.australia.gen.world;
import java.util.Random;
import gtPlusPlus.core.util.math.MathUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraftforge.common.util.ForgeDirection;
public class WorldGenAustralianTrees extends WorldGenTrees {
/** The minimum height of a generated tree. */
private final int minHeight;
/** True if this tree should grow Vines. */
private final boolean growVines;
/** The metadata value of the wood to use in tree generation. */
private final int woodMeta;
/** The metadata value of the leaves to use in tree generation. */
private final int leavesMeta;
public WorldGenAustralianTrees(boolean p_i2027_1_) {
this(p_i2027_1_, 4, false);
}
public WorldGenAustralianTrees(boolean p_i2028_1_, int aMinHeight, boolean aVinesGrow) {
super(p_i2028_1_, aMinHeight, 0, 0, aVinesGrow);
this.minHeight = aMinHeight;
this.woodMeta = 0;
this.leavesMeta = 0;
this.growVines = aVinesGrow;
}
public boolean generate(World aWorld, Random aRand, int aX, int aY, int aZ) {
int aActualMinHeight = MathUtils.randInt(4, 8) + this.minHeight;
boolean flag = true;
if (aY >= 1 && aY + aActualMinHeight + 1 <= 256) {
byte b0;
int k1;
Block block;
for (int i1 = aY; i1 <= aY + 1 + aActualMinHeight; ++i1) {
b0 = 1;
if (i1 == aY) {
b0 = 0;
}
if (i1 >= aY + 1 + aActualMinHeight - 2) {
b0 = 2;
}
for (int j1 = aX - b0; j1 <= aX + b0 && flag; ++j1) {
for (k1 = aZ - b0; k1 <= aZ + b0 && flag; ++k1) {
if (i1 >= 0 && i1 < 256) {
block = aWorld.getBlock(j1, i1, k1);
if (!this.isReplaceable(aWorld, j1, i1, k1)) {
flag = false;
}
} else {
flag = false;
}
}
}
}
if (!flag) {
return false;
} else {
Block block2 = aWorld.getBlock(aX, aY - 1, aZ);
boolean isSoil = true;
for (int gh = 0; gh < 5; gh++) {
int xMod, zMod;
if (gh == 0) {
xMod = 1;
zMod = 0;
}
else if (gh == 1) {
xMod = 0;
zMod = 1;
}
else if (gh == 2) {
xMod = -1;
zMod = 0;
}
else if (gh == 3) {
xMod = 0;
zMod = -1;
}
else {
xMod = 0;
zMod = 0;
}
block2 = aWorld.getBlock(aX+xMod, aY - 1, aZ+zMod);
if (block2 == Blocks.air || !block2.canSustainPlant(aWorld, aX+xMod, aY - 1, aZ+zMod, ForgeDirection.UP, (BlockSapling) Blocks.sapling)) {
isSoil = false;
break;
}
}
if (isSoil && aY < 256 - aActualMinHeight - 1) {
block2.onPlantGrow(aWorld, aX, aY - 1, aZ, aX, aY, aZ);
b0 = 5;
byte b1 = 0;
int l1;
int i2;
int j2;
int i3;
for (k1 = aY - b0 + aActualMinHeight; k1 <= aY + aActualMinHeight; ++k1) {
i3 = k1 - (aY + aActualMinHeight);
l1 = b1 + 3 - i3 / 2;
for (i2 = aX - l1; i2 <= aX + l1; ++i2) {
j2 = i2 - aX;
for (int k2 = aZ - l1; k2 <= aZ + l1; ++k2) {
int l2 = k2 - aZ;
if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || aRand.nextInt(2) != 0 && i3 != 0) {
Block block1 = aWorld.getBlock(i2, k1, k2);
if (block1.isAir(aWorld, i2, k1, k2) || block1.isLeaves(aWorld, i2, k1, k2)) {
this.setBlockAndNotifyAdequately(aWorld, i2, k1, k2, Blocks.leaves,
this.leavesMeta);
}
}
}
}
}
for (k1 = 0; k1 < aActualMinHeight; ++k1) {
block = aWorld.getBlock(aX, aY + k1, aZ);
if (block.isAir(aWorld, aX, aY + k1, aZ) || block.isLeaves(aWorld, aX, aY + k1, aZ)) {
//Set Middle Trunk
this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ, Blocks.log, this.woodMeta);
//Set Sides
if (k1 < (aActualMinHeight - 2)) {
if (aWorld.isAirBlock(aX+1, aY + k1, aZ) || block.isLeaves(aWorld, aX+1, aY + k1, aZ)) this.setBlockAndNotifyAdequately(aWorld, aX+1, aY + k1, aZ, Blocks.log, this.woodMeta);
if (aWorld.isAirBlock(aX-1, aY + k1, aZ) || block.isLeaves(aWorld, aX-1, aY + k1, aZ)) this.setBlockAndNotifyAdequately(aWorld, aX-1, aY + k1, aZ, Blocks.log, this.woodMeta);
if (aWorld.isAirBlock(aX, aY + k1, aZ+1) || block.isLeaves(aWorld, aX, aY + k1, aZ+1)) this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ+1, Blocks.log, this.woodMeta);
if (aWorld.isAirBlock(aX, aY + k1, aZ-1) || block.isLeaves(aWorld, aX, aY + k1, aZ-1)) this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ-1, Blocks.log, this.woodMeta);
}
if (this.growVines && k1 > 0) {
if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX - 1, aY + k1, aZ)) {
this.setBlockAndNotifyAdequately(aWorld, aX - 1, aY + k1, aZ, Blocks.vine, 8);
}
if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX + 1, aY + k1, aZ)) {
this.setBlockAndNotifyAdequately(aWorld, aX + 1, aY + k1, aZ, Blocks.vine, 2);
}
if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX, aY + k1, aZ - 1)) {
this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ - 1, Blocks.vine, 1);
}
if (aRand.nextInt(3) > 0 && aWorld.isAirBlock(aX, aY + k1, aZ + 1)) {
this.setBlockAndNotifyAdequately(aWorld, aX, aY + k1, aZ + 1, Blocks.vine, 4);
}
}
}
}
if (this.growVines) {
for (k1 = aY - 3 + aActualMinHeight; k1 <= aY + aActualMinHeight; ++k1) {
i3 = k1 - (aY + aActualMinHeight);
l1 = 2 - i3 / 2;
for (i2 = aX - l1; i2 <= aX + l1; ++i2) {
for (j2 = aZ - l1; j2 <= aZ + l1; ++j2) {
if (aWorld.getBlock(i2, k1, j2).isLeaves(aWorld, i2, k1, j2)) {
if (aRand.nextInt(4) == 0
&& aWorld.getBlock(i2 - 1, k1, j2).isAir(aWorld, i2 - 1, k1, j2)) {
this.growVines(aWorld, i2 - 1, k1, j2, 8);
}
if (aRand.nextInt(4) == 0
&& aWorld.getBlock(i2 + 1, k1, j2).isAir(aWorld, i2 + 1, k1, j2)) {
this.growVines(aWorld, i2 + 1, k1, j2, 2);
}
if (aRand.nextInt(4) == 0
&& aWorld.getBlock(i2, k1, j2 - 1).isAir(aWorld, i2, k1, j2 - 1)) {
this.growVines(aWorld, i2, k1, j2 - 1, 1);
}
if (aRand.nextInt(4) == 0
&& aWorld.getBlock(i2, k1, j2 + 1).isAir(aWorld, i2, k1, j2 + 1)) {
this.growVines(aWorld, i2, k1, j2 + 1, 4);
}
}
}
}
}
if (aRand.nextInt(5) == 0 && aActualMinHeight > 5) {
for (k1 = 0; k1 < 2; ++k1) {
for (i3 = 0; i3 < 4; ++i3) {
if (aRand.nextInt(4 - k1) == 0) {
l1 = aRand.nextInt(3);
this.setBlockAndNotifyAdequately(aWorld,
aX + Direction.offsetX[Direction.rotateOpposite[i3]], aY + aActualMinHeight - 5 + k1,
aZ + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa,
l1 << 2 | i3);
}
}
}
}
}
return true;
} else {
return false;
}
}
} else {
return false;
}
}
/**
* Grows vines downward from the given block for a given length. Args: World, x,
* starty, z, vine-length
*/
private void growVines(World p_76529_1_, int p_76529_2_, int p_76529_3_, int p_76529_4_, int p_76529_5_) {
this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_);
int i1 = 4;
while (true) {
--p_76529_3_;
if (!p_76529_1_.getBlock(p_76529_2_, p_76529_3_, p_76529_4_).isAir(p_76529_1_, p_76529_2_, p_76529_3_,
p_76529_4_) || i1 <= 0) {
return;
}
this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_);
--i1;
}
}
}
|