Beginning work on the coral reef

This commit is contained in:
Adubbz 2014-05-19 10:35:23 +10:00
parent ed7836c193
commit 91593111d2
12 changed files with 298 additions and 6 deletions

View File

@ -15,6 +15,7 @@ public class BOPBiomeManager
public static List<BiomeEntry>[] overworldBiomes = new ArrayList[4];
public static List<BiomeEntry>[] overworldSubBiomes = new ArrayList[BiomeGenBase.getBiomeGenArray().length];
public static List<Integer> overworldOceanBiomes = new ArrayList();
public static BiomeGenBase[] overworldRiverBiomes = new BiomeGenBase[BiomeGenBase.getBiomeGenArray().length];
public static List<BiomeEntry> netherBiomes = new ArrayList();
@ -77,6 +78,11 @@ public class BOPBiomeManager
return -1;
}
public static boolean isBiomeOceanic(int biomeId)
{
return overworldOceanBiomes.contains(biomeId);
}
private static int getConfiguredWeight(BiomeGenBase biome, String biomeType, int weight)
{
return BOPConfigurationBiomeWeights.config.get(biomeType + " Biome Weights", biome.biomeName, weight).getInt(weight);

View File

@ -74,6 +74,7 @@ public class BOPCBiomes
public static BiomeGenBase canyonRavine;
//Ocean Biomes
public static BiomeGenBase coralReef;
public static BiomeGenBase kelpForest;
//Nether Biomes

View File

@ -0,0 +1,16 @@
package biomesoplenty.common.biomes;
import net.minecraft.world.biome.BiomeGenBase;
import biomesoplenty.api.BOPBiomeManager;
public abstract class BOPOceanBiome extends BOPSubBiome
{
public BOPOceanBiome(int biomeID)
{
super(biomeID);
BOPBiomeManager.overworldOceanBiomes.add(this.biomeID);
this.spawnableCreatureList.clear();
}
}

View File

@ -0,0 +1,50 @@
package biomesoplenty.common.biomes.overworld.ocean;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase.Height;
import biomesoplenty.api.BOPBlockHelper;
import biomesoplenty.common.biomes.BOPOceanBiome;
public class BiomeGenCoralReef extends BOPOceanBiome
{
private static final Height biomeHeight = new Height(-1.0F, 0.1F);
public BiomeGenCoralReef(int biomeID)
{
super(biomeID);
this.zoom = 0.5D;
this.threshold = 0D;
this.setHeight(biomeHeight);
this.setColor(18285);
this.setTemperatureRainfall(0.5F, 0.9F);
this.bopWorldFeatures.setFeature("coralPerChunk", 300);
}
@Override
public void decorate(World world, Random random, int chunkX, int chunkZ)
{
super.decorate(world, random, chunkX, chunkZ);
int var5 = 12 + random.nextInt(6);
for (int var6 = 0; var6 < var5; ++var6)
{
int x = chunkX + random.nextInt(16);
int y = random.nextInt(28) + 4;
int z = chunkZ + random.nextInt(16);
Block block = world.getBlock(x, y, z);
if (block != null && block.isReplaceableOreGen(world, x, y, z, Blocks.stone))
{
world.setBlock(x, y, z, BOPBlockHelper.get("gemOre"), 12, 2);
}
}
}
}

View File

@ -77,6 +77,7 @@ import biomesoplenty.common.biomes.overworld.BiomeGenTundra;
import biomesoplenty.common.biomes.overworld.BiomeGenWasteland;
import biomesoplenty.common.biomes.overworld.BiomeGenWetland;
import biomesoplenty.common.biomes.overworld.BiomeGenWoodland;
import biomesoplenty.common.biomes.overworld.ocean.BiomeGenCoralReef;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenAlpsForest;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenCanyonRavine;
import biomesoplenty.common.biomes.overworld.sub.BiomeGenGlacier;
@ -200,6 +201,7 @@ public class BOPBiomes
canyonRavine = registerOverworldSubBiome(BiomeGenCanyonRavine.class, "Canyon Ravine", 10, canyon.biomeID);
//Ocean Biomes
coralReef = registerOverworldSubBiome(BiomeGenCoralReef.class, "Coral Reef", 10, BiomeGenBase.ocean.biomeID);
volcano = registerOverworldSubBiome(BiomeGenVolcano.class, "Volcano", 10, BiomeGenBase.deepOcean.biomeID);
tropics = registerOverworldSubBiome(BiomeGenTropics.class, "Tropics", 10, BiomeGenBase.deepOcean.biomeID);

View File

@ -30,9 +30,9 @@ public class BOPFluids
private static void registerFluids()
{
registerFluid(poison = new PoisonFluid("poison").setBlock(BOPBlockHelper.get("poison")));
registerFluid(spring_water = new SpringWaterFluid("spring_water").setBlock(BOPBlockHelper.get("springWater")));
registerFluid(honey = new HoneyFluid("honey").setBlock(BOPBlockHelper.get("honey")));
registerFluid(poison = new PoisonFluid("poison"));
registerFluid(spring_water = new SpringWaterFluid("spring_water"));
registerFluid(honey = new HoneyFluid("honey"));
}
private static void registerFluidBlocks()
@ -40,6 +40,10 @@ public class BOPFluids
registerBlock(new BlockPoisonFluid().setBlockName("poison"));
registerBlock(new BlockSpringWaterFluid().setBlockName("springWater"));
registerBlock(new BlockHoneyFluid().setBlockName("honey"));
poison.setBlock(BOPBlockHelper.get("poison"));
spring_water.setBlock(BOPBlockHelper.get("springWater"));
honey.setBlock(BOPBlockHelper.get("honey"));
}
private static void registerFluidItems()

