From aaa1b7c337ce71a82523e89b880a11a9c4fa2578 Mon Sep 17 00:00:00 2001 From: Forstride Date: Sat, 24 Aug 2019 08:11:36 -0400 Subject: [PATCH] Fixed big trees not generating alternate leaves --- .../biome/overworld/LavenderFieldBiome.java | 2 +- .../gen/feature/tree/BigTreeFeature.java | 21 +++++++++++++++++-- .../biomesoplenty/init/ModVanillaCompat.java | 3 +-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/biomesoplenty/common/biome/overworld/LavenderFieldBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/LavenderFieldBiome.java index 014a213df..609c0cefb 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/LavenderFieldBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/LavenderFieldBiome.java @@ -50,7 +50,7 @@ public class LavenderFieldBiome extends BiomeBOP //////////////////////////////////////////////////////////// // Vegetation - this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.FLOWERING_OAK_TREE, BOPBiomeFeatures.BIG_FLOWERING_OAK_TREE, BOPBiomeFeatures.BIG_JACARANDA_TREE}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.2F, 0.3F, 0.1F}, BOPBiomeFeatures.JACARANDA_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(1, 0.2F, 1))); + this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.FLOWERING_OAK_TREE, BOPBiomeFeatures.BIG_FLOWERING_OAK_TREE, BOPBiomeFeatures.BIG_JACARANDA_TREE}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.2F, 0.1F, 0.1F}, BOPBiomeFeatures.JACARANDA_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(1, 0.2F, 1))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(new StandardGrassFeature(NoFeatureConfig::deserialize), IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(12))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(BOPBiomeFeatures.LAVENDER_FLOWERS, IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(500))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.REED, IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(10))); diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java index 7af4a58a8..3daaa31cf 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/tree/BigTreeFeature.java @@ -10,6 +10,7 @@ package biomesoplenty.common.world.gen.feature.tree; import biomesoplenty.common.util.block.IBlockPosQuery; import com.google.common.collect.Lists; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -90,10 +91,26 @@ public class BigTreeFeature extends TreeFeatureBase if (Math.pow((double)Math.abs(dx) + 0.5D, 2.0D) + Math.pow((double)Math.abs(dz) + 0.5D, 2.0D) <= (double)(radius * radius)) { BlockPos blockpos = pos.add(dx, 0, dz); - if (this.isAirOrLeaves(world, blockpos)) + if (this.replace.matches(world, blockpos)) { // Mojang sets leaves via the method used for logs. Probably intentional? - this.setLogState(changedBlocks, world, blockpos, this.leaves, boundingBox); + if (this.altLeaves != Blocks.AIR.getDefaultState()) + { + int rand = new Random().nextInt(4); + + if (rand == 0) + { + this.setLogState(changedBlocks, world, blockpos, this.altLeaves, boundingBox); + } + else + { + this.setLogState(changedBlocks, world, blockpos, this.leaves, boundingBox); + } + } + else + { + this.setLogState(changedBlocks, world, blockpos, this.leaves, boundingBox); + } } } } diff --git a/src/main/java/biomesoplenty/init/ModVanillaCompat.java b/src/main/java/biomesoplenty/init/ModVanillaCompat.java index 45eee6094..65025c4a4 100644 --- a/src/main/java/biomesoplenty/init/ModVanillaCompat.java +++ b/src/main/java/biomesoplenty/init/ModVanillaCompat.java @@ -35,8 +35,7 @@ public class ModVanillaCompat addFeature(Biomes.FOREST, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(BOPBlocks.sprout.getDefaultState()), Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(4))); addFeature(Biomes.WOODED_HILLS, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(BOPBlocks.sprout.getDefaultState()), Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(4))); - addFeature(Biomes.FLOWER_FOREST, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(BOPBiomeFeatures.JACARANDA_TREE, IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(1, 0.1F, 1))); - addFeature(Biomes.FLOWER_FOREST, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.BIG_FLOWERING_OAK_TREE, BOPBiomeFeatures.JACARANDA_TREE, BOPBiomeFeatures.BIG_JACARANDA_TREE}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.4F, 0.1F, 0.05F}, BOPBiomeFeatures.FLOWERING_OAK_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(2, 0.5F, 1))); + addFeature(Biomes.FLOWER_FOREST, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.BIG_FLOWERING_OAK_TREE, BOPBiomeFeatures.JACARANDA_TREE, BOPBiomeFeatures.BIG_JACARANDA_TREE}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.4F, 0.2F, 0.1F}, BOPBiomeFeatures.FLOWERING_OAK_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(1, 0.5F, 1))); addFeature(Biomes.FLOWER_FOREST, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(BOPBiomeFeatures.BLUE_HYDRANGEA_FEATURE, IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_32, new FrequencyConfig(5))); addFeature(Biomes.JUNGLE, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(BOPBiomeFeatures.ORANGE_COSMOS_FEATURE, IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_32, new FrequencyConfig(4)));