-
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.
Added biome support for Afraid of the Dark.
- Loading branch information
1 parent
7e0b14c
commit e6f028a
Showing
12 changed files
with
248 additions
and
0 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
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
17 changes: 17 additions & 0 deletions
17
src/main/java/rtg/api/biome/afraidofthedark/config/BiomeConfigAOTD.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,17 @@ | ||
package rtg.api.biome.afraidofthedark.config; | ||
|
||
import rtg.api.biome.BiomeConfig; | ||
|
||
public class BiomeConfigAOTD { | ||
|
||
public static BiomeConfig biomeConfigAOTDErieForest; | ||
|
||
public static BiomeConfig[] getBiomeConfigs() { | ||
|
||
BiomeConfig[] biomeConfigs = new BiomeConfig[]{ | ||
biomeConfigAOTDErieForest | ||
}; | ||
|
||
return biomeConfigs; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/rtg/api/biome/afraidofthedark/config/BiomeConfigAOTDBase.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,11 @@ | ||
package rtg.api.biome.afraidofthedark.config; | ||
|
||
import rtg.api.biome.BiomeConfig; | ||
|
||
public class BiomeConfigAOTDBase extends BiomeConfig { | ||
|
||
public BiomeConfigAOTDBase(String biomeSlug) { | ||
|
||
super("afraidofthedark", biomeSlug); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/rtg/api/biome/afraidofthedark/config/BiomeConfigAOTDErieForest.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,10 @@ | ||
package rtg.api.biome.afraidofthedark.config; | ||
|
||
|
||
public class BiomeConfigAOTDErieForest extends BiomeConfigAOTDBase { | ||
|
||
public BiomeConfigAOTDErieForest() { | ||
|
||
super("erieforest"); | ||
} | ||
} |
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
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
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,33 @@ | ||
package rtg.config.afraidofthedark; | ||
|
||
import java.io.File; | ||
|
||
import net.minecraftforge.common.config.Configuration; | ||
|
||
import rtg.api.biome.afraidofthedark.config.BiomeConfigAOTD; | ||
import rtg.config.BiomeConfigManager; | ||
import rtg.util.Logger; | ||
|
||
public class ConfigAOTD { | ||
|
||
public static Configuration config; | ||
|
||
public static void init(File configFile) { | ||
|
||
config = new Configuration(configFile); | ||
|
||
try { | ||
config.load(); | ||
|
||
BiomeConfigManager.setBiomeConfigsFromUserConfigs(BiomeConfigAOTD.getBiomeConfigs(), config); | ||
} | ||
catch (Exception e) { | ||
Logger.error("RTG has had a problem loading AOTD configuration."); | ||
} | ||
finally { | ||
if (config.hasChanged()) { | ||
config.save(); | ||
} | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/rtg/world/biome/realistic/afraidofthedark/RealisticBiomeAOTDBase.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,49 @@ | ||
package rtg.world.biome.realistic.afraidofthedark; | ||
|
||
import net.minecraft.world.biome.BiomeGenBase; | ||
|
||
import net.minecraftforge.fml.common.Loader; | ||
|
||
import rtg.api.biome.BiomeConfig; | ||
import rtg.api.biome.afraidofthedark.config.BiomeConfigAOTD; | ||
import rtg.util.Logger; | ||
import rtg.world.biome.realistic.RealisticBiomeBase; | ||
import rtg.world.gen.surface.SurfaceBase; | ||
import rtg.world.gen.terrain.TerrainBase; | ||
|
||
public class RealisticBiomeAOTDBase extends RealisticBiomeBase { | ||
|
||
public static RealisticBiomeBase aotdErieForest; | ||
|
||
public RealisticBiomeAOTDBase(BiomeConfig config, BiomeGenBase b, BiomeGenBase riverbiome, TerrainBase t, SurfaceBase s) { | ||
|
||
super(config, b, riverbiome, t, s); | ||
|
||
this.waterSurfaceLakeChance = 0; | ||
this.lavaSurfaceLakeChance = 0; | ||
} | ||
|
||
public static void addBiomes() { | ||
|
||
if (Loader.isModLoaded("AfraidOfTheDark")) { | ||
BiomeGenBase[] b = BiomeGenBase.getBiomeGenArray(); | ||
|
||
for (int i = 0; i < 256; i++) { | ||
if (b[i] != null) { | ||
if (b[i].biomeName == null) { | ||
Logger.warn("Biome ID %d has no name.", b[i].biomeID); | ||
continue; | ||
} | ||
|
||
BiomeGenBase aotdBiome = b[i]; | ||
String biomeName = aotdBiome.biomeName; | ||
String biomeClass = aotdBiome.getBiomeClass().getName(); | ||
|
||
if (biomeName == "Erie Forest" && biomeClass == "com.DavidM1A2.AfraidOfTheDark.common.biomes.BiomeErieForest") { | ||
aotdErieForest = new RealisticBiomeAOTDErieForest(aotdBiome, BiomeConfigAOTD.biomeConfigAOTDErieForest); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/rtg/world/biome/realistic/afraidofthedark/RealisticBiomeAOTDErieForest.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,23 @@ | ||
package rtg.world.biome.realistic.afraidofthedark; | ||
|
||
import net.minecraft.world.biome.BiomeGenBase; | ||
|
||
import rtg.api.biome.BiomeConfig; | ||
import rtg.world.biome.deco.DecoBaseBiomeDecorations; | ||
import rtg.world.gen.surface.afraidofthedark.SurfaceAOTDErieForest; | ||
import rtg.world.gen.terrain.afraidofthedark.TerrainAOTDErieForest; | ||
|
||
public class RealisticBiomeAOTDErieForest extends RealisticBiomeAOTDBase { | ||
|
||
public RealisticBiomeAOTDErieForest(BiomeGenBase aotdBiome, BiomeConfig config) { | ||
|
||
super(config, | ||
aotdBiome, BiomeGenBase.river, | ||
new TerrainAOTDErieForest(68f, 80f, 30f), | ||
new SurfaceAOTDErieForest(config, aotdBiome.topBlock, aotdBiome.fillerBlock) | ||
); | ||
|
||
DecoBaseBiomeDecorations decoBaseBiomeDecorations = new DecoBaseBiomeDecorations(); | ||
this.addDeco(decoBaseBiomeDecorations); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/rtg/world/gen/surface/afraidofthedark/SurfaceAOTDErieForest.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,65 @@ | ||
package rtg.world.gen.surface.afraidofthedark; | ||
|
||
import java.util.Random; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.biome.BiomeGenBase; | ||
import net.minecraft.world.chunk.ChunkPrimer; | ||
|
||
import rtg.api.biome.BiomeConfig; | ||
import rtg.util.CellNoise; | ||
import rtg.util.CliffCalculator; | ||
import rtg.util.OpenSimplexNoise; | ||
import rtg.world.gen.surface.SurfaceBase; | ||
|
||
public class SurfaceAOTDErieForest extends SurfaceBase { | ||
|
||
public SurfaceAOTDErieForest(BiomeConfig config, IBlockState top, IBlockState filler) { | ||
|
||
super(config, top, filler); | ||
} | ||
|
||
@Override | ||
public void paintTerrain(ChunkPrimer primer, int i, int j, int x, int y, int depth, World world, Random rand, OpenSimplexNoise simplex, CellNoise cell, float[] noise, float river, BiomeGenBase[] base) { | ||
|
||
float c = CliffCalculator.calc(x, y, noise); | ||
boolean cliff = c > 1.4f ? true : false; | ||
|
||
for (int k = 255; k > -1; k--) { | ||
Block b = primer.getBlockState((y * 16 + x) * 256 + k).getBlock(); | ||
if (b == Blocks.air) { | ||
depth = -1; | ||
} | ||
else if (b == Blocks.stone) { | ||
depth++; | ||
|
||
if (cliff) { | ||
if (depth > -1 && depth < 2) { | ||
if (rand.nextInt(3) == 0) { | ||
|
||
primer.setBlockState((y * 16 + x) * 256 + k, hcCobble(world, i, j, x, y, k)); | ||
} | ||
else { | ||
|
||
primer.setBlockState((y * 16 + x) * 256 + k, hcStone(world, i, j, x, y, k)); | ||
} | ||
} | ||
else if (depth < 10) { | ||
primer.setBlockState((y * 16 + x) * 256 + k, hcStone(world, i, j, x, y, k)); | ||
} | ||
} | ||
else { | ||
if (depth == 0 && k > 61) { | ||
primer.setBlockState((y * 16 + x) * 256 + k, topBlock); | ||
} | ||
else if (depth < 4) { | ||
primer.setBlockState((y * 16 + x) * 256 + k, fillerBlock); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/rtg/world/gen/terrain/afraidofthedark/TerrainAOTDErieForest.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,25 @@ | ||
package rtg.world.gen.terrain.afraidofthedark; | ||
|
||
import rtg.util.CellNoise; | ||
import rtg.util.OpenSimplexNoise; | ||
import rtg.world.gen.terrain.TerrainBase; | ||
|
||
public class TerrainAOTDErieForest extends TerrainBase { | ||
|
||
private float minHeight; | ||
private float maxHeight; | ||
private float hillStrength; | ||
|
||
public TerrainAOTDErieForest(float minHeight, float maxHeight, float hillStrength) { | ||
|
||
this.minHeight = minHeight; | ||
this.maxHeight = (maxHeight > rollingHillsMaxHeight) ? rollingHillsMaxHeight : ((maxHeight < this.minHeight) ? rollingHillsMaxHeight : maxHeight); | ||
this.hillStrength = hillStrength; | ||
} | ||
|
||
@Override | ||
public float generateNoise(OpenSimplexNoise simplex, CellNoise cell, int x, int y, float border, float river) { | ||
|
||
return terrainRollingHills(x, y, simplex, river, hillStrength, maxHeight, groundNoise, groundNoiseAmplitudeHills, river); | ||
} | ||
} |