-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vanilla code re-organisation (Stone Beach)
- Loading branch information
1 parent
bc6eeee
commit 9020889
Showing
6 changed files
with
209 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/rtg/biomes/realistic/vanilla/RealisticBiomeVanillaStoneBeach.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package rtg.biomes.realistic.vanilla; | ||
|
||
import rtg.api.RTGBiomes; | ||
import rtg.biomes.realistic.RealisticBiomeBase; | ||
import rtg.surface.vanilla.SurfaceVanillaStoneBeach; | ||
import rtg.terrain.vanilla.TerrainVanillaStoneBeach; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.world.biome.BiomeGenBase; | ||
|
||
public class RealisticBiomeVanillaStoneBeach extends RealisticBiomeVanilla | ||
{ | ||
public RealisticBiomeVanillaStoneBeach() | ||
{ | ||
super( | ||
BiomeGenBase.stoneBeach, | ||
RTGBiomes.baseRiverOasis, | ||
RealisticBiomeBase.coastColdCliff, | ||
new TerrainVanillaStoneBeach(0f, 100f, 63f, 80f), | ||
new SurfaceVanillaStoneBeach(BiomeGenBase.stoneBeach.topBlock, BiomeGenBase.stoneBeach.fillerBlock, false, null, 1f, 1.5f, 85f, 20f, 4f) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
src/main/java/rtg/surface/vanilla/SurfaceVanillaStoneBeach.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package rtg.surface.vanilla; | ||
|
||
import java.util.Random; | ||
|
||
import rtg.surface.SurfaceBase; | ||
import rtg.util.CellNoise; | ||
import rtg.util.CliffCalculator; | ||
import rtg.util.PerlinNoise; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.biome.BiomeGenBase; | ||
|
||
public class SurfaceVanillaStoneBeach extends SurfaceBase | ||
{ | ||
private boolean beach; | ||
private Block beachBlock; | ||
private float min; | ||
|
||
private float sCliff = 1.5f; | ||
private float sHeight = 60f; | ||
private float sStrength = 65f; | ||
private float cCliff = 1.5f; | ||
|
||
public byte topByte = 0; | ||
|
||
public SurfaceVanillaStoneBeach(Block top, Block fill, boolean genBeach, Block genBeachBlock, float minCliff) | ||
{ | ||
super(top, fill); | ||
beach = genBeach; | ||
beachBlock = genBeachBlock; | ||
min = minCliff; | ||
} | ||
|
||
public SurfaceVanillaStoneBeach(Block top, Block fill, boolean genBeach, Block genBeachBlock, float minCliff, float stoneCliff, float stoneHeight, float stoneStrength, float clayCliff) | ||
{ | ||
this(top, fill, genBeach, genBeachBlock, minCliff); | ||
|
||
sCliff = stoneCliff; | ||
sHeight = stoneHeight; | ||
sStrength = stoneStrength; | ||
cCliff = clayCliff; | ||
} | ||
|
||
@Override | ||
public void paintTerrain(Block[] blocks, byte[] metadata, int i, int j, int x, int y, int depth, World world, Random rand, PerlinNoise perlin, CellNoise cell, float[] noise, float river, BiomeGenBase[] base) | ||
{ | ||
float c = CliffCalculator.calc(x, y, noise); | ||
int cliff = 0; | ||
boolean gravel = false; | ||
|
||
Block b; | ||
for(int k = 255; k > -1; k--) | ||
{ | ||
b = blocks[(y * 16 + x) * 256 + k]; | ||
if(b == Blocks.air) | ||
{ | ||
depth = -1; | ||
} | ||
else if(b == Blocks.stone) | ||
{ | ||
depth++; | ||
|
||
if(depth == 0) | ||
{ | ||
if(k < 63) | ||
{ | ||
if(beach) | ||
{ | ||
gravel = true; | ||
} | ||
} | ||
|
||
float p = perlin.noise3(i / 8f, j / 8f, k / 8f) * 0.5f; | ||
if(c > min && c > sCliff - ((k - sHeight) / sStrength) + p) | ||
{ | ||
cliff = 1; | ||
} | ||
if(c > cCliff) | ||
{ | ||
cliff = 2; | ||
} | ||
|
||
if(cliff == 1) | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = rand.nextInt(3) == 0 ? Blocks.cobblestone : Blocks.stone; | ||
} | ||
else if(cliff == 2) | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = Blocks.stained_hardened_clay; | ||
metadata[(y * 16 + x) * 256 + k] = 9; | ||
} | ||
else if(k < 63) | ||
{ | ||
if(beach) | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = beachBlock; | ||
gravel = true; | ||
} | ||
else if(k < 62) | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = fillerBlock; | ||
} | ||
else | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = topBlock; | ||
metadata[(y * 16 + x) * 256 + k] = topByte; | ||
} | ||
} | ||
else | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = topBlock; | ||
metadata[(y * 16 + x) * 256 + k] = topByte; | ||
} | ||
} | ||
else if(depth < 6) | ||
{ | ||
if(cliff == 1) | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = Blocks.stone; | ||
} | ||
else if(cliff == 2) | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = Blocks.stained_hardened_clay; | ||
metadata[(y * 16 + x) * 256 + k] = 9; | ||
} | ||
else if(gravel) | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = beachBlock; | ||
} | ||
else | ||
{ | ||
blocks[(y * 16 + x) * 256 + k] = fillerBlock; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/rtg/terrain/vanilla/TerrainVanillaStoneBeach.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package rtg.terrain.vanilla; | ||
|
||
import rtg.terrain.TerrainBase; | ||
import rtg.util.CellNoise; | ||
import rtg.util.PerlinNoise; | ||
|
||
public class TerrainVanillaStoneBeach extends TerrainBase | ||
{ | ||
private float start; | ||
private float height; | ||
private float base; | ||
private float width; | ||
|
||
public TerrainVanillaStoneBeach(float hillStart, float landHeight, float baseHeight, float hillWidth) | ||
{ | ||
start = hillStart; | ||
height = landHeight; | ||
base = baseHeight; | ||
width = hillWidth; | ||
} | ||
|
||
@Override | ||
public float generateNoise(PerlinNoise perlin, CellNoise cell, int x, int y, float ocean, float border, float river) | ||
{ | ||
float h = perlin.noise2(x / width, y / width) * height * river; | ||
h = h < start ? start + ((h - start) / 4.5f) : h; | ||
|
||
if(h > 0f) | ||
{ | ||
float st = h * 1.5f > 15f ? 15f : h * 1.5f; | ||
h += cell.noise(x / 70D, y / 70D, 1D) * st; | ||
} | ||
|
||
h += perlin.noise2(x / 20f, y / 20f) * 5f; | ||
h += perlin.noise2(x / 12f, y / 12f) * 3f; | ||
h += perlin.noise2(x / 5f, y / 5f) * 1.5f; | ||
|
||
return base + h; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters