Added support for island biomes
This commit is contained in:
parent
0c370f4f98
commit
75f50a80a4
3 changed files with 87 additions and 1 deletions
|
@ -173,6 +173,7 @@ import biomesoplenty.common.biome.vanilla.BiomeExtSwampland;
|
|||
import biomesoplenty.common.biome.vanilla.BiomeExtTaiga;
|
||||
import biomesoplenty.common.command.BOPCommand;
|
||||
import biomesoplenty.common.enums.BOPClimates;
|
||||
import biomesoplenty.common.enums.BOPClimates.WeightedBiomeEntry;
|
||||
import biomesoplenty.common.util.biome.BiomeUtils;
|
||||
import biomesoplenty.common.util.config.BOPConfig;
|
||||
import biomesoplenty.common.world.WorldTypeBOP;
|
||||
|
@ -196,7 +197,10 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
|
|||
public static Set<BiomeGenBase> presentBiomes;
|
||||
public static Map<Integer, List<Integer>> subBiomesMap;
|
||||
public static Map<Integer, List<Integer>> mutatedBiomesMap;
|
||||
|
||||
|
||||
public static ArrayList<WeightedBiomeEntry> islandBiomesList = new ArrayList<WeightedBiomeEntry>();
|
||||
public static int totalIslandBiomesWeight;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
worldTypeBOP = new WorldTypeBOP();
|
||||
|
@ -398,6 +402,8 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
|
|||
setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.coral_reef);
|
||||
setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.kelp_forest);
|
||||
|
||||
// island biomes
|
||||
|
||||
}
|
||||
|
||||
private static void registerBiomeDictionaryTags()
|
||||
|
@ -568,6 +574,12 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
private static void addIslandBiome(BiomeGenBase biome, int weight)
|
||||
{
|
||||
totalIslandBiomesWeight += weight;
|
||||
islandBiomesList.add(new WeightedBiomeEntry(weight, biome));
|
||||
}
|
||||
|
||||
private static void configureBiome(IExtendedBiome biome, String idName)
|
||||
{
|
||||
File configFile = new File(new File(BiomesOPlenty.configDirectory, "biomes"), idName + ".json");
|
||||
|
|
|
@ -19,6 +19,7 @@ import biomesoplenty.common.world.layer.GenLayerBiomeEdgeBOP;
|
|||
import biomesoplenty.common.world.layer.GenLayerBiomeIslands;
|
||||
import biomesoplenty.common.world.layer.GenLayerClimate;
|
||||
import biomesoplenty.common.world.layer.GenLayerIslandBOP;
|
||||
import biomesoplenty.common.world.layer.GenLayerLargeIsland;
|
||||
import biomesoplenty.common.world.layer.GenLayerRaggedEdges;
|
||||
import biomesoplenty.common.world.layer.GenLayerRainfallNoise;
|
||||
import biomesoplenty.common.world.layer.GenLayerRainfallRandom;
|
||||
|
@ -239,6 +240,7 @@ public class WorldChunkManagerBOP extends WorldChunkManager
|
|||
|
||||
// add mushroom islands and deep oceans
|
||||
mainBranch = new GenLayerAddMushroomIsland(5L, mainBranch);
|
||||
mainBranch = new GenLayerLargeIsland(5L, mainBranch);
|
||||
mainBranch = new GenLayerDeepOcean(4L, mainBranch);
|
||||
|
||||
// fork off a new branch as a seed for rivers and sub biomes
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2016, 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.world.layer;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import biomesoplenty.common.enums.BOPClimates.WeightedBiomeEntry;
|
||||
import biomesoplenty.common.init.ModBiomes;
|
||||
import net.minecraft.world.gen.layer.GenLayer;
|
||||
import net.minecraft.world.gen.layer.IntCache;
|
||||
|
||||
public class GenLayerLargeIsland extends BOPGenLayer
|
||||
{
|
||||
public GenLayerLargeIsland(long seed, GenLayer parent)
|
||||
{
|
||||
super(seed);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight)
|
||||
{
|
||||
int outerWidth = areaWidth + 2;
|
||||
|
||||
int[] biomeIds = this.parent.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2);
|
||||
int[] out = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int z = 0; z < areaHeight; ++z)
|
||||
{
|
||||
for (int x = 0; x < areaWidth; ++x)
|
||||
{
|
||||
int northWestVal = biomeIds[x + 0 + (z + 0) * outerWidth];
|
||||
int northEastVal = biomeIds[x + 2 + (z + 0) * outerWidth];
|
||||
int southWestVal = biomeIds[x + 0 + (z + 2) * outerWidth];
|
||||
int southEastVal = biomeIds[x + 2 + (z + 2) * outerWidth];
|
||||
int centerVal = biomeIds[x + 1 + (z + 1) * outerWidth];
|
||||
|
||||
this.initChunkSeed((long)(x + areaX), (long)(z + areaY));
|
||||
|
||||
if (centerVal == 0 && northWestVal == 0 && northEastVal == 0 && southWestVal == 0 && southEastVal == 0 && this.nextInt(50) == 0)
|
||||
{
|
||||
out[x + z * areaWidth] = getRandomIslandBiome();
|
||||
}
|
||||
else
|
||||
{
|
||||
out[x + z * areaWidth] = centerVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public int getRandomIslandBiome()
|
||||
{
|
||||
int weight = this.nextInt(ModBiomes.totalIslandBiomesWeight);
|
||||
Iterator<WeightedBiomeEntry> iterator = ModBiomes.islandBiomesList.iterator();
|
||||
WeightedBiomeEntry item;
|
||||
do
|
||||
{
|
||||
item = iterator.next();
|
||||
weight -= item.weight;
|
||||
}
|
||||
while (weight >= 0);
|
||||
return item.biome.biomeID;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue