diff --git a/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java index 582fd991a..3844c12af 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java @@ -67,6 +67,5 @@ public class AlpsBiome extends BiomeBOP this.addWeight(BOPClimates.ICE_CAP, 5); this.setBeachBiome((Biome)null); this.setRiverBiome((Biome)null); - this.canSpawnInBiome = false; } } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java index 9529f67bb..f11925cf0 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java @@ -70,8 +70,7 @@ public class AlpsFoothillsBiome extends BiomeBOP this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.STRAY, 80, 4, 4)); - - this.canSpawnInBiome = false; + this.setBeachBiome((Biome)null); this.setRiverBiome((Biome)null); } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BayouBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/BayouBiome.java index 35a54076b..c52d3e2f4 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BayouBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BayouBiome.java @@ -37,7 +37,7 @@ public class BayouBiome extends BiomeBOP { public BayouBiome() { - super((new Biome.Builder()).surfaceBuilder(new ConfiguredSurfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG)).precipitation(Biome.RainType.RAIN).category(Biome.Category.SWAMP).depth(-0.225F).scale(-0.05F).temperature(0.95F).downfall(0.9F).waterColor(0x62AF6E).waterFogColor(0x0C2116).parent((String)null)); + super((new Biome.Builder()).surfaceBuilder(new ConfiguredSurfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG)).precipitation(Biome.RainType.RAIN).category(Biome.Category.SWAMP).depth(-0.315F).scale(-0.05F).temperature(0.95F).downfall(0.9F).waterColor(0x62AF6E).waterFogColor(0x0C2116).parent((String)null)); // Structures this.addStructure(Feature.SWAMP_HUT, IFeatureConfig.NO_FEATURE_CONFIG); @@ -52,13 +52,11 @@ public class BayouBiome extends BiomeBOP DefaultBiomeFeatures.addOres(this); DefaultBiomeFeatures.addSwampClayDisks(this); - this.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.DISK, new SphereReplaceConfig(BOPBlocks.mud.getDefaultState(), 6, 2, Lists.newArrayList(new BlockState[]{Blocks.DIRT.getDefaultState(), Blocks.GRASS_BLOCK.getDefaultState()})), Placement.COUNT_TOP_SOLID, new FrequencyConfig(3))); - //////////////////////////////////////////////////////////// // Vegetation // Trees - this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.SPARSE_OAK_TREE, BOPBiomeFeatures.TALL_WILLOW_TREE}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.1F, 0.3F}, Feature.SWAMP_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(8, 0.7F, 1))); + this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.CYPRESS_TREE_MEDIUM}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.3F}, BOPBiomeFeatures.CYPRESS_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(4, 0.6F, 1))); // Flowers and Foliage this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(new FernGrassFeature(NoFeatureConfig::deserialize), IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(12))); @@ -66,8 +64,8 @@ public class BayouBiome extends BiomeBOP this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.DOUBLE_PLANT, new DoublePlantConfig(Blocks.LARGE_FERN.getDefaultState()), Placement.COUNT_HEIGHTMAP_32, new FrequencyConfig(12))); // Other Plants - this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(BOPBlocks.cattail.getDefaultState()), Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(15))); - this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.DOUBLE_PLANT, new DoublePlantConfig(BOPBlocks.tall_cattail.getDefaultState()), Placement.COUNT_HEIGHTMAP_32, new FrequencyConfig(8))); + this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(BOPBlocks.cattail.getDefaultState()), Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(24))); + this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.DOUBLE_PLANT, new DoublePlantConfig(BOPBlocks.tall_cattail.getDefaultState()), Placement.COUNT_HEIGHTMAP_32, new FrequencyConfig(12))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.REED, IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(10))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(Blocks.BROWN_MUSHROOM.getDefaultState()), Placement.CHANCE_HEIGHTMAP_DOUBLE, new ChanceConfig(4))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(Blocks.RED_MUSHROOM.getDefaultState()), Placement.CHANCE_HEIGHTMAP_DOUBLE, new ChanceConfig(8))); @@ -85,10 +83,6 @@ public class BayouBiome extends BiomeBOP DefaultBiomeFeatures.addFreezeTopLayer(this); // Entities - this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.SHEEP, 12, 4, 4)); - this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.PIG, 10, 4, 4)); - this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.CHICKEN, 10, 4, 4)); - this.addSpawn(EntityClassification.CREATURE, new Biome.SpawnListEntry(EntityType.COW, 8, 4, 4)); this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SPIDER, 100, 4, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ZOMBIE, 95, 4, 4)); diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java index 880de8303..2b1d9d3bb 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java @@ -57,7 +57,7 @@ public class BogBiome extends BiomeBOP //////////////////////////////////////////////////////////// // Vegetation - this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.SPRUCE_TWIGLET_TREE, BOPBiomeFeatures.MAPLE_TWIGLET_TREE, Feature.PINE_TREE}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.4F, 0.6F, 0.1F}, BOPBiomeFeatures.TWIGLET_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(5, 0.4F, 1))); + this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.RANDOM_SELECTOR, new MultipleRandomFeatureConfig(new Feature[]{BOPBiomeFeatures.SPRUCE_TWIGLET_TREE, BOPBiomeFeatures.MAPLE_TWIGLET_TREE}, new IFeatureConfig[]{IFeatureConfig.NO_FEATURE_CONFIG, IFeatureConfig.NO_FEATURE_CONFIG}, new float[]{0.4F, 0.6F}, BOPBiomeFeatures.TWIGLET_TREE, IFeatureConfig.NO_FEATURE_CONFIG), Placement.COUNT_EXTRA_HEIGHTMAP, new AtSurfaceWithExtraConfig(5, 0.4F, 1))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(new StandardGrassFeature(NoFeatureConfig::deserialize), IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(8))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.SWEET_BERRY_BUSH, IFeatureConfig.NO_FEATURE_CONFIG, Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(50))); this.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(BOPBlocks.reed.getDefaultState()), Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(35))); diff --git a/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java index 8f4672644..1e3d6a53b 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java @@ -85,7 +85,6 @@ public class ColdDesertBiome extends BiomeBOP this.addWeight(BOPClimates.ICE_CAP, 10); this.setBeachBiome((Biome)null); this.setRiverBiome((Biome)null); - this.canSpawnInBiome = false; } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/biomesoplenty/common/biome/overworld/OasisBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/OasisBiome.java index 903c3de3b..8b94ef40c 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/OasisBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/OasisBiome.java @@ -72,7 +72,5 @@ public class OasisBiome extends BiomeBOP this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.HUSK, 80, 4, 4)); - - this.canSpawnInBiome = false; } } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/OutbackBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/OutbackBiome.java index 58d390a01..6b2794836 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/OutbackBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/OutbackBiome.java @@ -82,6 +82,5 @@ public class OutbackBiome extends BiomeBOP this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.HUSK, 80, 4, 4)); this.addWeight(BOPClimates.HOT_DESERT, 7); - this.canSpawnInBiome = false; } } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java index 0e7958c45..732652b0e 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java @@ -84,6 +84,5 @@ public class OvergrownCliffsBiome extends BiomeBOP this.addWeight(BOPClimates.TROPICAL, 1); this.setBeachBiome((Biome)null); - this.canSpawnInBiome = false; } } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java index 0e1512896..fbfe9866a 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java @@ -78,7 +78,6 @@ public class SilkgladeBiome extends BiomeBOP this.addWeight(BOPClimates.DRY_TEMPERATE, 1); this.setBeachBiome((Biome)null); this.setRiverBiome((Biome)null); - this.canSpawnInBiome = false; } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java index d481fbf7d..41315c92a 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java @@ -70,8 +70,7 @@ public class VolcanoBiome extends BiomeBOP this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); - - this.canSpawnInBiome = false; + this.setRiverBiome((Biome)null); this.setBeachBiome(BOPBiomes.volcano_edge); } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/VolcanoEdgeBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/VolcanoEdgeBiome.java index 2bf82bcd1..50c73b884 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/VolcanoEdgeBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/VolcanoEdgeBiome.java @@ -76,8 +76,7 @@ public class VolcanoEdgeBiome extends BiomeBOP this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.SLIME, 100, 4, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); - - this.canSpawnInBiome = false; + this.setRiverBiome((Biome)null); this.setBeachBiome((Biome)null); } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java index 06954a19c..60bedcf86 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java @@ -75,7 +75,6 @@ public class WastelandBiome extends BiomeBOP this.addWeight(BOPClimates.HOT_DESERT, 1); this.setBeachBiome(Biomes.DESERT); this.setRiverBiome((Biome)null); - this.canSpawnInBiome = false; } @OnlyIn(Dist.CLIENT) 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 b92079fee..eff6e08e2 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/BOPBiomeFeatures.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/BOPBiomeFeatures.java @@ -62,9 +62,10 @@ public class BOPBiomeFeatures public static final AbstractTreeFeature YELLOW_POPLAR_TREE = new PoplarTreeFeature.Builder().log(Blocks.BIRCH_LOG.getDefaultState()).leaves(BOPBlocks.yellow_autumn_leaves.getDefaultState()).minHeight(10).maxHeight(18).create(); //Swamp Trees + public static final AbstractTreeFeature CYPRESS_TREE = new CypressTreeFeature.Builder().create(); + public static final AbstractTreeFeature CYPRESS_TREE_MEDIUM = new CypressTreeFeature.Builder().minHeight(15).maxHeight(25).trunkWidth(2).create(); public static final AbstractTreeFeature TALL_SWAMP_TREE = new BasicTreeFeature.Builder().vine(Blocks.VINE.getDefaultState()).minHeight(8).maxHeight(12).maxLeavesRadius(2).leavesOffset(0).create(); public static final AbstractTreeFeature WILLOW_TREE = new BasicTreeFeature.Builder().log(BOPBlocks.willow_log.getDefaultState()).leaves(BOPBlocks.willow_leaves.getDefaultState()).vine(BOPBlocks.willow_vine.getDefaultState()).minHeight(6).maxHeight(10).maxLeavesRadius(2).leavesOffset(0).create(); - public static final AbstractTreeFeature TALL_WILLOW_TREE = new BasicTreeFeature.Builder().log(BOPBlocks.willow_log.getDefaultState()).leaves(BOPBlocks.willow_leaves.getDefaultState()).vine(BOPBlocks.willow_vine.getDefaultState()).minHeight(10).maxHeight(16).maxLeavesRadius(2).leavesOffset(0).create(); //Sparse Trees public static final AbstractTreeFeature SPARSE_OAK_TREE = new BigTreeFeature.Builder().minHeight(7).maxHeight(12).foliageHeight(1).create(); diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/tree/CypressTreeFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/tree/CypressTreeFeature.java new file mode 100644 index 000000000..eaf598a1a --- /dev/null +++ b/src/main/java/biomesoplenty/common/world/gen/feature/tree/CypressTreeFeature.java @@ -0,0 +1,252 @@ +/******************************************************************************* + * Copyright 2014-2019, 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.gen.feature.tree; + +import biomesoplenty.api.block.BOPBlocks; +import biomesoplenty.common.util.biome.GeneratorUtil; +import biomesoplenty.common.util.block.IBlockPosQuery; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.SaplingBlock; +import net.minecraft.block.SeaGrassBlock; +import net.minecraft.block.material.Material; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.MutableBoundingBox; +import net.minecraft.world.IWorld; + +import java.util.Random; +import java.util.Set; + +public class CypressTreeFeature extends TreeFeatureBase +{ + public static class Builder extends BuilderBase + { + protected int trunkWidth; + + public Builder trunkWidth(int a) {this.trunkWidth = a; return this;} + + public Builder() + { + this.minHeight = 6; + this.maxHeight = 15; + this.placeOn = (world, pos) -> world.getBlockState(pos).canSustainPlant(world, pos, Direction.UP, (SaplingBlock)Blocks.OAK_SAPLING); + this.replace = (world, pos) -> world.getBlockState(pos).canBeReplacedByLeaves(world, pos) || world.getBlockState(pos).getMaterial() == Material.WATER; + this.log = BOPBlocks.willow_log.getDefaultState(); + this.leaves = BOPBlocks.willow_leaves.getDefaultState(); + this.vine = BOPBlocks.willow_vine.getDefaultState(); + this.trunkWidth = 1; + } + + @Override + public CypressTreeFeature create() + { + return new CypressTreeFeature(this.updateNeighbours, this.placeOn, this.replace, this.log, this.leaves, this.altLeaves, this.vine, this.hanging, this.trunkFruit, this.minHeight, this.maxHeight, this.trunkWidth); + } + + } + + private int trunkWidth = 1; + + protected CypressTreeFeature(boolean notify, IBlockPosQuery placeOn, IBlockPosQuery replace, BlockState log, BlockState leaves, BlockState altLeaves, BlockState vine, BlockState hanging, BlockState trunkFruit, int minHeight, int maxHeight, int trunkWidth) + { + super(notify, placeOn, replace, log, leaves, altLeaves, vine, hanging, trunkFruit, minHeight, maxHeight); + this.trunkWidth = trunkWidth; + } + + public boolean checkSpace(IWorld world, BlockPos pos, int baseHeight, int height) + { + for (int y = 0; y <= height; y++) + { + int trunkWidth = (this.trunkWidth * (height - y) / height) + 1; + int trunkStart = MathHelper.ceil(0.25D - trunkWidth / 2.0D); + int trunkEnd = MathHelper.floor(0.25D + trunkWidth / 2.0D); + + // require 3x3 for the leaves, 1x1 for the trunk + int start = (y <= baseHeight ? trunkStart : trunkStart - 1); + int end = (y <= baseHeight ? trunkEnd : trunkEnd + 1); + + for (int x = start; x <= end; x++) + { + for (int z = start; z <= end; z++) + { + BlockPos pos1 = pos.add(x, y, z); + // note, there may be a sapling on the first layer - make sure this.replace matches it! + if (pos1.getY() >= 255 || !this.replace.matches(world, pos1)) + { + return false; + } + } + } + } + + BlockPos pos2 = pos.add(0, height - 2,0); + if (!world.getBlockState(pos2).canBeReplacedByLeaves(world, pos2)) + { + return false; + } + + return true; + } + + // generates a layer of leafs + public void generateLeafLayer(IWorld world, Random rand, BlockPos pos, int leavesRadius, int trunkStart, int trunkEnd) + { + int start = trunkStart - leavesRadius; + int end = trunkEnd + leavesRadius; + + for (int x = start; x <= end; x++) + { + for (int z = start; z <= end; z++) + { + // skip corners + if ((leavesRadius > 0 ) && (x == start || x == end) && (z == start || z == end)) {continue;} + int distFromTrunk = (x < 0 ? trunkStart - x : x - trunkEnd) + (z < 0 ? trunkStart - z : z - trunkEnd); + + // set leaves as long as it's not too far from the trunk to survive + if (distFromTrunk <= 2) + { + this.setLeaves(world, pos.add(x, 0, z)); + } + } + } + } + + public void generateBranch(Set changedBlocks, MutableBoundingBox boundingBox, IWorld world, Random rand, BlockPos pos, Direction direction, int length) + { + Direction.Axis axis = direction.getAxis(); + Direction sideways = direction.rotateY(); + for (int i = 1; i <= length; i++) + { + BlockPos pos1 = pos.offset(direction, i); + int r = (i == 1 || i == length) ? 1 : 2; + for (int j = -r; j <= r; j++) + { + if (i < length || rand.nextInt(2) == 0) + { + this.setLeaves(world, pos1.offset(sideways, j)); + } + } + if (length - i > 2) + { + this.setLeaves(world, pos1.up()); + this.setLeaves(world, pos1.up().offset(sideways, -1)); + this.setLeaves(world, pos1.up().offset(sideways, 1)); + this.setLog(changedBlocks, world, pos1, axis, boundingBox); + } + } + } + + + @Override + protected boolean place(Set changedBlocks, IWorld world, Random random, BlockPos startPos, MutableBoundingBox boundingBox) + { + // Move down until we reach the ground + while (startPos.getY() > 1 && this.replace.matches(world, startPos) || world.getBlockState(startPos).getMaterial() == Material.LEAVES) {startPos = startPos.down();} + + for (int x = 0; x <= this.trunkWidth - 1; x++) + { + for (int z = 0; z <= this.trunkWidth - 1; z++) + { + if (!this.placeOn.matches(world, startPos.add(x, 0, z))) + { + // Abandon if we can't place the tree on this block + return false; + } + } + } + + // Choose heights + int height = GeneratorUtil.nextIntBetween(random, this.minHeight, this.maxHeight); + int baseHeight = GeneratorUtil.nextIntBetween(random, (int)(height * 0.6F), (int)(height * 0.4F)); + int leavesHeight = height - baseHeight; + if (leavesHeight < 3) {return false;} + + if (!this.checkSpace(world, startPos.up(), baseHeight, height)) + { + // Abandon if there isn't enough room + return false; + } + + // Start at the top of the tree + BlockPos pos = startPos.up(height); + + // Leaves at the top + this.setLeaves(world, pos); + pos.down(); + + // Add layers of leaves + for (int i = 0; i < leavesHeight; i++) + { + + int trunkWidth = (this.trunkWidth * i / height) + 1; + int trunkStart = MathHelper.ceil(0.25D - trunkWidth / 2.0D); + int trunkEnd = MathHelper.floor(0.25D + trunkWidth / 2.0D); + + + int radius = MathHelper.clamp(i, 0, 2); + if (i == leavesHeight - 1) + { + radius = 1; + } + + if (radius == 0) + { + this.setLeaves(world, pos); + } + else if (radius < 2) + { + this.generateLeafLayer(world, random, pos, radius, trunkStart, trunkEnd); + } + else + { + this.generateBranch(changedBlocks, boundingBox, world, random, pos.add(trunkStart, 0, trunkStart), Direction.NORTH, radius); + this.generateBranch(changedBlocks, boundingBox, world, random, pos.add(trunkEnd, 0, trunkStart), Direction.EAST, radius); + this.generateBranch(changedBlocks, boundingBox, world, random, pos.add(trunkEnd, 0, trunkEnd), Direction.SOUTH, radius); + this.generateBranch(changedBlocks, boundingBox, world, random, pos.add(trunkStart, 0, trunkEnd), Direction.WEST, radius); + } + pos = pos.down(); + } + + // Generate the trunk + for (int y = 0; y < height - 1; y++) + { + int trunkWidth = (this.trunkWidth * (height - y) / height) + 1; + int trunkStart = MathHelper.ceil(0.25D - trunkWidth / 2.0D); + int trunkEnd = MathHelper.floor(0.25D + trunkWidth / 2.0D); + + if (trunkWidth < 1) + { + trunkStart = 0; + trunkEnd = 0; + } + + for (int x = trunkStart; x <= trunkEnd; x++) + { + for (int z = trunkStart; z <= trunkEnd; z++) + { + this.setLog(changedBlocks, world, startPos.add(x, y, z), boundingBox); + } + } + } + + return true; + } + + @Override + public boolean setLeaves(IWorld world, BlockPos pos) + { + if (world.getBlockState(pos).canBeReplacedByLeaves(world, pos)) + { + this.setBlockState(world, pos, this.leaves); + return true; + } + return false; + } +} diff --git a/src/main/java/biomesoplenty/common/world/gen/feature/tree/RedwoodTreeFeature.java b/src/main/java/biomesoplenty/common/world/gen/feature/tree/RedwoodTreeFeature.java index 2e780a5b2..b876f7a34 100644 --- a/src/main/java/biomesoplenty/common/world/gen/feature/tree/RedwoodTreeFeature.java +++ b/src/main/java/biomesoplenty/common/world/gen/feature/tree/RedwoodTreeFeature.java @@ -206,7 +206,7 @@ public class RedwoodTreeFeature extends TreeFeatureBase int trunkStart = MathHelper.ceil(0.25D - trunkWidth / 2.0D); int trunkEnd = MathHelper.floor(0.25D + trunkWidth / 2.0D); - if (trunkWidth < 1 || trunkWidth > this.trunkWidth) + if (trunkWidth < 1) { trunkStart = 0; trunkEnd = 0; diff --git a/src/main/resources/assets/biomesoplenty/textures/blocks/toadstool.png b/src/main/resources/assets/biomesoplenty/textures/blocks/toadstool.png index 13b8651db..64befa9c0 100644 Binary files a/src/main/resources/assets/biomesoplenty/textures/blocks/toadstool.png and b/src/main/resources/assets/biomesoplenty/textures/blocks/toadstool.png differ