diff --git a/src/main/java/biomesoplenty/api/block/BlockQueries.java b/src/main/java/biomesoplenty/api/block/BlockQueries.java index ce8da46ab..3c370a624 100644 --- a/src/main/java/biomesoplenty/api/block/BlockQueries.java +++ b/src/main/java/biomesoplenty/api/block/BlockQueries.java @@ -18,6 +18,7 @@ public class BlockQueries public static IBlockPosQuery hasWater; public static IBlockPosQuery airAbove; public static IBlockPosQuery airBelow; + public static IBlockPosQuery waterCovered; public static IBlockPosQuery breakable; public static IBlockPosQuery air; public static IBlockPosQuery airOrLeaves; @@ -43,5 +44,4 @@ public class BlockQueries public static IBlockPosQuery underwater; public static IBlockPosQuery suitableForReed; public static IBlockPosQuery rootsCanDigThrough; - } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenCoralReef.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenCoralReef.java index 8865dba13..7663e0698 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenCoralReef.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenCoralReef.java @@ -8,29 +8,18 @@ package biomesoplenty.common.biome.overworld; -import net.minecraft.block.BlockTallGrass; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; -import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; import biomesoplenty.api.biome.BOPBiome; import biomesoplenty.api.biome.generation.GeneratorStage; -import biomesoplenty.api.biome.generation.GeneratorWeighted; import biomesoplenty.api.block.BOPBlocks; +import biomesoplenty.api.block.BlockQueries; import biomesoplenty.common.block.BlockBOPCoral; -import biomesoplenty.common.entities.EntityButterfly; -import biomesoplenty.common.enums.BOPClimates; -import biomesoplenty.common.enums.BOPFlowers; import biomesoplenty.common.enums.BOPGems; -import biomesoplenty.common.enums.BOPPlants; -import biomesoplenty.common.enums.BOPTrees; -import biomesoplenty.common.enums.BOPWoods; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.world.BOPWorldSettings; +import biomesoplenty.common.world.feature.GeneratorColumns; import biomesoplenty.common.world.feature.GeneratorFlora; -import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorOreSingle; -import biomesoplenty.common.world.feature.tree.GeneratorBasicTree; -import biomesoplenty.common.world.feature.tree.GeneratorBigTree; +import net.minecraft.init.Blocks; public class BiomeGenCoralReef extends BOPBiome { @@ -54,6 +43,9 @@ public class BiomeGenCoralReef extends BOPBiome this.addGenerator("glowing_coral", GeneratorStage.LILYPAD, (new GeneratorFlora.Builder()).amountPerChunk(15.0F).replace(Blocks.water).with(BOPBlocks.coral.getDefaultState().withProperty(BlockBOPCoral.VARIANT, BlockBOPCoral.CoralType.GLOWING)).scatterYMethod(ScatterYMethod.AT_GROUND).create()); this.addGenerator("algae", GeneratorStage.LILYPAD, (new GeneratorFlora.Builder()).amountPerChunk(3.0F).replace(Blocks.water).with(BOPBlocks.coral.getDefaultState().withProperty(BlockBOPCoral.VARIANT, BlockBOPCoral.CoralType.ALGAE)).scatterYMethod(ScatterYMethod.AT_GROUND).create()); + // kelp + this.addGenerator("kelp", GeneratorStage.LILYPAD, (new GeneratorColumns.Builder()).replace(BlockQueries.waterCovered).placeOn(BlockQueries.groundBlocks).with(BOPBlocks.seaweed.getDefaultState()).scatterYMethod(ScatterYMethod.AT_GROUND).create()); + // gem this.addGenerator("sapphire", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.SAPPHIRE).create()); } diff --git a/src/main/java/biomesoplenty/common/init/ModBlockQueries.java b/src/main/java/biomesoplenty/common/init/ModBlockQueries.java index 7ad19cb8f..c77e9ed71 100644 --- a/src/main/java/biomesoplenty/common/init/ModBlockQueries.java +++ b/src/main/java/biomesoplenty/common/init/ModBlockQueries.java @@ -61,6 +61,16 @@ public class ModBlockQueries } }; + // Match block positions with water above + waterCovered = new IBlockPosQuery() + { + @Override + public boolean matches(World world, BlockPos pos) + { + return world.getBlockState(pos).getBlock().getMaterial() == Material.water && world.getBlockState(pos.up()).getBlock().getMaterial() == Material.water; + } + }; + // Match blocks which are not unbreakable - IE not bedrock, barrier, command blocks breakable = new IBlockPosQuery() { diff --git a/src/main/java/biomesoplenty/common/world/feature/GeneratorColumns.java b/src/main/java/biomesoplenty/common/world/feature/GeneratorColumns.java index d9b317f08..09b39c928 100644 --- a/src/main/java/biomesoplenty/common/world/feature/GeneratorColumns.java +++ b/src/main/java/biomesoplenty/common/world/feature/GeneratorColumns.java @@ -75,17 +75,16 @@ public class GeneratorColumns extends GeneratorReplacing BlockPos genPos = pos.add(rand.nextInt(4) - rand.nextInt(4), rand.nextInt(3) - rand.nextInt(3), rand.nextInt(4) - rand.nextInt(4)); // see if we can place the column - if (this.placeOn.matches(world, genPos.down())) + if (this.placeOn.matches(world, genPos.down()) && this.replace.matches(world, genPos)) { // choose random target height - int height = GeneratorUtils.nextIntBetween(rand, this.minHeight, this.maxHeight); + int targetHeight = GeneratorUtils.nextIntBetween(rand, this.minHeight, this.maxHeight); // keep placing blocks upwards (if there's room) - while(height > 0 && world.isAirBlock(genPos)) + for (int height = targetHeight; height >= 0 && replace.matches(world, genPos); height--) { world.setBlockState(genPos, this.with); genPos = genPos.up(); - height--; } } } diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java index b3c261706..8c90f14e8 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java @@ -113,26 +113,12 @@ public abstract class GeneratorTreeBase extends BOPGeneratorBase } public T vine(IBlockState a) { - if (a == null) - { - this.vine = null; - } - else - { - this.vine = a; - } + this.vine = a; return this.self(); } public T hanging(IBlockState a) { - if (a == null) - { - this.hanging = null; - } - else - { - this.hanging = a; - } + this.hanging = a; return this.self(); }