diff --git a/src/main/java/forestry/arboriculture/VanillaWoodType.java b/src/main/java/forestry/arboriculture/VanillaWoodType.java index f66957c82..a535044a3 100644 --- a/src/main/java/forestry/arboriculture/VanillaWoodType.java +++ b/src/main/java/forestry/arboriculture/VanillaWoodType.java @@ -11,18 +11,12 @@ import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; import com.mojang.authlib.GameProfile; import forestry.api.arboriculture.IWoodType; -import forestry.api.arboriculture.genetics.IFruit; import forestry.api.genetics.IGenome; -import forestry.api.genetics.alleles.TreeChromosomes; import forestry.arboriculture.blocks.ForestryLeafType; -import forestry.arboriculture.features.ArboricultureBlocks; -import forestry.modules.features.FeatureBlockGroup; import org.jetbrains.annotations.Nullable; @@ -32,7 +26,8 @@ public enum VanillaWoodType implements IWoodType { BIRCH(ForestryLeafType.BIRCH), JUNGLE(ForestryLeafType.JUNGLE), ACACIA(ForestryLeafType.ACACIA_VANILLA), - DARK_OAK(ForestryLeafType.DARK_OAK); + DARK_OAK(ForestryLeafType.DARK_OAK), + CHERRY(ForestryLeafType.CHERRY_VANILLA); public static final VanillaWoodType[] VALUES = values(); diff --git a/src/main/java/forestry/arboriculture/blocks/ForestryLeafType.java b/src/main/java/forestry/arboriculture/blocks/ForestryLeafType.java index 41e864391..08ef35e3f 100644 --- a/src/main/java/forestry/arboriculture/blocks/ForestryLeafType.java +++ b/src/main/java/forestry/arboriculture/blocks/ForestryLeafType.java @@ -30,6 +30,7 @@ public final class ForestryLeafType implements IBlockSubtype { public static final ForestryLeafType LIME = new ForestryLeafType(ForestryTreeSpecies.LIME); public static final ForestryLeafType WALNUT = new ForestryLeafType(ForestryTreeSpecies.WALNUT); public static final ForestryLeafType CHESTNUT = new ForestryLeafType(ForestryTreeSpecies.CHESTNUT); + public static final ForestryLeafType CHERRY_VANILLA = new ForestryLeafType(ForestryTreeSpecies.CHERRY_VANILLA); public static final ForestryLeafType BUSH_CHERRY = new ForestryLeafType(ForestryTreeSpecies.BUSH_CHERRY); public static final ForestryLeafType LEMON = new ForestryLeafType(ForestryTreeSpecies.LEMON); public static final ForestryLeafType PLUM = new ForestryLeafType(ForestryTreeSpecies.PLUM); diff --git a/src/main/java/forestry/arboriculture/genetics/TreeGrowthHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeGrowthHelper.java index 80788bbc3..80af84f28 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeGrowthHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeGrowthHelper.java @@ -16,35 +16,49 @@ import forestry.api.genetics.IGenome; +import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; + public class TreeGrowthHelper { + /** + * Finds a valid growth position for a tree if it has all necessary saplings and at least one position has enough + * room for the tree to grow. If no valid position is found, then {@code null} is returned. + * + * + * @param level The world to check for valid positions. + * @param genome The genome of the sapling trying to grow. + * @param pos The position of the sapling. + * @param expectedGirth The expected girth of the tree according to genetics and variation. + * @param expectedHeight The expected height of the tree according to genetics and variation. + * @return A valid growth position, or {@code null} if saplings were missing or if there's no room for the tree. + */ @Nullable - public static BlockPos getGrowthPos(LevelAccessor world, IGenome genome, BlockPos pos, int expectedGirth, int expectedHeight) { - BlockPos growthPos = hasSufficientSaplingsAroundSapling(genome, world, pos, expectedGirth); + public static BlockPos getGrowthPos(LevelAccessor level, IGenome genome, BlockPos pos, int expectedGirth, int expectedHeight) { + // TODO use MutableBlockPos to reduce BlockPos allocations. + // Check if the tree has enough saplings to grow + BlockPos growthPos = hasSufficientSaplingsAroundSapling(genome, level, pos, expectedGirth); if (growthPos == null) { return null; } - if (!hasRoom(world, growthPos, expectedGirth, expectedHeight)) { + // Check if the trunk would be obstructed by solid blocks + if (!hasRoom(level, growthPos, expectedGirth, expectedHeight)) { return null; } return growthPos; } - private static boolean hasRoom(LevelAccessor world, BlockPos pos, int expectedGirth, int expectedHeight) { + private static boolean hasRoom(LevelAccessor level, BlockPos pos, int expectedGirth, int expectedHeight) { Vec3i area = new Vec3i(expectedGirth, expectedHeight + 1, expectedGirth); - return checkArea(world, pos.above(), area); + return checkArea(level, pos.above(), area); } - private static boolean checkArea(LevelAccessor world, BlockPos start, Vec3i area) { + private static boolean checkArea(LevelAccessor level, BlockPos start, Vec3i area) { for (int x = 0; x < area.getX(); x++) { for (int y = 0; y < area.getY(); y++) { for (int z = 0; z < area.getZ(); z++) { BlockPos pos = start.offset(x, y, z); - BlockState blockState = world.getBlockState(pos); - //TODO: Can't be used because the world generation only provides a IWorld and not a World - /*BlockItemUseContext context = new DirectionalPlaceContext((World) world, pos, Direction.DOWN, ItemStack.EMPTY, Direction.UP); - return blockState.isReplaceable(context);*/ + BlockState blockState = level.getBlockState(pos); if (!blockState.canBeReplaced()) { return false; } @@ -63,7 +77,7 @@ private static boolean checkArea(LevelAccessor world, BlockPos start, Vec3i area private static BlockPos hasSufficientSaplingsAroundSapling(IGenome genome, LevelAccessor world, BlockPos saplingPos, int expectedGirth) { final int checkSize = (expectedGirth * 2) - 1; final int offset = expectedGirth - 1; - final Map knownSaplings = new HashMap<>(checkSize * checkSize); + final Object2BooleanOpenHashMap knownSaplings = new Object2BooleanOpenHashMap<>(checkSize * checkSize); for (int x = -offset; x <= 0; x++) { for (int z = -offset; z <= 0; z++) { @@ -77,11 +91,11 @@ private static BlockPos hasSufficientSaplingsAroundSapling(IGenome genome, Level return null; } - private static boolean checkForSaplings(IGenome genome, LevelAccessor world, BlockPos startPos, int girth, Map knownSaplings) { + private static boolean checkForSaplings(IGenome genome, LevelAccessor level, BlockPos startPos, int girth, Object2BooleanOpenHashMap knownSaplings) { for (int x = 0; x < girth; x++) { for (int z = 0; z < girth; z++) { BlockPos checkPos = startPos.offset(x, 0, z); - Boolean knownSapling = knownSaplings.computeIfAbsent(checkPos, k -> isSapling(genome, world, checkPos)); + boolean knownSapling = knownSaplings.computeIfAbsent(checkPos, k -> isSapling(genome, level, checkPos)); if (!knownSapling) { return false; } @@ -90,16 +104,16 @@ private static boolean checkForSaplings(IGenome genome, LevelAccessor world, Blo return true; } - private static boolean isSapling(IGenome genome, LevelAccessor world, BlockPos pos) { - if (!world.hasChunkAt(pos)) { + private static boolean isSapling(IGenome genome, LevelAccessor level, BlockPos pos) { + if (!level.hasChunkAt(pos)) { return false; } - if (world.isEmptyBlock(pos)) { + if (level.isEmptyBlock(pos)) { return false; } - TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class); + TileSapling sapling = TileUtil.getTile(level, pos, TileSapling.class); if (sapling == null) { return false; } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureAcacia.java b/src/main/java/forestry/arboriculture/worldgen/FeatureAcacia.java index 0d3aec2ec..9427232d5 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureAcacia.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureAcacia.java @@ -27,14 +27,14 @@ public FeatureAcacia(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { Direction leanDirection = FeatureHelper.DirectionHelper.getRandom(rand); float leanAmount = height / 4.0f; - Set treeTops = FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, leanDirection, leanAmount); + Set treeTops = FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, leanDirection, leanAmount); if (height > 5 && rand.nextBoolean()) { Direction branchDirection = FeatureHelper.DirectionHelper.getRandomOther(rand, leanDirection); - Set treeTops2 = FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, Math.round(height * 0.66f), girth, 0, 0, branchDirection, leanAmount); + Set treeTops2 = FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, Math.round(height * 0.66f), girth, 0, 0, branchDirection, leanAmount); treeTops.addAll(treeTops2); } @@ -53,14 +53,14 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB float canopyWidth = rand.nextBoolean() ? 3.0f : 2.5f; int radius = Math.round(canopyMultiplier * canopyWidth - 4); BlockPos pos = new BlockPos(xOffset, startPos.getY() + yOffset - canopyThickness, zOffset); - branchEnds.addAll(FeatureHelper.generateBranches(world, rand, wood, pos, girth, 0.0f, 0.1f, radius, 2, 1.0f)); + branchEnds.addAll(FeatureHelper.generateBranches(level, rand, wood, pos, girth, 0.0f, 0.1f, radius, 2, 1.0f)); } return branchEnds; } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { int leafSpawn = branchEnd.getY() - startPos.getY(); int canopyThickness = Math.max(1, Math.round(leafSpawn / 10.0f)); @@ -68,7 +68,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT float canopyWidth = rand.nextBoolean() ? 1.0f : 1.5f; BlockPos center = new BlockPos(branchEnd.getX(), leafSpawn - canopyThickness + 1 + startPos.getY(), branchEnd.getZ()); float radius = Math.max(1, canopyMultiplier * canopyWidth + girth); - FeatureHelper.generateCylinderFromPos(world, leaf, center, radius, canopyThickness, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, center, radius, canopyThickness, FeatureHelper.EnumReplaceMode.AIR, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/FeatureArboriculture.java index cd5ecb6be..51ea5ee7d 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureArboriculture.java @@ -22,6 +22,7 @@ import net.minecraft.core.Direction; import net.minecraft.util.RandomSource; import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelWriter; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -36,6 +37,19 @@ import forestry.core.utils.VecUtil; import forestry.core.worldgen.FeatureBase; +/** + * Base logic for tree generation. Tree generation generally follows these steps: + *
    + *
  1. Calculate the girth and height based on species, genome, and random variation.
  2. + *
  3. Check if there are enough saplings to grow the tree and if the trunk has enough room to grow.
  4. + *
  5. Remove the saplings.
  6. + *
  7. Generate the trunk and branches. Keep track of the "branch end" positions for leaf placement.
  8. + *
  9. Generate leaves at the branch positions.
  10. + *
  11. If the tree has pod fruit, generate fruit pods as well.
  12. + *
  13. Update distance states for all leaves after generation.
  14. + *
  15. Calls updateShape on all leaf blocks, which handles decay and waterlogged behavior.
  16. + *
+ */ public abstract class FeatureArboriculture extends FeatureBase { protected static final int minPodHeight = 3; @@ -47,46 +61,60 @@ protected FeatureArboriculture(ITreeGenData tree) { @Override public IGenome getDefaultGenome() { - return tree.getDefaultGenome(); + return this.tree.getDefaultGenome(); } @Override - public boolean place(IGenome genome, LevelAccessor world, RandomSource rand, BlockPos pos, boolean forced) { - TreeBlockTypeLeaf leaf = new TreeBlockTypeLeaf(tree, genome); - TreeBlockTypeLog wood = new TreeBlockTypeLog(tree, genome); + public boolean place(IGenome genome, LevelAccessor level, RandomSource rand, BlockPos pos, boolean forced) { + TreeBlockTypeLeaf leaf = new TreeBlockTypeLeaf(this.tree, genome); + TreeBlockTypeLog wood = new TreeBlockTypeLog(this.tree, genome); - preGenerate(genome, world, rand, pos); + // Calculate height and girth + preGenerate(genome, level, rand, pos); + // Determine valid growth position if any, or skip all checks if forced is true BlockPos genPos; if (forced) { genPos = pos; } else { - genPos = getValidGrowthPos(world, pos); + // Default implementation is in TreeGrowthHelper.getGrowthPos, but can be overridden in TreeSpecies + genPos = getValidGrowthPos(level, pos); } + // If a valid growth position was found if (genPos != null) { - clearSaplings(world, genPos); - List branchEnds = new ArrayList<>(generateTrunk(world, rand, wood, genPos)); + // Remove all saplings + clearSaplings(level, genPos); + + // Generate a trunk and a list of branch end positions. Store those branch ends in a contour + ArrayList branchEnds = new ArrayList<>(generateTrunk(level, rand, wood, genPos)); branchEnds.sort(VecUtil.TOP_DOWN_COMPARATOR); TreeContour.Impl contour = new TreeContour.Impl(branchEnds); - generateLeaves(world, rand, leaf, contour, genPos); - generateExtras(world, rand, genPos); - updateLeaves(world, contour); - DiscreteVoxelShape voxelshapepart = this.updateLeaves(world, contour); - StructureTemplate.updateShapeAtEdge(world, 3, voxelshapepart, contour.boundingBox.minX(), contour.boundingBox.minY(), contour.boundingBox.minZ()); + + // Generate leaves and pods + generateLeaves(level, rand, leaf, contour, genPos); + generateExtras(level, rand, genPos); + + // Correctly update the leaf distance states on the leaf blocks + DiscreteVoxelShape voxelshapepart = updateLeaves(level, contour); + // Call updateShape method on all blocks on the edge of the tree's bounding box + StructureTemplate.updateShapeAtEdge(level, 3, voxelshapepart, contour.boundingBox.minX(), contour.boundingBox.minY(), contour.boundingBox.minZ()); return true; } return false; } - public void preGenerate(IGenome genome, LevelAccessor world, RandomSource rand, BlockPos startPos) { + /** + * Used by {@link FeatureTree} to set fields such as height and girth before generating anything in the world. + */ + public void preGenerate(IGenome genome, LevelAccessor level, RandomSource rand, BlockPos startPos) { } /** * Copied vanilla logic from TreeFeature#updateLeaves */ - private DiscreteVoxelShape updateLeaves(LevelAccessor world, TreeContour.Impl contour) { + private DiscreteVoxelShape updateLeaves(LevelAccessor level, TreeContour.Impl contour) { BoundingBox boundingBox = contour.boundingBox; List> list = Lists.newArrayList(); DiscreteVoxelShape voxelshapepart = new BitSetDiscreteVoxelShape(boundingBox.getXSpan(), boundingBox.getYSpan(), boundingBox.getZSpan()); @@ -106,10 +134,9 @@ private DiscreteVoxelShape updateLeaves(LevelAccessor world, TreeContour.Impl co for (Direction direction : Direction.values()) { blockpos$mutable.setWithOffset(blockpos1, direction); if (!contour.leavePositions.contains(blockpos$mutable)) { - BlockState blockstate = world.getBlockState(blockpos$mutable); + BlockState blockstate = level.getBlockState(blockpos$mutable); if (blockstate.hasProperty(BlockStateProperties.DISTANCE)) { list.get(0).add(blockpos$mutable.immutable()); - // TreeFeature.setBlockKnownShape(world, blockpos$mutable, blockstate.setValue(BlockStateProperties.DISTANCE, 1)); if (boundingBox.isInside(blockpos$mutable)) { voxelshapepart.fill(blockpos$mutable.getX() - boundingBox.minX(), blockpos$mutable.getY() - boundingBox.minY(), blockpos$mutable.getZ() - boundingBox.minZ()); } @@ -130,12 +157,12 @@ private DiscreteVoxelShape updateLeaves(LevelAccessor world, TreeContour.Impl co for (Direction direction1 : Direction.values()) { blockpos$mutable.setWithOffset(blockpos2, direction1); if (!set.contains(blockpos$mutable) && !set1.contains(blockpos$mutable)) { - BlockState blockstate1 = world.getBlockState(blockpos$mutable); + BlockState blockstate1 = level.getBlockState(blockpos$mutable); if (blockstate1.hasProperty(BlockStateProperties.DISTANCE)) { int k = blockstate1.getValue(BlockStateProperties.DISTANCE); if (k > l + 1) { BlockState blockstate2 = blockstate1.setValue(BlockStateProperties.DISTANCE, Integer.valueOf(l + 1)); - // TreeFeature.setBlockKnownShape(world, blockpos$mutable, blockstate2); + setBlockKnownShape(level, blockpos$mutable, blockstate2); if (boundingBox.isInside(blockpos$mutable)) { voxelshapepart.fill(blockpos$mutable.getX() - boundingBox.minX(), blockpos$mutable.getY() - boundingBox.minY(), blockpos$mutable.getZ() - boundingBox.minZ()); } @@ -151,33 +178,38 @@ private DiscreteVoxelShape updateLeaves(LevelAccessor world, TreeContour.Impl co return voxelshapepart; } + private static void setBlockKnownShape(LevelWriter level, BlockPos pos, BlockState state) { + level.setBlock(pos, state, BlockSapling.UPDATE_NEIGHBORS | BlockSapling.UPDATE_CLIENTS | BlockSapling.UPDATE_KNOWN_SHAPE); + } + /** * Generate the tree's trunk. Returns a list of positions of branch ends for leaves to generate at. */ + protected abstract Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos); - protected abstract Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos); - - protected abstract void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos); + protected abstract void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos); - protected abstract void generateExtras(LevelAccessor world, RandomSource rand, BlockPos startPos); + protected abstract void generateExtras(LevelAccessor level, RandomSource rand, BlockPos startPos); @Nullable - public abstract BlockPos getValidGrowthPos(LevelAccessor world, BlockPos pos); + public abstract BlockPos getValidGrowthPos(LevelAccessor level, BlockPos pos); - public void clearSaplings(LevelAccessor world, BlockPos genPos) { - int treeGirth = tree.getGirth(tree.getDefaultGenome()); + /** + * Removes all saplings before generating the trunk. + */ + public void clearSaplings(LevelAccessor level, BlockPos genPos) { + int treeGirth = this.tree.getGirth(this.tree.getDefaultGenome()); for (int x = 0; x < treeGirth; x++) { for (int z = 0; z < treeGirth; z++) { BlockPos saplingPos = genPos.offset(x, 0, z); - if (world.getBlockState(saplingPos).getBlock() instanceof BlockSapling) { - world.setBlock(saplingPos, Blocks.AIR.defaultBlockState(), 18); + if (level.getBlockState(saplingPos).getBlock() instanceof BlockSapling) { + level.setBlock(saplingPos, Blocks.AIR.defaultBlockState(), 18); } } } } public boolean hasPods() { - return tree.allowsFruitBlocks(tree.getDefaultGenome()); + return this.tree.allowsFruitBlocks(this.tree.getDefaultGenome()); } - } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureBalsa.java b/src/main/java/forestry/arboriculture/worldgen/FeatureBalsa.java index 6c27c4dc7..8648a9cf1 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureBalsa.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureBalsa.java @@ -25,23 +25,23 @@ public FeatureBalsa(ITreeGenData tree) { } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { BlockPos topPos = startPos.offset(0, height + 1, 0); BlockPos.MutableBlockPos leafCenter = new BlockPos.MutableBlockPos(); float leafRadius = (girth - 1.0f) / 2.0f; - FeatureHelper.addBlock(world, leafCenter.set(topPos), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.addBlock(level, leafCenter.set(topPos), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); leafCenter.move(Direction.DOWN); - FeatureHelper.generateCylinderFromPos(world, leaf, leafCenter, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, leafCenter, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); leafCenter.move(Direction.DOWN); if (height > 10) { - FeatureHelper.generateCylinderFromPos(world, leaf, leafCenter, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, leafCenter, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); leafCenter.move(Direction.DOWN); } while (leafCenter.getY() > topPos.getY() - 6) { - FeatureHelper.generateCylinderFromPos(world, leaf, leafCenter, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, leafCenter, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); leafCenter.move(Direction.DOWN); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureBaobab.java b/src/main/java/forestry/arboriculture/worldgen/FeatureBaobab.java index f2d35daa1..95b595845 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureBaobab.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureBaobab.java @@ -26,29 +26,29 @@ public FeatureBaobab(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height - 1, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height - 1, girth, 0, 0, null, 0); if (rand.nextFloat() < 0.3f) { - FeatureHelper.generateCylinderFromTreeStartPos(world, wood, startPos.offset(0, height - 1, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, TreeContour.EMPTY); + FeatureHelper.generateCylinderFromTreeStartPos(level, wood, startPos.offset(0, height - 1, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, TreeContour.EMPTY); } else if (rand.nextBoolean()) { - FeatureHelper.generateCylinderFromTreeStartPos(world, wood, startPos.offset(0, height - 1, girth / 2), girth, girth - 1, 1, FeatureHelper.EnumReplaceMode.SOFT, TreeContour.EMPTY); + FeatureHelper.generateCylinderFromTreeStartPos(level, wood, startPos.offset(0, height - 1, girth / 2), girth, girth - 1, 1, FeatureHelper.EnumReplaceMode.SOFT, TreeContour.EMPTY); } - return FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, height - 2, 0), girth, 0, 0.5f, 4, 6, 1.0f); + return FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, height - 2, 0), girth, 0, 0.5f, 4, 6, 1.0f); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 1f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 1f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); // Add tree top for (int times = 0; times < height / 2; times++) { @@ -65,12 +65,12 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT if (girth > 1) { radius += rand.nextInt(girth - 1); } - FeatureHelper.generateSphere(world, center, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphere(level, center, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } // Add some smaller twigs below for flavour for (int times = 0; times < height / 4; times++) { - int delim = modifyByHeight(world, 6, 0, height); + int delim = modifyByHeight(level, 6, 0, height); int h = delim + (delim < height ? rand.nextInt(height - delim) : 0); if (rand.nextBoolean() && h < height / 2) { h = height / 2 + rand.nextInt(height / 2); @@ -80,7 +80,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT BlockPos center = startPos.offset(x_off, h, y_off); int radius = 1 + rand.nextInt(2); - FeatureHelper.generateSphere(world, center, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphere(level, center, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureBushCherry.java b/src/main/java/forestry/arboriculture/worldgen/FeatureBushCherry.java index 5e74d2503..679e04074 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureBushCherry.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureBushCherry.java @@ -27,15 +27,15 @@ public FeatureBushCherry(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); Set branchCoords = new HashSet<>(); int branchHeight = height - 1; int branchWidth = height / 2; while (branchHeight > 2) { - branchCoords.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.2f, 0.5f, branchWidth, 1, 1.0f)); + branchCoords.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.2f, 0.5f, branchWidth, 1, 1.0f)); branchHeight -= 2; branchWidth++; } @@ -43,14 +43,14 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 2; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCircle(world, rand, branchEnd.above(), 3, 3, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); - FeatureHelper.generateCircle(world, rand, branchEnd, 4, 3, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCircle(level, rand, branchEnd.above(), 3, 3, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCircle(level, rand, branchEnd, 4, 3, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureChestnut.java b/src/main/java/forestry/arboriculture/worldgen/FeatureChestnut.java index e1f1d0e14..edfdd234c 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureChestnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureChestnut.java @@ -26,8 +26,8 @@ public FeatureChestnut(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); int branchHeight = 4; if (rand.nextBoolean()) { @@ -36,27 +36,27 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB int branchRadius = height / 2; - return FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.5f, 0.5f, branchRadius, 2, 1.0f); + return FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.5f, 0.5f, branchRadius, 2, 1.0f); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > 4) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } if (rand.nextBoolean()) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 1.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 1.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureCocobolo.java b/src/main/java/forestry/arboriculture/worldgen/FeatureCocobolo.java index 1caa0ab6e..f6215fb66 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureCocobolo.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureCocobolo.java @@ -26,24 +26,24 @@ public FeatureCocobolo(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - return FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + return FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height; for (BlockPos treeTop : contour.getBranchEnds()) { - FeatureHelper.addBlock(world, treeTop.above(), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.addBlock(level, treeTop.above(), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } leafSpawn--; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); if (height > 10) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); leafSpawn--; @@ -54,7 +54,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT } float radius = (leafSpawn % 2 == 0) ? 2 + girth : girth; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(offset, leafSpawn, offset), girth, radius, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(offset, leafSpawn, offset), girth, radius, 1, FeatureHelper.EnumReplaceMode.AIR, contour); leafSpawn--; } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureDate.java b/src/main/java/forestry/arboriculture/worldgen/FeatureDate.java index c9bad5d96..0da4b8126 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureDate.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureDate.java @@ -24,13 +24,13 @@ public FeatureDate(ITreeGenData tree) { } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; float radiusMultiplier = height / 6f; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, radiusMultiplier * 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, radiusMultiplier * 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, radiusMultiplier * 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, radiusMultiplier * 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureEbony.java b/src/main/java/forestry/arboriculture/worldgen/FeatureEbony.java index 394b009b0..88594f3c6 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureEbony.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureEbony.java @@ -28,14 +28,14 @@ public FeatureEbony(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { int trunksGenerated = 0; for (int x = 0; x < girth; x++) { for (int z = 0; z < girth; z++) { if (rand.nextFloat() < 0.6f) { for (int y = 0; y < height; y++) { - FeatureHelper.addBlock(world, startPos.offset(x, y, z), wood, FeatureHelper.EnumReplaceMode.ALL); + FeatureHelper.addBlock(level, startPos.offset(x, y, z), wood, FeatureHelper.EnumReplaceMode.ALL); if (y > height / 2 && rand.nextFloat() < 0.1f * (10 / height)) { break; } @@ -43,7 +43,7 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB trunksGenerated++; } else { for (int i = 0; i < 1; i++) { - world.setBlock(startPos.offset(x, i, z), Blocks.AIR.defaultBlockState(), 18); + level.setBlock(startPos.offset(x, i, z), Blocks.AIR.defaultBlockState(), 18); } } } @@ -51,14 +51,14 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB // Generate backup trunk, if we failed to generate any. if (trunksGenerated <= 0) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, 1, 0, 0.6f, null, 0); + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, 1, 0, 0.6f, null, 0); } return Collections.emptySet(); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (int times = 0; times < 2 * height; times++) { int h = 2 * girth + rand.nextInt(height - girth); if (rand.nextBoolean() && h < height / 2) { @@ -70,7 +70,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT BlockPos center = startPos.offset(x_off, h, y_off); int radius = 1 + rand.nextInt(girth); - FeatureHelper.generateSphere(world, center, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphere(level, center, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureGreenheart.java b/src/main/java/forestry/arboriculture/worldgen/FeatureGreenheart.java index 68da78472..a77e9057c 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureGreenheart.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureGreenheart.java @@ -27,26 +27,26 @@ public FeatureGreenheart(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0.4f, null, 0); - FeatureHelper.generateSupportStems(wood, world, rand, startPos, height, girth, 0.5f, 0.2f); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0.4f, null, 0); + FeatureHelper.generateSupportStems(wood, level, rand, startPos, height, girth, 0.5f, 0.2f); return Collections.emptySet(); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > height - 4) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); if (height > 10) { // Add some smaller twigs below for flavour @@ -57,7 +57,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); - FeatureHelper.generateSphere(world, startPos.offset(x_off, h, y_off), 1 + rand.nextInt(1), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphere(level, startPos.offset(x_off, h, y_off), 1 + rand.nextInt(1), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureIpe.java b/src/main/java/forestry/arboriculture/worldgen/FeatureIpe.java index 23307aca8..f582f13b1 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureIpe.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureIpe.java @@ -27,8 +27,8 @@ public FeatureIpe(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); int trunkSpawn = height - 2; float adjustedGirth = girth * .65f; @@ -36,23 +36,23 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB Set branchCoords = new HashSet<>(); while (trunkSpawn > 2) { int radius = Math.round(adjustedGirth * (height - trunkSpawn) / 1.5f); - branchCoords.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, trunkSpawn, 0), girth, 0.25f, 0.25f, radius, 2, 1.0f)); + branchCoords.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, trunkSpawn, 0), girth, 0.25f, 0.25f, radius, 2, 1.0f)); trunkSpawn -= 2; } return branchCoords; } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; float adjustedGirth = girth * .65f; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.2f * adjustedGirth + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 0.2f * adjustedGirth + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.2f * adjustedGirth + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 0.2f * adjustedGirth + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 2.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 2.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureJungle.java b/src/main/java/forestry/arboriculture/worldgen/FeatureJungle.java index 6cf943a2f..8e9be77da 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureJungle.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureJungle.java @@ -30,7 +30,7 @@ public FeatureJungle(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { int height = this.height; float vinesChance = 0.0f; if (girth >= 2) { @@ -38,13 +38,13 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB vinesChance = 0.8f; } - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, vinesChance, null, 0); + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, vinesChance, null, 0); Set branchCoords = new HashSet<>(); if (height > 10) { int branchSpawn = 6; while (branchSpawn < height - 2) { - branchCoords.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, branchSpawn, 0), girth, 0.5f, 0f, 2, 1, 0.25f)); + branchCoords.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, branchSpawn, 0), girth, 0.5f, 0f, 2, 1, 0.25f)); branchSpawn += rand.nextInt(4); } } @@ -53,23 +53,23 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int height = this.height; if (girth >= 2) { height *= 1.5f; } for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; float canopyRadiusMultiplier = height / 7.0f; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f * canopyRadiusMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f * canopyRadiusMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * canopyRadiusMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.9f * canopyRadiusMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * canopyRadiusMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.9f * canopyRadiusMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureKapok.java b/src/main/java/forestry/arboriculture/worldgen/FeatureKapok.java index 21856e1b2..913885eba 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureKapok.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureKapok.java @@ -27,15 +27,15 @@ public FeatureKapok(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0.6f, null, 0); - FeatureHelper.generateSupportStems(wood, world, rand, startPos, height, girth, 0.8f, 0.4f); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0.6f, null, 0); + FeatureHelper.generateSupportStems(wood, level, rand, startPos, height, girth, 0.8f, 0.4f); Set branchCoords = new HashSet<>(); int leafSpawn = height + 1; while (leafSpawn > height - 4) { int radius = Math.round(girth * (height - leafSpawn) / 1.5f) + 6; - branchCoords.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, leafSpawn, 0), girth, 0.3f, 0.25f, radius, 6, 1.0f)); + branchCoords.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, leafSpawn, 0), girth, 0.3f, 0.25f, radius, 6, 1.0f)); leafSpawn -= 2; } @@ -43,16 +43,16 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd.above(), 2.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd.above(), 2.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } // Add some smaller twigs below for flavour @@ -63,7 +63,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); - FeatureHelper.generateSphere(world, startPos.offset(x_off, h, y_off), 1 + rand.nextInt(1), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphere(level, startPos.offset(x_off, h, y_off), 1 + rand.nextInt(1), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureLarch.java b/src/main/java/forestry/arboriculture/worldgen/FeatureLarch.java index 510e10f0b..a95d7979a 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureLarch.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureLarch.java @@ -24,17 +24,17 @@ public FeatureLarch(ITreeGenData tree) { } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; float sizeMultiplier = Math.max(height / 8, 1.0f); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, sizeMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, sizeMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > 2) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 * sizeMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, sizeMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 * sizeMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, sizeMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureLemon.java b/src/main/java/forestry/arboriculture/worldgen/FeatureLemon.java index d25d8ce4c..530aed2bf 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureLemon.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureLemon.java @@ -24,13 +24,13 @@ public FeatureLemon(ITreeGenData tree) { } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int yCenter = height - girth; yCenter = yCenter > 2 ? yCenter : 3; int radius = Math.round((2 + rand.nextInt(girth)) * (height / 4.0f)); if (radius > 4) { radius = 4; } - FeatureHelper.generateSphereFromTreeStartPos(world, startPos.offset(0, yCenter, 0), girth, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphereFromTreeStartPos(level, startPos.offset(0, yCenter, 0), girth, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureMahoe.java b/src/main/java/forestry/arboriculture/worldgen/FeatureMahoe.java index ee5bf42eb..a51ccaa32 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureMahoe.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureMahoe.java @@ -27,24 +27,24 @@ public FeatureMahoe(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - Set branchCoords = new HashSet<>(FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0)); + Set branchCoords = new HashSet<>(FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0)); for (int yBranch = 2; yBranch < height - 1; yBranch++) { - branchCoords.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.15f, 0.25f, Math.round((height - yBranch) * 0.75f), 1, 0.25f)); + branchCoords.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.15f, 0.25f, Math.round((height - yBranch) * 0.75f), 1, 0.25f)); } return branchCoords; } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 2 + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 2 + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } int yCenter = height - girth; yCenter = yCenter > 3 ? yCenter : 4; - FeatureHelper.generateSphereFromTreeStartPos(world, startPos.offset(0, yCenter, 0), girth, 3 + rand.nextInt(girth), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphereFromTreeStartPos(level, startPos.offset(0, yCenter, 0), girth, 3 + rand.nextInt(girth), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureMahogany.java b/src/main/java/forestry/arboriculture/worldgen/FeatureMahogany.java index 05af7e593..7d45bad58 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureMahogany.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureMahogany.java @@ -27,32 +27,32 @@ public FeatureMahogany(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0.6f, null, 0); - FeatureHelper.generateSupportStems(wood, world, rand, startPos, height, girth, 0.4f, 0.4f); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0.6f, null, 0); + FeatureHelper.generateSupportStems(wood, level, rand, startPos, height, girth, 0.4f, 0.4f); Set branchEnds = new HashSet<>(); for (int yBranch = height - 4; yBranch < height - 2; yBranch++) { - branchEnds.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.15f, 0.25f, Math.round((height - yBranch) * 0.5f), 1, 0.25f)); + branchEnds.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.15f, 0.25f, Math.round((height - yBranch) * 0.5f), 1, 0.25f)); } return branchEnds; } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 2 + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 2 + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureMaple.java b/src/main/java/forestry/arboriculture/worldgen/FeatureMaple.java index 7a684c61a..5504dcb2f 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureMaple.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureMaple.java @@ -27,32 +27,32 @@ public FeatureMaple(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); Set branchCoords = new HashSet<>(); for (int yBranch = 2; yBranch < height - 2; yBranch++) { - branchCoords.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.15f, 0.25f, Math.round((height - yBranch) * 0.25f), 1, 0.25f)); + branchCoords.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.15f, 0.25f, Math.round((height - yBranch) * 0.25f), 1, 0.25f)); } return branchCoords; } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 2 + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 2 + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; float diameterchange = (float) 1 / height; int leafSpawned = 2; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > 1) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); leafSpawned += 2; } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeaturePadauk.java b/src/main/java/forestry/arboriculture/worldgen/FeaturePadauk.java index b14346f47..47df9ee46 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeaturePadauk.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeaturePadauk.java @@ -29,8 +29,8 @@ public FeaturePadauk(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); int branchSpawn = height - 2; @@ -60,9 +60,9 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB wood.setDirection(directionValue); if (directionValue == Direction.NORTH) { - FeatureHelper.addBlock(world, startPos.offset(0, branchSpawnY, j * offsetValue), wood, FeatureHelper.EnumReplaceMode.ALL); + FeatureHelper.addBlock(level, startPos.offset(0, branchSpawnY, j * offsetValue), wood, FeatureHelper.EnumReplaceMode.ALL); } else if (directionValue == Direction.EAST) { - FeatureHelper.addBlock(world, startPos.offset(j * offsetValue, branchSpawnY, 0), wood, FeatureHelper.EnumReplaceMode.ALL); + FeatureHelper.addBlock(level, startPos.offset(j * offsetValue, branchSpawnY, 0), wood, FeatureHelper.EnumReplaceMode.ALL); } } } @@ -72,12 +72,12 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); int count = 0; int max = 3; @@ -86,7 +86,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT while (leafSpawn > 3 && count < canopyHeight) { int yCenter = leafSpawn--; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, yCenter, 0), girth, 4.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, yCenter, 0), girth, 4.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); count++; } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeaturePapaya.java b/src/main/java/forestry/arboriculture/worldgen/FeaturePapaya.java index 88f147d66..e26684419 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeaturePapaya.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeaturePapaya.java @@ -26,19 +26,19 @@ public FeaturePapaya(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - return FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, height - 1, 0), girth, 0.15f, 0.25f, height / 4, 1, 0.25f); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); + return FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, height - 1, 0), girth, 0.15f, 0.25f, height / 4, 1, 0.25f); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 1 + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 1 + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); } int yCenter = height - girth; yCenter = yCenter > 3 ? yCenter : 4; - FeatureHelper.generateSphereFromTreeStartPos(world, startPos.offset(0, yCenter, 0), girth, Math.round((2 + rand.nextInt(girth)) * (height / 8.0f)), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphereFromTreeStartPos(level, startPos.offset(0, yCenter, 0), girth, Math.round((2 + rand.nextInt(girth)) * (height / 8.0f)), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeaturePine.java b/src/main/java/forestry/arboriculture/worldgen/FeaturePine.java index bcbe47a6d..27649a0bf 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeaturePine.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeaturePine.java @@ -27,32 +27,32 @@ public FeaturePine(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); Set branchEnds = new HashSet<>(); for (int yBranch = 2; yBranch < height - 2; yBranch++) { - branchEnds.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.05f, 0.1f, Math.round((height - yBranch) * 0.25f), 1, 0.25f)); + branchEnds.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.05f, 0.1f, Math.round((height - yBranch) * 0.25f), 1, 0.25f)); } return branchEnds; } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 2 + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 2 + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; float diameterchange = 1.25f / height; int leafSpawned = 2; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > 1) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2 * diameterchange * leafSpawned + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); leafSpawned += 2; } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeaturePlum.java b/src/main/java/forestry/arboriculture/worldgen/FeaturePlum.java index c5718e991..df134c90d 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeaturePlum.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeaturePlum.java @@ -24,7 +24,7 @@ public FeaturePlum(ITreeGenData tree) { } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int yCenter = height - girth; yCenter = yCenter > 2 ? yCenter : 3; @@ -32,6 +32,6 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT if (radius > 4) { radius = 4; } - FeatureHelper.generateSphereFromTreeStartPos(world, startPos.offset(0, yCenter, 0), girth, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphereFromTreeStartPos(level, startPos.offset(0, yCenter, 0), girth, radius, leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeaturePoplar.java b/src/main/java/forestry/arboriculture/worldgen/FeaturePoplar.java index df7ff07e1..f45a25a4a 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeaturePoplar.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeaturePoplar.java @@ -24,12 +24,12 @@ public FeaturePoplar(ITreeGenData tree) { } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; float leafRadius = (girth - 1.0f) / 2.0f; while (leafSpawn > girth - 1) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, leafRadius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureSequoia.java b/src/main/java/forestry/arboriculture/worldgen/FeatureSequoia.java index 89894019e..3c6db067e 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureSequoia.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureSequoia.java @@ -31,9 +31,9 @@ protected FeatureSequoia(ITreeGenData tree, int baseHeight, int heightVariation) } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - FeatureHelper.generateSupportStems(wood, world, rand, startPos, height, girth, 0.4f, 0.4f); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); + FeatureHelper.generateSupportStems(wood, level, rand, startPos, height, girth, 0.4f, 0.4f); int topHeight = height / 3 + rand.nextInt(height / 6); @@ -43,28 +43,28 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB if (branchLength > 4) { branchLength = 4; } - branchCoords.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.05f, 0.25f, branchLength, 1, 0.5f)); + branchCoords.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, yBranch, 0), girth, 0.05f, 0.25f, branchLength, 1, 0.5f)); } return branchCoords; } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 1.0f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 1.0f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 2; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); int topHeight = height / 3 + rand.nextInt(height / 6); while (leafSpawn > topHeight) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureSilverLime.java b/src/main/java/forestry/arboriculture/worldgen/FeatureSilverLime.java index 9d54ea5c1..92d9a6776 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureSilverLime.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureSilverLime.java @@ -26,24 +26,24 @@ public FeatureSilverLime(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); BlockPos pos = startPos.offset(0, 3 + rand.nextInt(1), 0); - return FeatureHelper.generateBranches(world, rand, wood, pos, girth, 0.25f, 0.10f, Math.round(height * 0.25f), 2, 0.5f); + return FeatureHelper.generateBranches(level, rand, wood, pos, girth, 0.25f, 0.10f, Math.round(height * 0.25f), 2, 0.5f); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); float radius = 1; while (leafSpawn > 1) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, radius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, radius + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); radius += 0.25; } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureSpruce.java b/src/main/java/forestry/arboriculture/worldgen/FeatureSpruce.java index e72fed046..1c862a555 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureSpruce.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureSpruce.java @@ -27,15 +27,15 @@ public FeatureSpruce(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); Set branchEnds = new HashSet<>(); int branchSpawn = height - 1; int branchWidth = height / 4; while (branchSpawn > 2) { - branchEnds.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, branchSpawn, 0), girth, 0.2f, 0.5f, branchWidth, 1, 1.0f)); + branchEnds.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, branchSpawn, 0), girth, 0.2f, 0.5f, branchWidth, 1, 1.0f)); branchSpawn -= 2; branchWidth++; } @@ -44,17 +44,17 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); int leafRadius = 4; for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCircle(world, rand, branchEnd, leafRadius, 3, 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCircle(level, rand, branchEnd, leafRadius, 3, 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.SOFT, contour); } - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 2 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, (float) 2 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, (float) 1 + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureTeak.java b/src/main/java/forestry/arboriculture/worldgen/FeatureTeak.java index 6b0e8cdae..dcab8a203 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureTeak.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureTeak.java @@ -26,36 +26,36 @@ public FeatureTeak(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); int branchWidth = height / 3; - return FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, height - 3, 0), girth, 0.2f, 0.5f, branchWidth, 1, 1.0f); + return FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, height - 3, 0), girth, 0.2f, 0.5f, branchWidth, 1, 1.0f); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { float leafMultiplier = height / 6.0f; if (leafMultiplier > 2) { leafMultiplier = 2; } for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCircle(world, rand, branchEnd, 2, Math.round(3 * leafMultiplier), 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCircle(level, rand, branchEnd, 2, Math.round(3 * leafMultiplier), 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); if (rand.nextBoolean()) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 0.5f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 0.5f * leafMultiplier + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureTree.java b/src/main/java/forestry/arboriculture/worldgen/FeatureTree.java index be03b74d3..bfd3e6918 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureTree.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureTree.java @@ -38,36 +38,36 @@ protected FeatureTree(ITreeGenData tree, int baseHeight, int heightVariation) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); return Set.of(); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafHeight = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafHeight--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafHeight--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafHeight--, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafHeight, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafHeight--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafHeight--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafHeight--, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafHeight, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.AIR, contour); } @Override - protected void generateExtras(LevelAccessor world, RandomSource rand, BlockPos startPos) { + protected void generateExtras(LevelAccessor level, RandomSource rand, BlockPos startPos) { if (hasPods()) { - FeatureHelper.generatePods(tree, world, rand, startPos, height, minPodHeight, girth, FeatureHelper.EnumReplaceMode.AIR); + FeatureHelper.generatePods(tree, level, rand, startPos, height, minPodHeight, girth, FeatureHelper.EnumReplaceMode.AIR); } } @Override @Nullable - public BlockPos getValidGrowthPos(LevelAccessor world, BlockPos pos) { - return tree.getGrowthPos(tree.getDefaultGenome(), world, pos, girth, height); + public BlockPos getValidGrowthPos(LevelAccessor level, BlockPos pos) { + return this.tree.getGrowthPos(this.tree.getDefaultGenome(), level, pos, this.girth, this.height); } @Override - public final void preGenerate(IGenome genome, LevelAccessor world, RandomSource rand, BlockPos startPos) { - this.height = determineHeight(world, rand, this.baseHeight, this.heightVariation); + public final void preGenerate(IGenome genome, LevelAccessor level, RandomSource rand, BlockPos startPos) { + this.height = determineHeight(level, rand, this.baseHeight, this.heightVariation); this.girth = this.tree.getGirth(genome); } @@ -77,10 +77,10 @@ protected int modifyByHeight(LevelAccessor world, int val, int min, int max) { return determined < min ? min : Math.min(determined, max); } - private int determineHeight(LevelAccessor world, RandomSource rand, int required, int variation) { + private int determineHeight(LevelAccessor world, RandomSource rand, int baseHeight, int heightVariation) { //ITreeModifier treeModifier = SpeciesUtil.TREE_TYPE.get().getTreekeepingMode(world); - int baseHeight = required + rand.nextInt(variation); - int height = Math.round(baseHeight * tree.getHeightModifier(tree.getDefaultGenome()));/* * treeModifier.getHeightModifier(tree.getGenome(), 1f)*/ - return height < minHeight ? minHeight : Math.min(height, maxHeight); + int height = baseHeight + rand.nextInt(heightVariation); + int adjustedHeight = Math.round(height * tree.getHeightModifier(tree.getDefaultGenome()));/* * treeModifier.getHeightModifier(tree.getGenome(), 1f)*/ + return adjustedHeight < minHeight ? minHeight : Math.min(adjustedHeight, maxHeight); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureWalnut.java b/src/main/java/forestry/arboriculture/worldgen/FeatureWalnut.java index 9d1404006..0ecf2b713 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureWalnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureWalnut.java @@ -27,15 +27,15 @@ public FeatureWalnut(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); Set branchEnds = new HashSet<>(); int branchHeight = height - 3; float branchSize = 2; while (branchHeight >= 3) { - branchEnds.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.2f, 0.2f, (int) branchSize, 1, 0.5f)); + branchEnds.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.2f, 0.2f, (int) branchSize, 1, 0.5f)); branchHeight--; branchSize += 0.25f; } @@ -44,20 +44,20 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); float branchSize = 2; while (leafSpawn >= 3) { int leafRadius = Math.min(4, (int) branchSize); for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCircle(world, rand, branchEnd, leafRadius, 2, 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCircle(level, rand, branchEnd, leafRadius, 2, 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.SOFT, contour); } leafSpawn--; branchSize += 0.25f; diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureWenge.java b/src/main/java/forestry/arboriculture/worldgen/FeatureWenge.java index 448af6d5a..a3d4adc8f 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureWenge.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureWenge.java @@ -27,15 +27,15 @@ public FeatureWenge(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); Set branchEnds = new HashSet<>(); float branchSize = 3; int branchHeight = height + 1; while (branchHeight > 1) { - branchEnds.addAll(FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.2f, 0.2f, (int) branchSize, 2, 0.75f)); + branchEnds.addAll(FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, branchHeight, 0), girth, 0.2f, 0.2f, (int) branchSize, 2, 0.75f)); branchHeight--; branchSize += 0.5f; } @@ -44,22 +44,22 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > 1) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); leafSpawn--; } for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCircle(world, rand, branchEnd, 3, 3, 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCircle(level, rand, branchEnd, 3, 3, 2, leaf, 1.0f, FeatureHelper.EnumReplaceMode.SOFT, contour); } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureWillow.java b/src/main/java/forestry/arboriculture/worldgen/FeatureWillow.java index 46c07b24b..1da3a80a1 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureWillow.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureWillow.java @@ -27,15 +27,15 @@ public FeatureWillow(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0.8f, null, 0); - FeatureHelper.generateSupportStems(wood, world, rand, startPos, height, girth, 0.2f, 0.2f); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0.8f, null, 0); + FeatureHelper.generateSupportStems(wood, level, rand, startPos, height, girth, 0.2f, 0.2f); int leafSpawn = height - 4; while (leafSpawn > 2) { // support branches for tall willows, keeps the leaves from decaying immediately if ((leafSpawn - 3) % 6 == 0) { - FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, leafSpawn, 0), girth, 0, 0, 2, 1, 1.0f); + FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, leafSpawn, 0), girth, 0, 0, 2, 1, 1.0f); } leafSpawn--; } @@ -44,21 +44,21 @@ public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeB } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 3f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > 2) { - FeatureHelper.generateCircleFromTreeStartPos(world, rand, startPos.offset(0, leafSpawn--, 0), girth, 4f, 2, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCircleFromTreeStartPos(level, rand, startPos.offset(0, leafSpawn--, 0), girth, 4f, 2, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); } - FeatureHelper.generateCircleFromTreeStartPos(world, rand, startPos.offset(0, leafSpawn--, 0), girth, 4f, 1, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); - FeatureHelper.generateCircleFromTreeStartPos(world, rand, startPos.offset(0, leafSpawn--, 0), girth, 4f, 1, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); - FeatureHelper.generateCircleFromTreeStartPos(world, rand, startPos.offset(0, leafSpawn, 0), girth, 4f, 1, 1, leaf, 0.4f, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCircleFromTreeStartPos(level, rand, startPos.offset(0, leafSpawn--, 0), girth, 4f, 1, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCircleFromTreeStartPos(level, rand, startPos.offset(0, leafSpawn--, 0), girth, 4f, 1, 1, leaf, 1.0f, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCircleFromTreeStartPos(level, rand, startPos.offset(0, leafSpawn, 0), girth, 4f, 1, 1, leaf, 0.4f, FeatureHelper.EnumReplaceMode.AIR, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/FeatureZebrawood.java b/src/main/java/forestry/arboriculture/worldgen/FeatureZebrawood.java index 9f5a5a611..32fae6519 100644 --- a/src/main/java/forestry/arboriculture/worldgen/FeatureZebrawood.java +++ b/src/main/java/forestry/arboriculture/worldgen/FeatureZebrawood.java @@ -26,30 +26,30 @@ public FeatureZebrawood(ITreeGenData tree) { } @Override - public Set generateTrunk(LevelAccessor world, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { - FeatureHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - FeatureHelper.generateSupportStems(wood, world, rand, startPos, height, girth, 0.8f, 0.3f); + public Set generateTrunk(LevelAccessor level, RandomSource rand, TreeBlockTypeLog wood, BlockPos startPos) { + FeatureHelper.generateTreeTrunk(level, rand, wood, startPos, height, girth, 0, 0, null, 0); + FeatureHelper.generateSupportStems(wood, level, rand, startPos, height, girth, 0.8f, 0.3f); - return FeatureHelper.generateBranches(world, rand, wood, startPos.offset(0, height - 4, 0), girth, 0, 0.25f, 3, 2, 0.75f); + return FeatureHelper.generateBranches(level, rand, wood, startPos.offset(0, height - 4, 0), girth, 0, 0.25f, 3, 2, 0.75f); } @Override - protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { + protected void generateLeaves(LevelAccessor level, RandomSource rand, TreeBlockTypeLeaf leaf, TreeContour contour, BlockPos startPos) { for (BlockPos branchEnd : contour.getBranchEnds()) { - FeatureHelper.generateCylinderFromPos(world, leaf, branchEnd, 1.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateCylinderFromPos(level, leaf, branchEnd, 1.0f + girth, 2, FeatureHelper.EnumReplaceMode.AIR, contour); } int leafSpawn = height + 1; - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 0.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); while (leafSpawn > height - 4) { - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn--, 0), girth, 2.5f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); } - FeatureHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); + FeatureHelper.generateCylinderFromTreeStartPos(level, leaf, startPos.offset(0, leafSpawn, 0), girth, 1.9f + girth, 1, FeatureHelper.EnumReplaceMode.SOFT, contour); // Add some smaller twigs below for flavour for (int times = 0; times < height / 4; times++) { @@ -59,7 +59,7 @@ protected void generateLeaves(LevelAccessor world, RandomSource rand, TreeBlockT } int x_off = -1 + rand.nextInt(3); int y_off = -1 + rand.nextInt(3); - FeatureHelper.generateSphere(world, startPos.offset(x_off, h, y_off), 1 + rand.nextInt(1), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); + FeatureHelper.generateSphere(level, startPos.offset(x_off, h, y_off), 1 + rand.nextInt(1), leaf, FeatureHelper.EnumReplaceMode.AIR, contour); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/TreeContour.java b/src/main/java/forestry/arboriculture/worldgen/TreeContour.java index 3e6fd9177..52d26670e 100644 --- a/src/main/java/forestry/arboriculture/worldgen/TreeContour.java +++ b/src/main/java/forestry/arboriculture/worldgen/TreeContour.java @@ -1,8 +1,6 @@ package forestry.arboriculture.worldgen; import javax.annotation.Nullable; -import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -11,19 +9,16 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox; /** - * Helper class for storing data that is relevant to generating trees + * A tree contour holds branch end positions and leaf positions. */ -public interface TreeContour { +public sealed interface TreeContour { TreeContour EMPTY = new Empty(); - default void addLeaf(BlockPos pos) { - } + void addLeaf(BlockPos pos); - default Collection getBranchEnds() { - return Collections.emptyList(); - } + List getBranchEnds(); - class Impl implements TreeContour { + final class Impl implements TreeContour { public final Set leavePositions; public final List branchEnds; @@ -53,9 +48,18 @@ public List getBranchEnds() { } } - class Empty implements TreeContour { + final class Empty implements TreeContour { private Empty() { } + + @Override + public void addLeaf(BlockPos pos) { + } + + @Override + public List getBranchEnds() { + return List.of(); + } } } diff --git a/src/main/java/forestry/core/utils/VecUtil.java b/src/main/java/forestry/core/utils/VecUtil.java index 65cc657b4..fc27c46b0 100644 --- a/src/main/java/forestry/core/utils/VecUtil.java +++ b/src/main/java/forestry/core/utils/VecUtil.java @@ -24,6 +24,9 @@ import net.minecraft.world.level.levelgen.Heightmap; public final class VecUtil { + /** + * Sorts positions by height in descending order + */ public static final Comparator TOP_DOWN_COMPARATOR = (a, b) -> Integer.compare(b.getY(), a.getY()); public static BlockPos getRandomPositionInArea(RandomSource random, Vec3i area) { diff --git a/src/main/java/forestry/core/worldgen/FeatureBase.java b/src/main/java/forestry/core/worldgen/FeatureBase.java index 44fe91d0a..8a5a373cf 100644 --- a/src/main/java/forestry/core/worldgen/FeatureBase.java +++ b/src/main/java/forestry/core/worldgen/FeatureBase.java @@ -31,5 +31,5 @@ public boolean place(FeaturePlaceContext context) { public abstract IGenome getDefaultGenome(); - public abstract boolean place(IGenome genome, LevelAccessor world, RandomSource rand, BlockPos pos, boolean forced); + public abstract boolean place(IGenome genome, LevelAccessor level, RandomSource rand, BlockPos pos, boolean forced); } diff --git a/src/main/java/forestry/core/worldgen/FeatureHelper.java b/src/main/java/forestry/core/worldgen/FeatureHelper.java index 909f905db..20c9c1850 100644 --- a/src/main/java/forestry/core/worldgen/FeatureHelper.java +++ b/src/main/java/forestry/core/worldgen/FeatureHelper.java @@ -24,8 +24,6 @@ import forestry.arboriculture.worldgen.TreeBlockType; import forestry.arboriculture.worldgen.TreeContour; import forestry.core.utils.VecUtil; -//import forestry.arboriculture.worldgen.ITreeBlockType; -//import forestry.arboriculture.worldgen.TreeBlockType; public class FeatureHelper { diff --git a/src/main/java/forestry/plugin/DefaultTreeSpecies.java b/src/main/java/forestry/plugin/DefaultTreeSpecies.java index bd04ccfd7..cc1801864 100644 --- a/src/main/java/forestry/plugin/DefaultTreeSpecies.java +++ b/src/main/java/forestry/plugin/DefaultTreeSpecies.java @@ -175,7 +175,7 @@ public static void register(IArboricultureRegistration arboriculture) { .setRarity(0.0015f); // Bush Cherry (Chinese Bush Cherry) - arboriculture.registerSpecies(ForestryTreeSpecies.CHERRY_VANILLA, GENUS_PRUNUS, SPECIES_CHERRY_VANILLA) + arboriculture.registerSpecies(ForestryTreeSpecies.CHERRY_VANILLA, GENUS_PRUNUS, SPECIES_CHERRY_VANILLA, true, new Color(), VanillaWoodType.CHERRY) .setTreeFeature(FeatureCherryVanilla::new); // Lemon