-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBiomeGenTest3.java
227 lines (197 loc) · 8.54 KB
/
BiomeGenTest3.java
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
package freeradicalx.humanbiomes;
import java.util.Arrays;
import java.util.Random;
import ttftcuts.atg.api.ATGBiomes;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.feature.WorldGenDesertWells;
public class BiomeGenTest3 extends BiomeGenBase{
public BiomeGenTest3(int par1) {
super(par1);
this.setBiomeName("Test Biome 3");
this.topBlock = (byte)Block.grass.blockID;
this.theBiomeDecorator.treesPerChunk = 0;
this.theBiomeDecorator.flowersPerChunk = 0;
this.theBiomeDecorator.deadBushPerChunk = 0;
this.theBiomeDecorator.mushroomsPerChunk = 0;
this.theBiomeDecorator.generateLakes = false;
}
public void decorate(World world, Random par2Random, int x, int z)
{
super.decorate(world, par2Random, x, z);
//System.out.println("x: " + x + " z: " + z);
int X = x / 16;
int Z = z / 16;
//System.out.println("X: " + X + " Z: " + Z);
int[] heightSamples = {
world.getHeightValue(x, z),
world.getHeightValue(x + 8, z),
world.getHeightValue(x + 15, z),
world.getHeightValue(x, z + 8),
world.getHeightValue(x + 8, z + 8),
world.getHeightValue(x + 15, z + 8),
world.getHeightValue(x, z + 15),
world.getHeightValue(x + 8, z + 15),
world.getHeightValue(x + 15, z + 15),
};
Arrays.sort(heightSamples);
int variance = heightSamples[heightSamples.length - 1] - heightSamples[0];
int sum = 0;
for (int i = 0; i < heightSamples.length; i++){
sum = sum + heightSamples[i];
}
int height = sum / heightSamples.length;
}
//int height = (world.getHeightValue(x, z) + world.getHeightValue(x + 15, z) + world.getHeightValue(x, z + 15) + world.getHeightValue(x + 15, z + 15)) / 4;
//Buildings
/*
if ( (X % 5 != 0 && Z % 6 != 0) && !(((Z+4) % 6 == 0 || (Z+3) % 6 == 0 || (Z+2) % 6 == 0) && ((X+3) % 5 == 0 || (X+2) % 5 == 0)) )
{
Chunk chunk;
if ((X+4) % 5 == 0 && ((Z+4) % 6 == 0 || (Z+3) % 6 == 0 || (Z+2) % 6 == 0)){
chunk = world.getChunkFromBlockCoords(X-1, Z);
height = world.getHeightValue(x-1, z+8);
}
if ((X+1) % 5 == 0 && ((Z+4) % 6 == 0 || (Z+3) % 6 == 0 || (Z+2) % 6 == 0)){
chunk = world.getChunkFromBlockCoords(X+1, Z);
height = world.getHeightValue(x+16, z+8);
}
if ((Z+5) % 6 == 0 && ((X+3) % 5 == 0 || (X+2) % 5 == 0)){
chunk = world.getChunkFromBlockCoords(X, Z-1);
height = world.getHeightValue(x+8, z-1);
}
if ((Z+1) % 6 == 0 && ((X+3) % 5 == 0 || (X+2) % 5 == 0)){
chunk = world.getChunkFromBlockCoords(X, Z+1);
height = world.getHeightValue(x+8, z+16);
}
if ((X+4) % 5 == 0 && (Z+5) % 6 == 0){
chunk = world.getChunkFromBlockCoords(X-1, Z-1);
height = world.getHeightValue(x-1, z-1);
}
if ((X+4) % 5 == 0 && (Z+1) % 6 == 0){
chunk = world.getChunkFromBlockCoords(X-1, Z+1);
height = world.getHeightValue(x-1, z-16);
}
if ((X+1) % 5 == 0 && (Z+5) % 6 == 0){
chunk = world.getChunkFromBlockCoords(X+1, Z+1);
height = world.getHeightValue(x+16, z-1);
}
if ((X+1) % 5 == 0 && (Z+1) % 6 == 0){
chunk = world.getChunkFromBlockCoords(X+1, Z+1);
height = world.getHeightValue(x+16, z+16);
}
for (int yCount = 0; yCount < 20; yCount++){
if (yCount == 0){
for (int xCount = 0; xCount < 16; xCount++){
for (int zCount = 0; zCount < 16; zCount++){
world.setBlock(x + xCount, height + yCount, z + zCount, Block.sandStone.blockID);
int n = height - 1;
while (world.getBlockId(x + xCount, n, z + zCount) == 0){
world.setBlock(x + xCount, n, z + zCount, Block.sand.blockID);
n--;
if (height - n > 50){ break; }
}
}
}
}
if (yCount > 0 && yCount < 10){
for (int xCount = 0; xCount < 16; xCount++){
for (int zCount = 0; zCount < 16; zCount++){
if ((xCount == 2 || xCount == 13) && (zCount > 1 && zCount < 14)){
world.setBlock(x + xCount, height + yCount, z + zCount, Block.sandStone.blockID);
}
else if ((xCount > 1 && xCount < 14) && (zCount == 2 || zCount == 13)){
world.setBlock(x + xCount, height + yCount, z + zCount, Block.sandStone.blockID);
}
else {
world.setBlock(x + xCount, height + yCount, z + zCount, 0);
}
}
}
}
if (yCount == 10){
for (int xCount = 0; xCount < 16; xCount++){
for (int zCount = 0; zCount < 16; zCount++){
if ((xCount > 1 && xCount < 14) && (zCount > 1 && zCount < 14)){
world.setBlock(x + xCount, height + yCount, z + zCount, Block.sandStone.blockID);
}
else {
if (world.getBlockId(x + xCount, height + yCount, z + zCount) != 0){
world.setBlock(x + xCount, height + yCount, z + zCount, 0);
}
}
}
}
}
if (yCount > 10){
for (int xCount = 0; xCount < 16; xCount++){
for (int zCount = 0; zCount < 16; zCount++){
if (world.getBlockId(x + xCount, height + yCount, z + zCount) != 0){
world.setBlock(x + xCount, height + yCount, z + zCount, 0);
}
}
}
}
}
} */
/*
//East-west streets
if (X % 16 == 0 && Z % 16 != 0){
int eastHeight = (world.getHeightValue(x, z) + world.getHeightValue(x + 8, z) + world.getHeightValue(x + 15, z)) / 3;
int westHeight = (world.getHeightValue(x, z + 15) + world.getHeightValue(x + 8, z + 15) + world.getHeightValue(x + 15, z + 15)) / 3;
//if (Math.abs(eastHeight - westHeight) > 16) { return; }
float heightIncrement = (float)Math.abs(eastHeight - westHeight) / 16F;
if (eastHeight > westHeight) heightIncrement = -heightIncrement;
for (int zCount = 0; zCount < 16; zCount++){
for (int xCount = 0; xCount < 16; xCount++){
world.setBlock(x + xCount, (int)(eastHeight + (heightIncrement * zCount)), z + zCount, 35, 15, 3);
if (xCount == 7 && zCount % 4 != 0){
world.setBlock(x + xCount, (int)(eastHeight + (heightIncrement * zCount)), z + zCount, 35, 4, 3);
}
int n = (int)(eastHeight + (heightIncrement * zCount)) + 1;
while (world.getBlockId(x + xCount, n, z + zCount) != 0){
world.setBlock(x + xCount, n, z + zCount, 0);
n++;
}
}
}
}
//North-south streets
if (X % 16 != 0 && Z % 16 == 0){
int northHeight = (world.getHeightValue(x, z) + world.getHeightValue(x, z + 8) + world.getHeightValue(x, z + 15)) / 3;
int southHeight = (world.getHeightValue(x + 15, z) + world.getHeightValue(x + 15, z + 8) + world.getHeightValue(x + 15, z + 15)) / 3;
//if (Math.abs(northHeight - southHeight) > 16) { return; }
float heightIncrement = (float)Math.abs(northHeight - southHeight) / 16F;
if (northHeight > southHeight) heightIncrement = -heightIncrement;
for (int xCount = 0; xCount < 16; xCount++){
for (int zCount = 0; zCount < 16; zCount++){
world.setBlock(x + xCount, (int)(northHeight + (heightIncrement * xCount)), z + zCount, 35, 15, 3);
if (zCount == 7 && xCount % 4 != 0){
world.setBlock(x + xCount, (int)(northHeight + (heightIncrement * xCount)), z + zCount, 35, 4, 3);
}
int n = (int)(northHeight + (heightIncrement * xCount)) + 1;
while (world.getBlockId(x + xCount, n, z + xCount) != 0){
world.setBlock(x + xCount, n, z + zCount, 0);
n++;
}
}
}
}
//Intersections
if (X % 16 == 0 && Z % 16 == 0){
for (int xCount = 0; xCount < 16; xCount++){
for (int zCount = 0; zCount < 16; zCount++){
world.setBlock(x + xCount, height, z + zCount, 35, 15, 3);
int n = height + 1;
while (world.getBlockId(x + xCount, n, z + zCount) != 0){
world.setBlock(x + xCount, n, z + zCount, 0);
n++;
}
}
}
}
}
*/
}