Skip to content

Commit

Permalink
Vanilla code re-organisation (Stone Beach)
Browse files Browse the repository at this point in the history
  • Loading branch information
whichonespink44 committed Sep 9, 2015
1 parent bc6eeee commit 9020889
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/main/java/rtg/biomes/realistic/RealisticBiomeBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import rtg.biomes.realistic.savanna.RealisticBiomeStoneMountainsCactus;
import rtg.biomes.realistic.vanilla.RealisticBiomeVanillaBeach;
import rtg.biomes.realistic.vanilla.RealisticBiomeVanillaPlains;
import rtg.biomes.realistic.vanilla.RealisticBiomeVanillaStoneBeach;
import rtg.surface.SurfaceBase;
import rtg.terrain.TerrainBase;
import rtg.util.CellNoise;
Expand Down Expand Up @@ -123,6 +124,7 @@ public class RealisticBiomeBase
//VANILLA =======================================================================================
public static RealisticBiomeBase vanillaBeach = new RealisticBiomeVanillaBeach();
public static RealisticBiomeBase vanillaPlains = new RealisticBiomeVanillaPlains();
public static RealisticBiomeBase vanillaStoneBeach = new RealisticBiomeVanillaStoneBeach();

// ==============================================================================================

Expand Down
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)
);
}
}
13 changes: 4 additions & 9 deletions src/main/java/rtg/support/SupportVanilla.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
import rtg.api.RTGBiomes;
import rtg.biomes.realistic.vanilla.RealisticBiomeVanillaBeach;
import rtg.biomes.realistic.vanilla.RealisticBiomeVanillaPlains;
import rtg.biomes.realistic.vanilla.*;
import rtg.config.ConfigRTG;
import rtg.support.edit.*;
import rtg.surface.*;
Expand Down Expand Up @@ -37,13 +36,9 @@ public static void init()
if (ConfigRTG.generateVanillaStoneBeach)
{
Support.addBiome(
new RealisticBiomeSupport(
BiomeGenBase.stoneBeach, RTGBiomes.baseRiverWet,
new TerrainMountainRiver(),
new SurfaceDesertOasis(Blocks.gravel, Blocks.stone, Blocks.dirt, Blocks.gravel, (byte)0, 1)
),
BiomeCategory.COLD
);
new RealisticBiomeVanillaStoneBeach(),
BiomeCategory.WET
);
}

//vanilla_coldBeach
Expand Down
139 changes: 139 additions & 0 deletions src/main/java/rtg/surface/vanilla/SurfaceVanillaStoneBeach.java
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 src/main/java/rtg/terrain/vanilla/TerrainVanillaStoneBeach.java
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;
}
}
3 changes: 2 additions & 1 deletion src/main/java/rtg/world/ChunkManagerRealistic.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import rtg.biomes.realistic.savanna.RealisticBiomeSavannaForest;
import rtg.biomes.realistic.savanna.RealisticBiomeStoneMountains;
import rtg.biomes.realistic.savanna.RealisticBiomeStoneMountainsCactus;
import rtg.biomes.realistic.vanilla.RealisticBiomeVanillaStoneBeach;
import rtg.support.Support;
import rtg.util.CellNoise;
import rtg.util.PerlinNoise;
Expand Down Expand Up @@ -343,7 +344,7 @@ else if(wetEnabled)
* @todo Add a config option for single-biome worlds.
*/

//output = RealisticBiomeBase.vanillaBeach;
//output = RealisticBiomeBase.vanillaStoneBeach;

if (biomeDataMap.size() > 4096) {
biomeDataMap.clear();
Expand Down

0 comments on commit 9020889

Please sign in to comment.