Added the basic framework for adding new biomes
This commit is contained in:
parent
ef4b82a338
commit
f7649572f0
|
@ -0,0 +1,34 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright 2015, 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.api.biome;
|
||||||
|
|
||||||
|
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
|
||||||
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
|
||||||
|
public class BOPBiome extends BiomeGenBase implements IExtendedBiome
|
||||||
|
{
|
||||||
|
private GenerationManager generationManager = new GenerationManager();
|
||||||
|
|
||||||
|
public BOPBiome(int id)
|
||||||
|
{
|
||||||
|
super(id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeOwner getBiomeOwner()
|
||||||
|
{
|
||||||
|
return BiomeOwner.BIOMESOPLENTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GenerationManager getGenerationManager()
|
||||||
|
{
|
||||||
|
return this.generationManager;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,9 +10,7 @@ package biomesoplenty.api.biome;
|
||||||
|
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
public class BOPBiomes
|
public class BOPBiomes
|
||||||
{
|
{
|
||||||
public static Optional<BiomeGenBase> alps;
|
public static BiomeGenBase alps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ public class ExtendedBiomeRegistry
|
||||||
{
|
{
|
||||||
private static Map<BiomeGenBase, BiomeExtension> externalExtensions = new HashMap();
|
private static Map<BiomeGenBase, BiomeExtension> externalExtensions = new HashMap();
|
||||||
|
|
||||||
|
public static boolean isRegistered(BiomeGenBase biome)
|
||||||
|
{
|
||||||
|
return biome.biomeID != -1;
|
||||||
|
}
|
||||||
|
|
||||||
public static BiomeExtension createExtension(BiomeGenBase biome)
|
public static BiomeExtension createExtension(BiomeGenBase biome)
|
||||||
{
|
{
|
||||||
return externalExtensions.put(biome, new BiomeExtension(biome));
|
return externalExtensions.put(biome, new BiomeExtension(biome));
|
||||||
|
|
|
@ -26,6 +26,7 @@ import biomesoplenty.common.biome.ExtendedBiomeRegistry;
|
||||||
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
|
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
|
||||||
import biomesoplenty.common.util.config.JsonBiome;
|
import biomesoplenty.common.util.config.JsonBiome;
|
||||||
import biomesoplenty.common.util.config.JsonEntitySpawn;
|
import biomesoplenty.common.util.config.JsonEntitySpawn;
|
||||||
|
import biomesoplenty.core.BiomesOPlenty;
|
||||||
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
|
@ -79,12 +80,12 @@ public class BiomeConfigurationHandler
|
||||||
|
|
||||||
public static void translateVanillaValues(BiomeGenBase biome)
|
public static void translateVanillaValues(BiomeGenBase biome)
|
||||||
{
|
{
|
||||||
IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome);
|
/*IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome);
|
||||||
GenerationManager generationManager = extendedBiome.getGenerationManager();
|
GenerationManager generationManager = extendedBiome.getGenerationManager();
|
||||||
|
|
||||||
if (extendedBiome.getBiomeOwner() == BiomeOwner.OTHER)
|
if (extendedBiome.getBiomeOwner() == BiomeOwner.OTHER)
|
||||||
{
|
{
|
||||||
/*if (biome.theBiomeDecorator.cactiPerChunk > 0)
|
if (biome.theBiomeDecorator.cactiPerChunk > 0)
|
||||||
{
|
{
|
||||||
WorldGenCactus cactusGen = new WorldGenCactus();
|
WorldGenCactus cactusGen = new WorldGenCactus();
|
||||||
IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen) cactusGen;
|
IExtendedCactusGen extendedCactusGen = (IExtendedCactusGen) cactusGen;
|
||||||
|
@ -92,27 +93,44 @@ public class BiomeConfigurationHandler
|
||||||
extendedCactusGen.setCactiPerChunk(biome.theBiomeDecorator.cactiPerChunk);
|
extendedCactusGen.setCactiPerChunk(biome.theBiomeDecorator.cactiPerChunk);
|
||||||
generationManager.addGenerator("cactus", extendedCactusGen, Decorate.EventType.CACTUS);
|
generationManager.addGenerator("cactus", extendedCactusGen, Decorate.EventType.CACTUS);
|
||||||
biome.theBiomeDecorator.cactiPerChunk = 0;
|
biome.theBiomeDecorator.cactiPerChunk = 0;
|
||||||
}*/
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void configureBiomeWithJson(BiomeGenBase biome, JsonBiome jsonBiome)
|
private static void configureBiomeWithJson(BiomeGenBase biome, JsonBiome jsonBiome)
|
||||||
{
|
{
|
||||||
// TODO: Reflect and modify biome id biome.biomeId = jsonBiome.biomeID;
|
IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome);
|
||||||
biome.biomeName = jsonBiome.biomeName;
|
|
||||||
biome.topBlock = jsonBiome.topBlock;
|
|
||||||
biome.fillerBlock = jsonBiome.fillerBlock;
|
|
||||||
biome.setHeight(new BiomeGenBase.Height(jsonBiome.rootHeight, jsonBiome.rootVariation));
|
|
||||||
biome.temperature = jsonBiome.temperature;
|
|
||||||
biome.rainfall = jsonBiome.rainfall;
|
|
||||||
// TODO: Reflect and modify enableRain and enableSnow
|
|
||||||
biome.color = jsonBiome.color;
|
|
||||||
biome.waterColorMultiplier = jsonBiome.waterColorMultiplier;
|
|
||||||
JsonEntitySpawn.addBiomeEntitySpawns(biome, jsonBiome);
|
|
||||||
|
|
||||||
GenerationManager generationManager = ExtendedBiomeRegistry.getExtension(biome).getGenerationManager();
|
if (extendedBiome != null)
|
||||||
|
{
|
||||||
generationManager.configureGenerators(jsonBiome.decoration);
|
GenerationManager generationManager = extendedBiome.getGenerationManager();
|
||||||
|
|
||||||
|
if (extendedBiome.getBiomeOwner() == BiomeOwner.BIOMESOPLENTY)
|
||||||
|
{
|
||||||
|
if (jsonBiome.biomeId != -1)
|
||||||
|
{
|
||||||
|
biome.biomeID = jsonBiome.biomeId;
|
||||||
|
BiomeGenBase.getBiomeGenArray()[jsonBiome.biomeId] = biome;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
biome.biomeID = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
biome.biomeName = jsonBiome.biomeName;
|
||||||
|
biome.topBlock = jsonBiome.topBlock;
|
||||||
|
biome.fillerBlock = jsonBiome.fillerBlock;
|
||||||
|
biome.setHeight(new BiomeGenBase.Height(jsonBiome.rootHeight, jsonBiome.rootVariation));
|
||||||
|
biome.temperature = jsonBiome.temperature;
|
||||||
|
biome.rainfall = jsonBiome.rainfall;
|
||||||
|
// TODO: Reflect and modify enableRain and enableSnow
|
||||||
|
biome.color = jsonBiome.color;
|
||||||
|
biome.waterColorMultiplier = jsonBiome.waterColorMultiplier;
|
||||||
|
JsonEntitySpawn.addBiomeEntitySpawns(biome, jsonBiome);
|
||||||
|
|
||||||
|
generationManager.configureGenerators(jsonBiome.decoration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<BiomeGenBase, String> getConfigFileMap()
|
public static Map<BiomeGenBase, String> getConfigFileMap()
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
|
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import biomesoplenty.api.biome.IExtendedBiome;
|
||||||
import biomesoplenty.api.biome.IGenerator;
|
import biomesoplenty.api.biome.IGenerator;
|
||||||
import biomesoplenty.common.biome.ExtendedBiomeRegistry;
|
import biomesoplenty.common.biome.ExtendedBiomeRegistry;
|
||||||
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
|
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
|
||||||
|
@ -27,17 +28,22 @@ public class DecorateBiomeEventHandler
|
||||||
World world = event.world;
|
World world = event.world;
|
||||||
BlockPos pos = event.pos.add(16, 0, 16);
|
BlockPos pos = event.pos.add(16, 0, 16);
|
||||||
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
|
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
|
||||||
GenerationManager generationManager = ExtendedBiomeRegistry.getExtension(biome).getGenerationManager();
|
IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(biome);
|
||||||
|
|
||||||
for (Entry<String, IGenerator<?>> entry : generationManager.getGeneratorMap().entrySet())
|
if (extendedBiome != null)
|
||||||
{
|
{
|
||||||
String key = entry.getKey();
|
GenerationManager generationManager = extendedBiome.getGenerationManager();
|
||||||
IGenerator<?> generator = entry.getValue();
|
|
||||||
|
for (Entry<String, IGenerator<?>> entry : generationManager.getGeneratorMap().entrySet())
|
||||||
if (generationManager.getGeneratorStage(key) == event.type)
|
{
|
||||||
{
|
String key = entry.getKey();
|
||||||
generator.generate(world, event.rand, event.pos);
|
IGenerator<?> generator = entry.getValue();
|
||||||
}
|
|
||||||
|
if (generationManager.getGeneratorStage(key) == event.type)
|
||||||
|
{
|
||||||
|
generator.generate(world, event.rand, event.pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,14 @@ public class ModBiomes
|
||||||
{
|
{
|
||||||
worldTypeBOP = new WorldTypeBOP();
|
worldTypeBOP = new WorldTypeBOP();
|
||||||
|
|
||||||
|
registerBiomes();
|
||||||
registerExternalBiomes();
|
registerExternalBiomes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void registerBiomes()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private static void registerExternalBiomes()
|
private static void registerExternalBiomes()
|
||||||
{
|
{
|
||||||
registerExternalBiome(BiomeGenBase.ocean, "ocean");
|
registerExternalBiome(BiomeGenBase.ocean, "ocean");
|
||||||
|
@ -68,6 +73,13 @@ public class ModBiomes
|
||||||
registerExternalBiome(BiomeGenBase.mesaPlateau, "mesa_plateau");
|
registerExternalBiome(BiomeGenBase.mesaPlateau, "mesa_plateau");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static BiomeGenBase registerBiome(BiomeGenBase biome, String id)
|
||||||
|
{
|
||||||
|
BiomeConfigurationHandler.getConfigFileMap().put(biome, id);
|
||||||
|
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
private static void registerExternalBiome(BiomeGenBase biome, String id)
|
private static void registerExternalBiome(BiomeGenBase biome, String id)
|
||||||
{
|
{
|
||||||
ExtendedBiomeRegistry.createExtension(biome);
|
ExtendedBiomeRegistry.createExtension(biome);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
import biomesoplenty.api.biome.IExtendedBiome;
|
||||||
import biomesoplenty.api.biome.IGenerator;
|
import biomesoplenty.api.biome.IGenerator;
|
||||||
import biomesoplenty.common.biome.ExtendedBiomeRegistry;
|
import biomesoplenty.common.biome.ExtendedBiomeRegistry;
|
||||||
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
|
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
|
||||||
|
@ -54,9 +55,14 @@ public class JsonBiome
|
||||||
biome.waterColorMultiplier = baseBiome.waterColorMultiplier;
|
biome.waterColorMultiplier = baseBiome.waterColorMultiplier;
|
||||||
biome.entities = JsonEntitySpawn.getBiomeEntitySpawns(baseBiome);
|
biome.entities = JsonEntitySpawn.getBiomeEntitySpawns(baseBiome);
|
||||||
|
|
||||||
GenerationManager generationManager = ExtendedBiomeRegistry.getExtension(baseBiome).getGenerationManager();
|
IExtendedBiome extendedBiome = ExtendedBiomeRegistry.getExtension(baseBiome);
|
||||||
|
|
||||||
|
if (extendedBiome != null)
|
||||||
|
{
|
||||||
|
GenerationManager generationManager = extendedBiome.getGenerationManager();
|
||||||
|
|
||||||
biome.decoration = generationManager.getGeneratorMap();
|
biome.decoration = generationManager.getGeneratorMap();
|
||||||
|
}
|
||||||
|
|
||||||
return biome;
|
return biome;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,3 +2,4 @@ public net.minecraft.client.gui.GuiScreen func_146283_a(Ljava/util/List;II)V #dr
|
||||||
public net.minecraft.client.gui.GuiCreateWorld field_146320_D #field_146320_D
|
public net.minecraft.client.gui.GuiCreateWorld field_146320_D #field_146320_D
|
||||||
public net.minecraft.client.gui.GuiCreateWorld field_146331_K #field_146331_K
|
public net.minecraft.client.gui.GuiCreateWorld field_146331_K #field_146331_K
|
||||||
public net.minecraft.world.WorldType func_151358_j()Lnet/minecraft/world/WorldType; #setNotificationData
|
public net.minecraft.world.WorldType func_151358_j()Lnet/minecraft/world/WorldType; #setNotificationData
|
||||||
|
public-f net.minecraft.world.biome.BiomeGenBase field_76756_M #biomeID
|
Loading…
Reference in New Issue