View File

@ -45,7 +45,6 @@ public class BOPWorldFeatures
addFeature("shrubsPerChunk", 0);
addFeature("bushesPerChunk", 0);
addFeature("cloverPatchesPerChunk", 0);
addFeature("seaweedPerChunk", 0);
addFeature("leafPilesPerChunk", 0);
addFeature("deadLeafPilesPerChunk", 0);
addFeature("lavenderPerChunk", 0);
@ -90,6 +89,10 @@ public class BOPWorldFeatures
addFeature("glowshroomsPerChunk", 0);
addFeature("bopBigMushroomsPerChunk", 0);
//Ocean Features
addFeature("seaweedPerChunk", 0);
addFeature("coralPerChunk", 0);
//Nether Features
addFeature("waspHivesPerChunk", 0);
addFeature("boneSpinesUpPerChunk", 0);

View File

@ -14,6 +14,7 @@ public class WorldGenBOPCoral extends WorldGeneratorBOP
{
public Block flora;
public int floraMeta;
private boolean randomMeta;
private int groupCount = 64;
public WorldGenBOPCoral() {}
@ -22,6 +23,7 @@ public class WorldGenBOPCoral extends WorldGeneratorBOP
{
this.flora = flora;
this.floraMeta = floraMeta;
this.randomMeta = this.floraMeta == -1;
}
public WorldGenBOPCoral(Block flora, int floraMeta, int groupCount)
@ -29,6 +31,7 @@ public class WorldGenBOPCoral extends WorldGeneratorBOP
this.flora = flora;
this.floraMeta = floraMeta;
this.groupCount = groupCount;
this.randomMeta = this.floraMeta == -1;
}
@Override
@ -40,6 +43,8 @@ public class WorldGenBOPCoral extends WorldGeneratorBOP
int j1 = y + random.nextInt(4) - random.nextInt(4);
int k1 = z + random.nextInt(8) - random.nextInt(8);
if (randomMeta) floraMeta = 12 + random.nextInt(4);
if (world.getBlock(i1, j1, k1) == Blocks.water && world.getBlock(i1, j1 + 1, k1) == Blocks.water && (!world.provider.hasNoSky || j1 < 255) &&
this.flora.canReplace(world, i1, j1, k1, 0, new ItemStack(flora, 1, floraMeta)))
{

View File

@ -0,0 +1,25 @@
package biomesoplenty.common.world.features;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import biomesoplenty.common.world.generation.WorldGeneratorBOP;
public class WorldGenKelp extends WorldGeneratorBOP
{
@Override
public boolean generate(World world, Random rand, int x, int y, int z)
{
return false;
}
@Override
public void setupGeneration(World world, Random random, BiomeGenBase biome, String featureName, int x, int z)
{
// TODO Auto-generated method stub
}
}

View File

@ -75,7 +75,6 @@ public class WorldGenFieldAssociation
associateFeature("desertSproutsPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("plants"), 2));
associateFeature("bromeliadsPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("flowers"), 12));
associateFeature("waterReedsPerChunk", new WorldGenWaterReeds());
associateFeature("seaweedPerChunk", new WorldGenBOPCoral(BOPBlockHelper.get("coral2"), 8, 256));
associateFeature("wildCarrotsPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("plants"), 11));
associateFeature("poisonIvyPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("foliage"), 7));
associateFeature("berryBushesPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("foliage"), 8));
@ -111,6 +110,10 @@ public class WorldGenFieldAssociation
associateFeature("glowshroomsPerChunk", new WorldGenBOPFlora(BOPBlockHelper.get("mushrooms"), 3));
associateFeature("bopBigMushroomsPerChunk", new WorldGenBOPBigMushroom(Blocks.dirt, Blocks.grass, Blocks.mycelium, BOPBlockHelper.get("overgrownNetherrack")));
//Ocean Features
associateFeature("seaweedPerChunk", new WorldGenBOPCoral(BOPBlockHelper.get("coral2"), 8, 256));
associateFeature("coralPerChunk", new WorldGenBOPCoral(BOPBlockHelper.get("coral1"), -1));
//Nether Features
associateFeature("waspHivesPerChunk", new WorldGenWaspHive());
associateFeature("boneSpinesUpPerChunk", new WorldGenBoneSpine(false));

View File

@ -83,7 +83,7 @@ public abstract class GenLayerBOP extends GenLayer
if (j == 1)
{
object = new GenLayerShore(1000L, (GenLayer)object);
object = new GenLayerShoreBOP(1000L, (GenLayer)object);
}
}

View File

@ -0,0 +1,177 @@
package biomesoplenty.common.world.layer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenJungle;
import net.minecraft.world.biome.BiomeGenMesa;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;
import biomesoplenty.api.BOPBiomeManager;
public class GenLayerShoreBOP extends GenLayer
{
public GenLayerShoreBOP(long seed, GenLayer parent)
{
super(seed);
this.parent = parent;
}
@Override
public int[] getInts(int x, int z, int width, int length)
{
int[] inputBiomeIds = this.parent.getInts(x - 1, z - 1, width + 2, length + 2);
int[] outputBiomeIds = IntCache.getIntCache(width * length);
for (int i1 = 0; i1 < length; ++i1)
{
for (int j1 = 0; j1 < width; ++j1)
{
this.initChunkSeed((long)(j1 + x), (long)(i1 + z));
int landBiomeId = inputBiomeIds[j1 + 1 + (i1 + 1) * (width + 2)];
BiomeGenBase biomegenbase = BiomeGenBase.getBiome(landBiomeId);
int l1;
int i2;
int j2;
int k2;
if (landBiomeId == BiomeGenBase.mushroomIsland.biomeID)
{
l1 = inputBiomeIds[j1 + 1 + (i1 + 1 - 1) * (width + 2)];
i2 = inputBiomeIds[j1 + 1 + 1 + (i1 + 1) * (width + 2)];
j2 = inputBiomeIds[j1 + 1 - 1 + (i1 + 1) * (width + 2)];
k2 = inputBiomeIds[j1 + 1 + (i1 + 1 + 1) * (width + 2)];
if (l1 != BiomeGenBase.ocean.biomeID && i2 != BiomeGenBase.ocean.biomeID && j2 != BiomeGenBase.ocean.biomeID && k2 != BiomeGenBase.ocean.biomeID)
{
outputBiomeIds[j1 + i1 * width] = landBiomeId;
}
else
{
outputBiomeIds[j1 + i1 * width] = BiomeGenBase.mushroomIslandShore.biomeID;
}
}
else if (biomegenbase != null && biomegenbase.getBiomeClass() == BiomeGenJungle.class)
{
l1 = inputBiomeIds[j1 + 1 + (i1 + 1 - 1) * (width + 2)];
i2 = inputBiomeIds[j1 + 1 + 1 + (i1 + 1) * (width + 2)];
j2 = inputBiomeIds[j1 + 1 - 1 + (i1 + 1) * (width + 2)];
k2 = inputBiomeIds[j1 + 1 + (i1 + 1 + 1) * (width + 2)];
if (this.func_151631_c(l1) && this.func_151631_c(i2) && this.func_151631_c(j2) && this.func_151631_c(k2))
{
if (!isBiomeOceanic(l1) && !isBiomeOceanic(i2) && !isBiomeOceanic(j2) && !isBiomeOceanic(k2))
{
outputBiomeIds[j1 + i1 * width] = landBiomeId;
}
else
{
outputBiomeIds[j1 + i1 * width] = BiomeGenBase.beach.biomeID;
}
}
else
{
outputBiomeIds[j1 + i1 * width] = BiomeGenBase.jungleEdge.biomeID;
}
}
else if (landBiomeId != BiomeGenBase.extremeHills.biomeID && landBiomeId != BiomeGenBase.extremeHillsPlus.biomeID && landBiomeId != BiomeGenBase.extremeHillsEdge.biomeID)
{
if (biomegenbase != null && biomegenbase.func_150559_j())
{
this.func_151632_a(inputBiomeIds, outputBiomeIds, j1, i1, width, landBiomeId, BiomeGenBase.coldBeach.biomeID);
}
else if (landBiomeId != BiomeGenBase.mesa.biomeID && landBiomeId != BiomeGenBase.mesaPlateau_F.biomeID)
{
if (!BOPBiomeManager.isBiomeOceanic(landBiomeId) && landBiomeId != BiomeGenBase.ocean.biomeID && landBiomeId != BiomeGenBase.deepOcean.biomeID && landBiomeId != BiomeGenBase.river.biomeID && landBiomeId != BiomeGenBase.swampland.biomeID)
{
l1 = inputBiomeIds[j1 + 1 + (i1 + 1 - 1) * (width + 2)];
i2 = inputBiomeIds[j1 + 1 + 1 + (i1 + 1) * (width + 2)];
j2 = inputBiomeIds[j1 + 1 - 1 + (i1 + 1) * (width + 2)];
k2 = inputBiomeIds[j1 + 1 + (i1 + 1 + 1) * (width + 2)];
if (!isBiomeOceanic(l1) && !isBiomeOceanic(i2) && !isBiomeOceanic(j2) && !isBiomeOceanic(k2))
{
outputBiomeIds[j1 + i1 * width] = landBiomeId;
}
else
{
outputBiomeIds[j1 + i1 * width] = BiomeGenBase.beach.biomeID;
}
}
else
{
outputBiomeIds[j1 + i1 * width] = landBiomeId;
}
}
else
{
l1 = inputBiomeIds[j1 + 1 + (i1 + 1 - 1) * (width + 2)];
i2 = inputBiomeIds[j1 + 1 + 1 + (i1 + 1) * (width + 2)];
j2 = inputBiomeIds[j1 + 1 - 1 + (i1 + 1) * (width + 2)];
k2 = inputBiomeIds[j1 + 1 + (i1 + 1 + 1) * (width + 2)];
if (!isBiomeOceanic(l1) && !isBiomeOceanic(i2) && !isBiomeOceanic(j2) && !isBiomeOceanic(k2))
{
if (this.func_151633_d(l1) && this.func_151633_d(i2) && this.func_151633_d(j2) && this.func_151633_d(k2))
{
outputBiomeIds[j1 + i1 * width] = landBiomeId;
}
else
{
outputBiomeIds[j1 + i1 * width] = BiomeGenBase.desert.biomeID;
}
}
else
{
outputBiomeIds[j1 + i1 * width] = landBiomeId;
}
}
}
else
{
this.func_151632_a(inputBiomeIds, outputBiomeIds, j1, i1, width, landBiomeId, BiomeGenBase.stoneBeach.biomeID);
}
}
}
return outputBiomeIds;
}
private void func_151632_a(int[] inputBiomeIds, int[] outputBiomeIds, int x, int z, int width, int landBiomeId, int beachBiomeId)
{
if (isBiomeOceanic(landBiomeId))
{
outputBiomeIds[x + z * width] = landBiomeId;
}
else
{
int j1 = inputBiomeIds[x + 1 + (z + 1 - 1) * (width + 2)];
int k1 = inputBiomeIds[x + 1 + 1 + (z + 1) * (width + 2)];
int l1 = inputBiomeIds[x + 1 - 1 + (z + 1) * (width + 2)];
int i2 = inputBiomeIds[x + 1 + (z + 1 + 1) * (width + 2)];
if (!isBiomeOceanic(j1) && !isBiomeOceanic(k1) && !isBiomeOceanic(l1) && !isBiomeOceanic(i2))
{
outputBiomeIds[x + z * width] = landBiomeId;
}
else
{
outputBiomeIds[x + z * width] = beachBiomeId;
}
}
}
protected static boolean isBiomeOceanic(int biomeId)
{
return BOPBiomeManager.isBiomeOceanic(biomeId) || GenLayer.isBiomeOceanic(biomeId);
}
private boolean func_151631_c(int p_151631_1_)
{
return BiomeGenBase.getBiome(p_151631_1_) != null && BiomeGenBase.getBiome(p_151631_1_).getBiomeClass() == BiomeGenJungle.class ? true : p_151631_1_ == BiomeGenBase.jungleEdge.biomeID || p_151631_1_ == BiomeGenBase.jungle.biomeID || p_151631_1_ == BiomeGenBase.jungleHills.biomeID || p_151631_1_ == BiomeGenBase.forest.biomeID || p_151631_1_ == BiomeGenBase.taiga.biomeID || isBiomeOceanic(p_151631_1_);
}
private boolean func_151633_d(int p_151633_1_)
{
return BiomeGenBase.getBiome(p_151633_1_) != null && BiomeGenBase.getBiome(p_151633_1_) instanceof BiomeGenMesa;
}
}