Biome weights for BoP biomes are now configurable

This commit is contained in:
Adubbz 2015-03-29 12:09:24 +11:00
parent 75f5a6c2e8
commit ea0500c222
8 changed files with 80 additions and 34 deletions

View File

@ -8,13 +8,18 @@
package biomesoplenty.api.biome;
import java.util.HashMap;
import java.util.Map;
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeManager.BiomeType;
public class BOPBiome extends BiomeGenBase implements IExtendedBiome
{
private GenerationManager generationManager = new GenerationManager();
private Map<BiomeType, Integer> weightMap = new HashMap<BiomeType, Integer>();
public BOPBiome()
{
super(-1, false);
@ -38,4 +43,22 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
{
return this.generationManager;
}
@Override
public Map<BiomeType, Integer> getWeightMap()
{
return this.weightMap;
}
@Override
public void addWeight(BiomeType type, int weight)
{
this.weightMap.put(type, weight);
}
@Override
public void clearWeights()
{
this.weightMap.clear();
}
}

View File

@ -8,10 +8,16 @@
package biomesoplenty.api.biome;
import java.util.Map;
import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
public interface IExtendedBiome
{
public BiomeOwner getBiomeOwner();
public GenerationManager getGenerationManager();
public Map<BiomeType, Integer> getWeightMap();
public void clearWeights();
public void addWeight(BiomeType type, int weight);
}

View File

@ -16,6 +16,7 @@ import biomesoplenty.api.biome.BiomeOwner;
import biomesoplenty.api.biome.IExtendedBiome;
import biomesoplenty.api.biome.IGenerator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeManager.BiomeType;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate;
public class ExtendedBiomeRegistry
@ -48,8 +49,9 @@ public class ExtendedBiomeRegistry
public static class BiomeExtension implements IExtendedBiome
{
public BiomeGenBase biome;
public final BiomeGenBase biome;
private GenerationManager generationManager = new GenerationManager();
private Map<BiomeType, Integer> weightMap = new HashMap<BiomeType, Integer>();
private BiomeExtension(BiomeGenBase biome)
{
@ -67,6 +69,24 @@ public class ExtendedBiomeRegistry
{
return this.generationManager;
}
@Override
public Map<BiomeType, Integer> getWeightMap()
{
return this.weightMap;
}
@Override
public void addWeight(BiomeType type, int weight)
{
this.weightMap.put(type, weight);
}
@Override
public void clearWeights()
{
this.weightMap.clear();
}
}
public static class GenerationManager

View File

@ -9,6 +9,7 @@
package biomesoplenty.common.biome.overworld;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.BOPBiome;
public class BiomeGenAlps extends BOPBiome
@ -24,5 +25,7 @@ public class BiomeGenAlps extends BOPBiome
this.topBlock = Blocks.snow.getDefaultState();
this.fillerBlock = Blocks.snow.getDefaultState();
this.addWeight(BiomeType.ICY, 5);
}
}

View File

@ -16,6 +16,9 @@ import java.util.Map.Entry;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenCactus;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.common.BiomeManager.BiomeType;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate;
import org.apache.commons.io.FileUtils;
@ -118,6 +121,26 @@ public class BiomeConfigurationHandler
}
}
Map<BiomeType, Integer> weightMap = jsonBiome.weights;
//Removes the default weights set by us as they are about to be set from the config file
extendedBiome.clearWeights();
//TODO: Add a system for making Vanilla biome weights configurable. This won't necessarily be in this class, however it's worth noting.
for (Entry<BiomeType, Integer> entry : weightMap.entrySet())
{
if (entry != null)
{
BiomeType biomeType = entry.getKey();
int weight = entry.getValue();
//Updates the biome's weights to be in line with the config file
extendedBiome.addWeight(biomeType, weight);
//TODO: Change to use our biome manager rather than Vanilla's
BiomeManager.addBiome(biomeType, new BiomeEntry(biome, weight));
}
}
biome.biomeName = jsonBiome.biomeName;
biome.topBlock = jsonBiome.topBlock;
biome.fillerBlock = jsonBiome.fillerBlock;

View File

@ -1,27 +0,0 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.event;
import net.minecraft.client.renderer.BlockModelShapes;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* Called upon the construction of BlockModelShapes after the registration of
* Vanilla blocks. This event should be used as an opportunity to register any
* custom state mappings for modded blocks.
*/
public class BlockModelRegisterEvent extends Event
{
public final BlockModelShapes modelShapes;
public BlockModelRegisterEvent(BlockModelShapes modelShapes)
{
this.modelShapes = modelShapes;
}
}

View File

@ -35,11 +35,6 @@ public class ModBiomes
private static void registerBiomes()
{
alps = registerBiome(new BiomeGenAlps().setBiomeName("Alps"), "alps");
BiomeManager.addBiome(BiomeType.DESERT, new BiomeEntry(alps, 100));
BiomeManager.addBiome(BiomeType.WARM, new BiomeEntry(alps, 100));
BiomeManager.addBiome(BiomeType.COOL, new BiomeEntry(alps, 100));
BiomeManager.addBiome(BiomeType.ICY, new BiomeEntry(alps, 100));
}
private static void registerExternalBiomes()

View File

@ -13,6 +13,7 @@ import java.util.Map;
import net.minecraft.block.state.IBlockState;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.IExtendedBiome;
import biomesoplenty.api.biome.IGenerator;
import biomesoplenty.common.biome.ExtendedBiomeRegistry;
@ -28,6 +29,7 @@ public class JsonBiome
public String biomeName;
public int biomeId;
public Map<BiomeType, Integer> weights;
public IBlockState topBlock;
public IBlockState fillerBlock;
public float rootHeight;
@ -61,6 +63,7 @@ public class JsonBiome
{
GenerationManager generationManager = extendedBiome.getGenerationManager();
biome.weights = extendedBiome.getWeightMap();
biome.decoration = generationManager.getGeneratorMap();
}