The BoP WorldType once again functions correctly

This commit is contained in:
Adubbz 2015-03-29 15:17:17 +11:00
parent ea0500c222
commit f0ada0dc81
4 changed files with 75 additions and 7 deletions

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* 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.common.biome;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.common.BiomeManager.BiomeType;
public class BOPBiomeManager
{
private static ArrayList<BiomeEntry>[] biomes = new ArrayList[4];
static
{
for (int i = 0; i < biomes.length; i++)
{
biomes[i] = new ArrayList();
}
}
public static void addBiome(BiomeType type, BiomeEntry entry)
{
int idx = type.ordinal();
List<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
if (list != null) list.add(entry);
}
public static ImmutableList<BiomeEntry> getBiomes(BiomeType type)
{
int idx = type.ordinal();
List<BiomeEntry> list = idx > biomes.length ? null : biomes[idx];
return list != null ? ImmutableList.copyOf(list) : null;
}
}

View file

@ -15,21 +15,18 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.minecraft.world.biome.BiomeGenBase; 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.BiomeEntry;
import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.common.BiomeManager.BiomeType;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import biomesoplenty.api.biome.BiomeOwner; import biomesoplenty.api.biome.BiomeOwner;
import biomesoplenty.api.biome.IExtendedBiome; import biomesoplenty.api.biome.IExtendedBiome;
import biomesoplenty.common.biome.BOPBiomeManager;
import biomesoplenty.common.biome.ExtendedBiomeRegistry; 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;
@ -136,8 +133,7 @@ public class BiomeConfigurationHandler
//Updates the biome's weights to be in line with the config file //Updates the biome's weights to be in line with the config file
extendedBiome.addWeight(biomeType, weight); extendedBiome.addWeight(biomeType, weight);
//TODO: Change to use our biome manager rather than Vanilla's BOPBiomeManager.addBiome(biomeType, new BiomeEntry(biome, weight));
BiomeManager.addBiome(biomeType, new BiomeEntry(biome, weight));
} }
} }

View file

@ -10,12 +10,15 @@ package biomesoplenty.common.util.config;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
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 net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.IExtendedBiome; import biomesoplenty.api.biome.IExtendedBiome;
import biomesoplenty.api.biome.IGenerator; import biomesoplenty.api.biome.IGenerator;
import biomesoplenty.common.biome.BOPBiomeManager;
import biomesoplenty.common.biome.ExtendedBiomeRegistry; import biomesoplenty.common.biome.ExtendedBiomeRegistry;
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager; import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
@ -65,6 +68,18 @@ public class JsonBiome
biome.weights = extendedBiome.getWeightMap(); biome.weights = extendedBiome.getWeightMap();
biome.decoration = generationManager.getGeneratorMap(); biome.decoration = generationManager.getGeneratorMap();
//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 : extendedBiome.getWeightMap().entrySet())
{
if (entry != null)
{
BiomeType biomeType = entry.getKey();
int weight = entry.getValue();
BOPBiomeManager.addBiome(biomeType, new BiomeEntry(baseBiome, weight));
}
}
} }
return biome; return biome;

View file

@ -13,6 +13,7 @@ import static net.minecraftforge.common.BiomeManager.BiomeType.DESERT;
import static net.minecraftforge.common.BiomeManager.BiomeType.ICY; import static net.minecraftforge.common.BiomeManager.BiomeType.ICY;
import static net.minecraftforge.common.BiomeManager.BiomeType.WARM; import static net.minecraftforge.common.BiomeManager.BiomeType.WARM;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandom;
@ -24,6 +25,9 @@ import net.minecraft.world.gen.layer.IntCache;
import net.minecraftforge.common.BiomeManager; import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeEntry; import net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.ReflectionHelper;
import biomesoplenty.common.biome.BOPBiomeManager;
import com.google.common.collect.ImmutableList;
public class GenLayerBiomeBOP extends GenLayerBiome public class GenLayerBiomeBOP extends GenLayerBiome
{ {
@ -36,6 +40,14 @@ public class GenLayerBiomeBOP extends GenLayerBiome
biomes = ReflectionHelper.getPrivateValue(GenLayerBiome.class, this, "biomes"); biomes = ReflectionHelper.getPrivateValue(GenLayerBiome.class, this, "biomes");
//TODO: Use vanilla biome weights //TODO: Use vanilla biome weights
for (BiomeManager.BiomeType type : BiomeManager.BiomeType.values())
{
ImmutableList<BiomeEntry> biomesToAdd = BOPBiomeManager.getBiomes(type);
int idx = type.ordinal();
if (biomes[idx] == null) biomes[idx] = new ArrayList<BiomeEntry>();
if (biomesToAdd != null) biomes[idx].addAll(biomesToAdd);
}
} }
@Override @Override