Skip to content

Commit 619ccfc

Browse files
Crater tweaks and volcano random radius additions
1 parent 8503a3c commit 619ccfc

File tree

5 files changed

+43
-23
lines changed

5 files changed

+43
-23
lines changed

src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenCrater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private int getRadius(int base, int x, int z, int bumps, int[] random) {
201201

202202
//Then we want to add some sin-function bumps to it, as determined by the bumps
203203
//They increase theta each time because then we can get different-placed perturbations
204-
//An example graph for this is here: https://www.desmos.com/calculator/2dqaekywth
204+
//An example graph for this is here: https://www.desmos.com/calculator/5ojoqscuxv
205205
int extras = 0;
206206
for (int i = 2; i < Math.min(5, bumps) + 2; i++){
207207
extras += random[i-2] * base * Math.sin(i * radians) * 0.0075;

src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenCraterHuge.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_1807
6464
int[] sinCoefficients = {rand.nextInt(10) + 1, rand.nextInt(10) + 1, rand.nextInt(10) + 1, rand.nextInt(10) + 1, rand.nextInt(10) + 1};
6565
//Radius determination, with heavy weight towards smaller craters
6666
int baseRadius = getBaseRadius(rand.nextInt(400));
67-
//Perturbation # calculation
67+
//Perturbation # calculation && center spire boolean
6868
int numBulges = rand.nextInt(5) + 1;
69+
boolean spire = rand.nextInt(4) == 0;
6970

7071
//Turn the coordinates from chunk stuff into their actual values
7172
int xCoord = -chunkX + p_180701_4_;
@@ -103,7 +104,7 @@ protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_1807
103104
//Standard inversePartialSquareRadius & blockRadius stuff
104105
int distancesSquared = ((xCoord * 16) + x) * ((xCoord * 16) + x) + ((zCoord * 16) + z) * ((zCoord * 16) + z);
105106
int blockRadius = (int)Math.sqrt(distancesSquared);
106-
int inversePartialSquareRadius = (radius*radius - distancesSquared) / (radius * 4);
107+
int inversePartialSquareRadius = (int)((radius*radius - distancesSquared) / (baseRadius * ((baseRadius > 256) ? 4 : (baseRadius > 128) ? 3 : 2.25)));
107108
int inverseRadius = radius - blockRadius;
108109

109110
//Places filler blocks to excavate the crater
@@ -119,16 +120,16 @@ protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_1807
119120
//The graph of this function and the old one can be found here https://www.desmos.com/calculator/x02rgy2wlf
120121
for (int dist = -1; dist < 9 * ridgeSize * ((1 - inverseRadius)/(0.8 * radius + (inverseRadius - 1) * (inverseRadius - 1))) - 1.06; dist++) {
121122
//Place the bank thrown up by the impact, and have some of the farthest be dispersed
122-
if (y + dist < 255 && inverseRadius > -0.5 * radius)
123+
if (y + dist < 255 && inverseRadius > -0.75 * radius)
123124
chunkPrimerIn.setBlockState(x, y + dist, z, this.getBlockToPlace(world, chunkX, chunkZ, ores));
124-
else if (y + dist < 255 && inverseRadius >= -0.625 * radius && !(rand.nextInt(inverseRadius + (int)(radius * 0.625) + 1) == 0))
125+
else if (y + dist < 255 && inverseRadius >= -0.875 * radius && !(rand.nextInt(inverseRadius + (int)(radius * 0.875) + 1) == 0))
125126
chunkPrimerIn.setBlockState(x, y + dist, z, this.getBlockToPlace(world, chunkX, chunkZ, ores));
126-
else if (y + dist < 255 && inverseRadius < -0.625 * radius && rand.nextInt(Math.abs(inverseRadius + (int)(radius * 0.625)) + 1) == 0)
127+
else if (y + dist < 255 && inverseRadius < -0.875 * radius && rand.nextInt(Math.abs(inverseRadius + (int)(radius * 0.875)) + 1) == 0)
127128
chunkPrimerIn.setBlockState(x, y + dist, z, this.getBlockToPlace(world, chunkX, chunkZ, ores));
128129

129130
//Ejecta blocks on top, then ejecta blocks below farther out
130131
if (rand.nextInt(Math.abs(inverseRadius) + 1) == 0) {
131-
if (inverseRadius < -0.25 * radius && inverseRadius > -1.5 * radius)
132+
if (inverseRadius < -0.375 * radius && inverseRadius > -1.5 * radius)
132133
chunkPrimerIn.setBlockState(x, y + dist + 1, z, this.getBlockToPlace(world, chunkX, chunkZ, ores));
133134
else if (inverseRadius < -1.5 * radius)
134135
chunkPrimerIn.setBlockState(x, y + dist + 1+ rand.nextInt(2), z, this.getBlockToPlace(world, chunkX, chunkZ, ores));
@@ -145,8 +146,8 @@ else if (inverseRadius < -1.5 * radius)
145146

146147
//Place spire in the center of the bowl
147148
//An example of this graph is https://www.desmos.com/calculator/nn5xmzyu6i
148-
if (blockRadius < 0.1 * radius) {
149-
for (int dist = 0; dist < (-0.015625 * blockRadius * blockRadius) + radius/16; dist++) {
149+
if (blockRadius < 0.25 * radius && spire) {
150+
for (int dist = 0; dist < Math.pow(Math.abs(-(radius/16.0) + blockRadius/4.0), 1.25); dist++) {
150151
chunkPrimerIn.setBlockState(x, y + Math.min(dist, 16) - 27, z, this.getBlockToPlaceRich(world, chunkX, chunkZ, ores));
151152
}
152153

@@ -215,7 +216,7 @@ private int getRadius(int base, int x, int z, int bumps, int[] random) {
215216

216217
//Then we want to add some sin-function bumps to it, as determined by the bumps
217218
//They increase theta each time because then we can get different-placed perturbations
218-
//An example graph for this is here: https://www.desmos.com/calculator/z4dsa5k1qv
219+
//An example graph for this is here: https://www.desmos.com/calculator/5ojoqscuxv
219220
int extras = 0;
220221
for (int i = 2; i < Math.min(5, bumps) + 2; i++){
221222
extras += random[i-2] * base * Math.sin(i * radians) * 0.0075;

src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenCraterSmall.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private int getRadius(int base, int x, int z, int bumps, int[] random) {
152152

153153
//Then we want to add some sin-function bumps to it, as determined by the bumps
154154
//They increase theta each time because then we can get different-placed perturbations
155-
//An example graph for this is here: https://www.desmos.com/calculator/2dqaekywth
155+
//An example graph for this is here: https://www.desmos.com/calculator/5ojoqscuxv
156156
int extras = 0;
157157
for (int i = 2; i < Math.min(5, bumps) + 2; i++){
158158
extras += random[i-2] * base * Math.sin(i * radians) * 0.0125;

src/main/java/zmaster587/advancedRocketry/world/decoration/MapGenVolcano.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,38 @@ public MapGenVolcano(int chancePerChunk) {
2020

2121

2222
@Override
23-
protected void recursiveGenerate(World world, int chunkX,
24-
int chunkZ, int p_180701_4_, int p_180701_5_,
25-
ChunkPrimer chunkPrimerIn) {
23+
protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn) {
2624

2725
chancePerChunk = 15;
2826

2927
if(rand.nextInt(chancePerChunk) == Math.abs(chunkX) % chancePerChunk && rand.nextInt(chancePerChunk) == Math.abs(chunkZ) % chancePerChunk) {
3028

29+
//Standard coefficient stuff
3130
int size = 64;
3231
int sizeDeviation = rand.nextInt(8); // 0 -> 8
33-
int baseHeight = 40;
32+
int baseHeight = 25;
3433
int lavaNodeHeight = 25;
34+
//Random coefficients for the sin functions
35+
int[] sinCoefficients = {rand.nextInt(10) + 1, rand.nextInt(10) + 1, rand.nextInt(10) + 1, rand.nextInt(10) + 1, rand.nextInt(10) + 1};
36+
int numBumps = rand.nextInt(5) + 1;
3537

3638
int xCoord = -chunkX + p_180701_4_;
3739
int zCoord = -chunkZ + p_180701_5_;
38-
int crackle;
3940

4041
for(int x = 15; x >= 0; x--) {
4142
for(int z = 15; z >= 0; z--) {
4243

43-
//Do some roughness
44-
crackle = rand.nextInt(2);
45-
4644
int xCoordNew = (xCoord*16)+x;
4745
int zCoordNew = (zCoord*16)+z;
4846

47+
//Radius determination based on random functions
4948
int x2 = xCoordNew*xCoordNew;
5049
int z2 = zCoordNew*zCoordNew;
51-
double radius = Math.sqrt(x2 + z2);
52-
double func = 1/(Math.pow(1.028, radius-(size-sizeDeviation)*3)) +
50+
double radius = getRadius(Math.sqrt(x2 + z2), xCoordNew, zCoordNew, numBumps, sinCoefficients);
51+
//Do some roughness
52+
int crackle = rand.nextInt(2);
53+
54+
double func = 1/(Math.pow(1.028, radius-(size-sizeDeviation)*3)) +
5355
+ baseHeight
5456
- 8/(Math.pow(1.09, radius-((size-sizeDeviation)/2.6)))
5557
-Math.pow(1.7, radius - size*.9);
@@ -64,7 +66,7 @@ else if(underSurface)
6466
chunkPrimerIn.setBlockState(x, y, z, blockCasing.getDefaultState());
6567

6668

67-
double sphereradius = x2+z2+(y - lavaNodeHeight)*(y - lavaNodeHeight);
69+
double sphereradius = (radius * radius) + (y - lavaNodeHeight)*(y - lavaNodeHeight);
6870
if(sphereradius < 23*23)
6971
chunkPrimerIn.setBlockState(x, y, z, blockEnrichedLava.getDefaultState());
7072
else if(sphereradius < 25*25)
@@ -78,4 +80,21 @@ else if(sphereradius < 25*25)
7880
}
7981
}
8082
}
83+
84+
//Very fun function for fancy radius
85+
//Int[] MUST be the same size as max bumps or larger!
86+
private double getRadius(double base, int x, int z, int bumps, int[] random) {
87+
//We need to start this out with polar coordinates
88+
double radians = Math.atan2(x, z);
89+
90+
//Then we want to add some sin-function bumps to it, as determined by the bumps
91+
//They increase theta each time because then we can get different-placed perturbations
92+
//An example graph for this is here: https://www.desmos.com/calculator/5ojoqscuxv
93+
int extras = 0;
94+
for (int i = 2; i < Math.min(5, bumps) + 2; i++){
95+
extras += random[i-2] * base * Math.sin(i * radians) * 0.0125;
96+
}
97+
98+
return base + extras;
99+
}
81100
}

src/main/resources/assets/advancedrocketry/models/block/models/nuclearrocketmotor.obj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ f 30/38/37 25/32/37 24/52/38
403403
f 15/47/40 34/42/41 30/38/41
404404
f 24/52/43 25/32/44 27/34/44
405405
f 14/54/14 7/7/14 5/55/14
406-
usemtl Material.002
406+
usemtl Material
407407
f 41/68/47 46/69/47 57/70/47
408408
f 42/71/48 41/68/48 50/72/48
409409
f 43/73/49 42/74/49 52/75/49

0 commit comments

Comments
 (0)