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 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;
import biomesoplenty.api.biome.BiomeOwner;
import biomesoplenty.api.biome.IExtendedBiome;
import biomesoplenty.common.biome.BOPBiomeManager;
import biomesoplenty.common.biome.ExtendedBiomeRegistry;
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
import biomesoplenty.common.util.config.JsonBiome;
import biomesoplenty.common.util.config.JsonEntitySpawn;
import biomesoplenty.core.BiomesOPlenty;
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
extendedBiome.addWeight(biomeType, weight);
//TODO: Change to use our biome manager rather than Vanilla's
BiomeManager.addBiome(biomeType, new BiomeEntry(biome, weight));
BOPBiomeManager.addBiome(biomeType, new BiomeEntry(biome, weight));
}
}

View File

@ -10,12 +10,15 @@ package biomesoplenty.common.util.config;
import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.block.state.IBlockState;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.IExtendedBiome;
import biomesoplenty.api.biome.IGenerator;
import biomesoplenty.common.biome.BOPBiomeManager;
import biomesoplenty.common.biome.ExtendedBiomeRegistry;
import biomesoplenty.common.biome.ExtendedBiomeRegistry.GenerationManager;
@ -65,6 +68,18 @@ public class JsonBiome
biome.weights = extendedBiome.getWeightMap();
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;

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.WARM;
import java.util.ArrayList;
import java.util.List;
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.BiomeEntry;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import biomesoplenty.common.biome.BOPBiomeManager;
import com.google.common.collect.ImmutableList;
public class GenLayerBiomeBOP extends GenLayerBiome
{
@ -36,6 +40,14 @@ public class GenLayerBiomeBOP extends GenLayerBiome
biomes = ReflectionHelper.getPrivateValue(GenLayerBiome.class, this, "biomes");
//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
@ -43,7 +55,7 @@ public class GenLayerBiomeBOP extends GenLayerBiome
{
int[] inputBiomeIds = this.parent.getInts(areaX, areaY, areaWidth, areaHeight);
int[] outputBiomeIds = IntCache.getIntCache(areaWidth * areaHeight);
for (int x = 0; x < areaHeight; ++x)
{
for (int z = 0; z < areaWidth; ++z)