From b3931fc24b194299b1ef6b12f5741aac7c3f1a92 Mon Sep 17 00:00:00 2001 From: Forstride Date: Wed, 8 Jul 2020 09:29:02 -0400 Subject: [PATCH] Fleshy things --- .../biome/nether/VisceralHeapBiome.java | 1 + .../world/gen/feature/BOPBiomeFeatures.java | 1 + .../gen/feature/FleshSplatterFeature.java | 56 ------------- .../world/gen/feature/FleshTendonFeature.java | 81 +++++++++++++++++++ .../java/biomesoplenty/init/ModFeatures.java | 1 + 5 files changed, 84 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/biomesoplenty/common/world/gen/feature/FleshSplatterFeature.java create mode 100644 src/main/java/biomesoplenty/common/world/gen/feature/FleshTendonFeature.java diff --git a/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java b/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java index a2e6b95f4..63f0b6c10 100644 --- a/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java +++ b/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java @@ -37,6 +37,7 @@ public class VisceralHeapBiome extends NetherBiomeBOP this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, Feature.GLOWSTONE_BLOB.configured(IFeatureConfig.NONE).decorated(Placement.LIGHT_GEM_CHANCE.configured(new FrequencyConfig(7)))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, Feature.GLOWSTONE_BLOB.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_RANGE.configured(new CountRangeConfig(7, 0, 0, 128)))); + this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, BOPBiomeFeatures.FLESH_TENDON.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(20)))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, BOPBiomeFeatures.BONE_SPINE.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(10)))); this.addFeature(GenerationStage.Decoration.UNDERGROUND_DECORATION, BOPBiomeFeatures.SHROOMLIGHT_SCATTER.configured(IFeatureConfig.NONE).decorated(Placement.COUNT_HEIGHTMAP_DOUBLE.configured(new FrequencyConfig(5)))); diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/BOPBiomeFeatures.java b/src/main/java/biomesoplenty/common/world/gen/feature/BOPBiomeFeatures.java index 191ec212e..ddfc6baa1 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/BOPBiomeFeatures.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/BOPBiomeFeatures.java @@ -138,6 +138,7 @@ public class BOPBiomeFeatures public static final Feature SHROOMLIGHT_SCATTER = new ShroomlightFeature(NoFeatureConfig.CODEC); public static final Feature SMALL_CRYSTAL = new SmallCrystalFeature(NoFeatureConfig.CODEC); public static final Feature LARGE_CRYSTAL = new LargeCrystalFeature(NoFeatureConfig.CODEC); + public static final Feature FLESH_TENDON = new FleshTendonFeature(NoFeatureConfig.CODEC); //Flowers public static final FlowersFeature CHAPARRAL_FLOWERS = new ChaparralFlowersFeature(); diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/FleshSplatterFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/FleshSplatterFeature.java deleted file mode 100644 index 73c9265fd..000000000 --- a/src/main/java/biomesoplenty/common/world/gen/feature/FleshSplatterFeature.java +++ /dev/null @@ -1,56 +0,0 @@ -package biomesoplenty.common.world.gen.feature; - -import biomesoplenty.api.block.BOPBlocks; -import com.mojang.serialization.Codec; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.gen.feature.structure.StructureManager; - -import java.util.Random; - -public class FleshSplatterFeature extends Feature -{ - public FleshSplatterFeature(Codec deserializer) - { - super(deserializer); - } - - @Override - public boolean place(ISeedReader worldIn, StructureManager structureManager, ChunkGenerator chunkGenerator, Random rand, BlockPos pos, NoFeatureConfig config) - { - int i = 0; - int j = rand.nextInt(8 - 2) + 2; - - for (int k = pos.getX() - j; k <= pos.getX() + j; ++k) - { - for (int l = pos.getZ() - j; l <= pos.getZ() + j; ++l) - { - int i1 = k - pos.getX(); - int j1 = l - pos.getZ(); - if (i1 * i1 + j1 * j1 <= j * j) - { - for (int k1 = pos.getY() - 2; k1 <= pos.getY() + 2; ++k1) - { - BlockPos blockpos = new BlockPos(k, k1, l); - BlockState blockstate = worldIn.getBlockState(blockpos); - BlockState blockstate1 = worldIn.getBlockState(blockpos.above()); - - if (blockstate.getBlock() == Blocks.NETHERRACK && blockstate1.isAir(worldIn, blockpos.above())) - { - worldIn.setBlock(blockpos, BOPBlocks.flesh.defaultBlockState(), 2); - ++i; - break; - } - } - } - } - } - - return i > 0; - } -} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/FleshTendonFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/FleshTendonFeature.java new file mode 100644 index 000000000..1fea2ef18 --- /dev/null +++ b/src/main/java/biomesoplenty/common/world/gen/feature/FleshTendonFeature.java @@ -0,0 +1,81 @@ +package biomesoplenty.common.world.gen.feature; + +import biomesoplenty.api.block.BOPBlocks; +import biomesoplenty.common.block.NetherCrystalBlock; +import biomesoplenty.common.util.block.IBlockPosQuery; +import com.mojang.serialization.Codec; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.state.properties.AttachFace; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.ISeedReader; +import net.minecraft.world.IWorld; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.feature.structure.StructureManager; + +import java.util.Random; + +public class FleshTendonFeature extends Feature +{ + protected IBlockPosQuery placeOn = (world, pos) -> world.getBlockState(pos).getBlock() == BOPBlocks.flesh; + protected IBlockPosQuery replace = (world, pos) -> world.getBlockState(pos).canBeReplacedByLeaves(world, pos) || world.getBlockState(pos).getBlock() == BOPBlocks.nether_crystal; + + public FleshTendonFeature(Codec deserializer) + { + super(deserializer); + } + + @Override + public boolean place(ISeedReader world, StructureManager p_230362_2_, ChunkGenerator p_230362_3_, Random rand, BlockPos pos, NoFeatureConfig p_230362_6_) + { + if (!world.isEmptyBlock(pos)) + { + return false; + } + else + { + BlockState blockstate = world.getBlockState(pos.below()); + if (!blockstate.is(BOPBlocks.flesh)) + { + return false; + } + else + { + int height = 120; + double baseSlant = rand.nextInt(35) / 100D; + double slantOffset = baseSlant; + double slantMultiplier = 1.3D; + Direction direction = Direction.Plane.HORIZONTAL.getRandomDirection(rand); + + for(int step = 0; step <= height; step++) + { + BlockPos offsetPos = pos.above(step).relative(direction, (int)Math.floor(slantOffset)); + + if (offsetPos.getY() < 127) + { + this.setBlock(world, offsetPos, BOPBlocks.flesh.defaultBlockState()); + } + + //As the height increases, slant more drastically + slantOffset *= slantMultiplier; + } + + return true; + } + } + } + + public boolean setBlock(IWorld world, BlockPos pos, BlockState state) + { + if (this.replace.matches(world, pos)) + { + super.setBlock(world, pos, state); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/init/ModFeatures.java b/src/main/java/biomesoplenty/init/ModFeatures.java index d0e1a9140..269c30458 100644 --- a/src/main/java/biomesoplenty/init/ModFeatures.java +++ b/src/main/java/biomesoplenty/init/ModFeatures.java @@ -138,6 +138,7 @@ public class ModFeatures registerFeatures(BOPBiomeFeatures.SHROOMLIGHT_SCATTER, "shroomlight_scatter"); registerFeatures(BOPBiomeFeatures.SMALL_CRYSTAL, "small_crystal"); registerFeatures(BOPBiomeFeatures.LARGE_CRYSTAL, "large_crystal"); + registerFeatures(BOPBiomeFeatures.FLESH_TENDON, "flesh_tendon"); //Flowers registerFeatures(BOPBiomeFeatures.CHAPARRAL_FLOWERS, "chaparral_flowers");