Skip to content

Commit

Permalink
Added biome support for Afraid of the Dark.
Browse files Browse the repository at this point in the history
  • Loading branch information
whichonespink44 committed Feb 1, 2017
1 parent 7e0b14c commit e6f028a
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 0 deletions.
1 change: 1 addition & 0 deletions mod_deps.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

depstring=after:BiomesOPlenty@[3.0.0.1924,);\
after:AbyssalCraftAPI@[1.8.1,);\
after:AfraidOfTheDark@[1.1.2,);\
after:highlands@[3.1.0,);\
after:flowercraftmod@[3.02,)
2 changes: 2 additions & 0 deletions src/main/java/rtg/RTG.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import rtg.util.RealisticBiomePresenceTester;
import rtg.world.WorldTypeRTG;
import rtg.world.biome.realistic.abyssalcraft.RealisticBiomeACBase;
import rtg.world.biome.realistic.afraidofthedark.RealisticBiomeAOTDBase;
import rtg.world.biome.realistic.biomesoplenty.RealisticBiomeBOPBase;
import rtg.world.biome.realistic.buildcraft.RealisticBiomeBCBase;
import rtg.world.biome.realistic.flowercraft.RealisticBiomeFCBase;
Expand Down Expand Up @@ -100,6 +101,7 @@ public void fmlLifeCycle(FMLPostInitializationEvent event) {
RealisticBiomeBCBase.addBiomes();
RealisticBiomeHLBase.addBiomes();
RealisticBiomeACBase.addBiomes();
RealisticBiomeAOTDBase.addBiomes();
RealisticBiomeMSBase.addBiomes();
RealisticBiomeFCBase.addBiomes();

Expand Down
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;
}
}
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);
}
}
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");
}
}
8 changes: 8 additions & 0 deletions src/main/java/rtg/config/BiomeConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import rtg.api.biome.BiomeConfig;
import rtg.api.biome.BiomeConfigProperty;
import rtg.api.biome.abyssalcraft.config.*;
import rtg.api.biome.afraidofthedark.config.BiomeConfigAOTD;
import rtg.api.biome.afraidofthedark.config.BiomeConfigAOTDErieForest;
import rtg.api.biome.biomesoplenty.config.*;
import rtg.api.biome.buildcraft.config.BiomeConfigBC;
import rtg.api.biome.buildcraft.config.BiomeConfigBCDesertOilField;
Expand All @@ -28,6 +30,7 @@ public class BiomeConfigManager {
public static void initBiomeConfigs() {

initBiomeConfigsAC();
initBiomeConfigsAOTD();
initBiomeConfigsBOP();
initBiomeConfigsBC();
initBiomeConfigsHL();
Expand All @@ -47,6 +50,11 @@ public static void initBiomeConfigsAC() {
BiomeConfigAC.biomeConfigACDarklandsPlains = new BiomeConfigACDarklandsPlains();
}

public static void initBiomeConfigsAOTD() {

BiomeConfigAOTD.biomeConfigAOTDErieForest = new BiomeConfigAOTDErieForest();
}

public static void initBiomeConfigsBOP() {

BiomeConfigBOP.biomeConfigBOPAlps = new BiomeConfigBOPAlps();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/rtg/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;

import rtg.config.abyssalcraft.ConfigAC;
import rtg.config.afraidofthedark.ConfigAOTD;
import rtg.config.biomesoplenty.ConfigBOP;
import rtg.config.buildcraft.ConfigBC;
import rtg.config.flowercraft.ConfigFC;
Expand All @@ -21,6 +22,7 @@ public class ConfigManager {
public static File bcConfigFile;
public static File hlConfigFile;
public static File acConfigFile;
public static File aotdConfigFile;
public static File msConfigFile;
public static File fcConfigFile;

Expand All @@ -35,6 +37,7 @@ public static void init(String configpath) {
bcConfigFile = new File(configpath + "biomes/buildcraft.cfg");
hlConfigFile = new File(configpath + "biomes/highlands.cfg");
acConfigFile = new File(configpath + "biomes/abyssalcraft.cfg");
aotdConfigFile = new File(configpath + "biomes/afraidofthedark.cfg");
msConfigFile = new File(configpath + "biomes/minestrappolation.cfg");
fcConfigFile = new File(configpath + "biomes/flowercraft.cfg");

Expand All @@ -47,6 +50,7 @@ public static void init(String configpath) {
ConfigBC.init(bcConfigFile);
ConfigHL.init(hlConfigFile);
ConfigAC.init(acConfigFile);
ConfigAOTD.init(aotdConfigFile);
ConfigMS.init(msConfigFile);
ConfigFC.init(fcConfigFile);
}
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/rtg/config/afraidofthedark/ConfigAOTD.java
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();
}
}
}
}
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);
}
}
}
}
}
}
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);
}
}
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);
}
}
}
}
}
}
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);
}
}

0 comments on commit e6f028a

Please sign in to comment.