Fixed trees growing from saplings

This commit is contained in:
Adubbz 2019-12-27 17:55:04 +11:00
parent fda42522f1
commit e209b53009
32 changed files with 179 additions and 184 deletions

View file

@ -12,16 +12,14 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.trees.BigTree;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.DefaultBiomeFeatures;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.HugeTreeFeatureConfig;
import net.minecraft.world.gen.feature.TreeFeatureConfig;
import net.minecraft.world.gen.feature.*;
import javax.annotation.Nullable;
import java.util.Random;
public abstract class BigTreeNoConfig extends BigTree
public abstract class BigTreeDefaultConfig extends BigTree
{
@Override
@Nullable
@ -37,8 +35,8 @@ public abstract class BigTreeNoConfig extends BigTree
return null;
}
protected abstract Feature<?> getFeature(Random random);
protected abstract Feature<?> getBigFeature(Random random);
protected abstract Feature<? extends BaseTreeFeatureConfig> getFeature(Random random);
protected abstract Feature<? extends BaseTreeFeatureConfig> getBigFeature(Random random);
@Override
public boolean growTree(IWorld world, ChunkGenerator<?> generator, BlockPos pos, BlockState state, Random random)
@ -54,7 +52,7 @@ public abstract class BigTreeNoConfig extends BigTree
}
}
Feature<?> feature = this.getFeature(random);
Feature<BaseTreeFeatureConfig> feature = (Feature<BaseTreeFeatureConfig>)this.getFeature(random);
if (feature == null)
{
@ -63,7 +61,7 @@ public abstract class BigTreeNoConfig extends BigTree
else
{
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
if (feature.place(world, generator, random, pos, null))
if (feature.place(world, generator, random, pos, DefaultBiomeFeatures.NORMAL_TREE_CONFIG))
{
return true;
}
@ -78,7 +76,7 @@ public abstract class BigTreeNoConfig extends BigTree
@Override
public boolean placeMega(IWorld world, ChunkGenerator<?> generator, BlockPos pos, BlockState state, Random random, int x, int z)
{
Feature<?> feature = this.getBigFeature(random);
Feature<BaseTreeFeatureConfig> feature = (Feature<BaseTreeFeatureConfig>)this.getBigFeature(random);
if (feature == null)
{
return false;
@ -90,7 +88,7 @@ public abstract class BigTreeNoConfig extends BigTree
world.setBlockState(pos.add(x + 1, 0, z), blockstate, 4);
world.setBlockState(pos.add(x, 0, z + 1), blockstate, 4);
world.setBlockState(pos.add(x + 1, 0, z + 1), blockstate, 4);
if (feature.place(world, generator, random, pos.add(x, 0, z), null))
if (feature.place(world, generator, random, pos.add(x, 0, z), DefaultBiomeFeatures.NORMAL_TREE_CONFIG))
{
return true;
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class DeadTree extends TreeNoConfig
public class DeadTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return random.nextInt(10) == 0 ? BOPBiomeFeatures.DYING_TREE : BOPBiomeFeatures.SMALL_DEAD_TREE;
}

View file

@ -5,16 +5,16 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class FirTree extends BigTreeNoConfig
public class FirTree extends BigTreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return BOPBiomeFeatures.FIR_TREE;
}
@Override
protected Feature<?> getBigFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getBigFeature(Random random)
{
return BOPBiomeFeatures.FIR_TREE_LARGE;
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class FloweringOakTree extends TreeNoConfig
public class FloweringOakTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_FLOWERING_OAK_TREE : BOPBiomeFeatures.FLOWERING_OAK_TREE);
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class HellbarkTree extends TreeNoConfig
public class HellbarkTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return BOPBiomeFeatures.HELLBARK_TREE;
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class JacarandaTree extends TreeNoConfig
public class JacarandaTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_JACARANDA_TREE : BOPBiomeFeatures.JACARANDA_TREE);
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class MagicTree extends TreeNoConfig
public class MagicTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_MAGIC_TREE : BOPBiomeFeatures.MAGIC_TREE);
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class MahoganyTree extends TreeNoConfig
public class MahoganyTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return BOPBiomeFeatures.MAHOGANY_TREE;
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class MapleTree extends TreeNoConfig
public class MapleTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_MAPLE_TREE : BOPBiomeFeatures.MAPLE_TREE);
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class OrangeAutumnTree extends TreeNoConfig
public class OrangeAutumnTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_ORANGE_AUTUMN_TREE : BOPBiomeFeatures.ORANGE_AUTUMN_TREE);
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class OriginTree extends TreeNoConfig
public class OriginTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_ORIGIN_TREE : BOPBiomeFeatures.ORIGIN_TREE);
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class PalmTree extends TreeNoConfig
public class PalmTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return BOPBiomeFeatures.PALM_TREE;
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class PinkCherryTree extends TreeNoConfig
public class PinkCherryTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_PINK_CHERRY_TREE : BOPBiomeFeatures.PINK_CHERRY_TREE);
}

View file

@ -5,16 +5,16 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class RedwoodTree extends BigTreeNoConfig
public class RedwoodTree extends BigTreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return BOPBiomeFeatures.REDWOOD_TREE;
}
@Override
protected Feature<?> getBigFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getBigFeature(Random random)
{
return BOPBiomeFeatures.REDWOOD_TREE_MEDIUM;
}

View file

@ -12,13 +12,14 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.trees.Tree;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.DefaultBiomeFeatures;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.*;
import javax.annotation.Nullable;
import java.util.Random;
public abstract class TreeNoConfig extends Tree
public abstract class TreeDefaultConfig extends Tree
{
@Override
@Nullable
@ -27,12 +28,12 @@ public abstract class TreeNoConfig extends Tree
return null;
}
protected abstract Feature<?> getFeature(Random random);
protected abstract Feature<? extends BaseTreeFeatureConfig> getFeature(Random random);
@Override
public boolean growTree(IWorld world, ChunkGenerator<?> generator, BlockPos pos, BlockState state, Random random)
{
Feature<?> feature = this.getFeature(random);
Feature<BaseTreeFeatureConfig> feature = (Feature<BaseTreeFeatureConfig>)this.getFeature(random);
if (feature == null)
{
return false;
@ -40,7 +41,7 @@ public abstract class TreeNoConfig extends Tree
else
{
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 4);
if (feature.place(world, generator, random, pos, null))
if (feature.place(world, generator, random, pos, DefaultBiomeFeatures.NORMAL_TREE_CONFIG))
{
return true;
}

View file

@ -5,16 +5,16 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class UmbranTree extends BigTreeNoConfig
public class UmbranTree extends BigTreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return BOPBiomeFeatures.UMBRAN_TREE;
}
@Override
protected Feature<?> getBigFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getBigFeature(Random random)
{
return BOPBiomeFeatures.TALL_UMBRAN_TREE;
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class WhiteCherryTree extends TreeNoConfig
public class WhiteCherryTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_WHITE_CHERRY_TREE : BOPBiomeFeatures.WHITE_CHERRY_TREE);
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class WillowTree extends TreeNoConfig
public class WillowTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return BOPBiomeFeatures.WILLOW_TREE;
}

View file

@ -5,10 +5,10 @@ import net.minecraft.world.gen.feature.*;
import java.util.Random;
public class YellowAutumnTree extends TreeNoConfig
public class YellowAutumnTree extends TreeDefaultConfig
{
@Override
protected Feature<?> getFeature(Random random)
protected Feature<? extends BaseTreeFeatureConfig> getFeature(Random random)
{
return (random.nextInt(10) == 0 ? BOPBiomeFeatures.BIG_YELLOW_AUTUMN_TREE : BOPBiomeFeatures.YELLOW_AUTUMN_TREE);
}

View file

@ -185,12 +185,12 @@ public class BasicTreeFeature extends TreeFeatureBase
}
else
{
this.setLeaves(world, leavesPos);
this.placeLeaves(world, leavesPos, changedLeaves, boundingBox);
}
}
else
{
this.setLeaves(world, leavesPos);
this.placeLeaves(world, leavesPos, changedLeaves, boundingBox);
}
}
}
@ -292,7 +292,7 @@ public class BasicTreeFeature extends TreeFeatureBase
BlockPos blockpos2 = start.up(layer);
if (this.replace.matches(world, blockpos2))
{
this.setLog(changedBlocks, world, start.up(layer), boundingBox);
this.placeLog(world, start.up(layer), changedBlocks, boundingBox);
}
}
}

View file

@ -99,16 +99,16 @@ public class BigTreeFeature extends TreeFeatureBase
if (rand == 0)
{
this.setBlock(world, blockpos, this.altLeaves, changedBlocks, boundingBox);
this.placeBlock(world, blockpos, this.altLeaves, changedBlocks, boundingBox);
}
else
{
this.setBlock(world, blockpos, this.leaves, changedBlocks, boundingBox);
this.placeBlock(world, blockpos, this.leaves, changedBlocks, boundingBox);
}
}
else
{
this.setBlock(world, blockpos, this.leaves, changedBlocks, boundingBox);
this.placeBlock(world, blockpos, this.leaves, changedBlocks, boundingBox);
}
}
}
@ -219,7 +219,7 @@ public class BigTreeFeature extends TreeFeatureBase
BlockPos deltaPos = startPos.add((double)(0.5F + (float)j * dx), (double)(0.5F + (float)j * dy), (double)(0.5F + (float)j * dz));
if (set)
{
this.setLog(changedBlocks, world, deltaPos, this.getLogAxis(startPos, deltaPos), boundingBox);
this.placeLog(world, deltaPos, this.getLogAxis(startPos, deltaPos), changedBlocks, boundingBox);
}
else if (!this.isFree(world, deltaPos))
{

View file

@ -79,31 +79,31 @@ public class BulbTreeFeature extends TreeFeatureBase
}
// generates a 'branch' of a leaf layer
public void generateBranch(IWorld world, Random random, BlockPos pos, Direction direction)
public void generateBranch(IWorld world, Random random, BlockPos pos, Direction direction, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
Direction sideways = direction.rotateY();
this.setLeaves(world, pos.offset(direction, 1));
this.setLeaves(world, pos.up().offset(direction, 1));
this.placeLeaves(world, pos.offset(direction, 1), changedLeaves, boundingBox);
this.placeLeaves(world, pos.up().offset(direction, 1), changedLeaves, boundingBox);
if (random.nextInt(3) > 0)
{
this.setLeaves(world, pos.up().offset(direction, 1).offset(sideways, 1));
this.placeLeaves(world, pos.up().offset(direction, 1).offset(sideways, 1), changedLeaves, boundingBox);
}
}
// generates a layer of leafs (2 blocks high)
public void generateLeafLayer(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox, IWorld world, Random random, BlockPos pos)
public void generateLeafLayer(IWorld world, Random random, BlockPos pos, Set<BlockPos> changedLogs, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
for (Direction direction : Direction.Plane.HORIZONTAL)
{
this.generateBranch(world, random, pos, direction);
this.generateBranch(world, random, pos, direction, changedLeaves, boundingBox);
}
// add the trunk in the middle
this.setLog(changedBlocks, world, pos, boundingBox);
this.setLog(changedBlocks, world, pos.up(), boundingBox);
this.placeLog(world, pos, changedLogs, boundingBox);
this.placeLog(world, pos.up(), changedLogs, boundingBox);
}
public void generateTop(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox, IWorld world, Random random, BlockPos pos, int topHeight)
public void generateTop(IWorld world, Random random, BlockPos pos, int topHeight, Set<BlockPos> changedLogs, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
for (int y = 0; y < topHeight; y++)
{
@ -115,17 +115,17 @@ public class BulbTreeFeature extends TreeFeatureBase
{
if (Math.abs(x) < radius || Math.abs(z) < radius || random.nextInt(2) == 0)
{
this.setLeaves(world, pos.add(x, y, z));
this.placeLeaves(world, pos.add(x, y, z), changedLeaves, boundingBox);
}
}
}
if (y < topHeight - 1)
{
// add the trunk in the middle
this.setLog(changedBlocks, world, pos.add(0, y, 0), boundingBox);
this.placeLog(world, pos.add(0, y, 0), changedLogs, boundingBox);
} else {
// add leaves on top for certain
this.setLeaves(world, pos.add(0, y, 0));
this.placeLeaves(world, pos.add(0, y, 0), changedLeaves, boundingBox);
}
}
}
@ -133,7 +133,6 @@ public class BulbTreeFeature extends TreeFeatureBase
@Override
protected boolean place(Set<BlockPos> changedLogs, Set<BlockPos> changedLeaves, IWorld world, Random random, BlockPos startPos, MutableBoundingBox boundingBox)
{
// Move down until we reach the ground
while (startPos.getY() > 1 && world.isAirBlock(startPos) || world.getBlockState(startPos).getMaterial() == Material.LEAVES) {startPos = startPos.down();}
@ -163,19 +162,19 @@ public class BulbTreeFeature extends TreeFeatureBase
// Generate bottom of tree (trunk only)
for(int i = 0; i < baseHeight; i++)
{
this.setLog(changedLogs, world, pos, boundingBox);
this.placeLog(world, pos, changedLogs, boundingBox);
pos = pos.up();
}
// Generate middle of the tree - 2 steps at a time (trunk and leaves)
for (int i = 0; i < numBranches; i++)
{
this.generateLeafLayer(changedLogs, boundingBox, world, random, pos);
this.generateLeafLayer(world, random, pos, changedLogs, changedLeaves, boundingBox);
pos = pos.up(2);
}
// Generate the top of the tree
this.generateTop(changedLogs, boundingBox, world, random, pos, topHeight);
this.generateTop(world, random, pos, topHeight, changedLogs, changedLeaves, boundingBox);
// Add vines
this.addVines(world, random, startPos, baseHeight, height, 3, 10);

View file

@ -72,7 +72,7 @@ public class BushTreeFeature extends TreeFeatureBase
// log in the center
if (height - y > 1)
{
this.setLog(changedLogs, world, pos.add(0, y, 0), boundingBox);
this.placeLog(world, pos.add(0, y, 0), changedLogs, boundingBox);
}
//Reduces the radius closer to the top of the bush
@ -93,12 +93,12 @@ public class BushTreeFeature extends TreeFeatureBase
}
else
{
this.setLeaves(world, pos.add(x, y, z));
this.placeLeaves(world, pos.add(x, y, z), changedLeaves, boundingBox);
}
}
else
{
this.setLeaves(world, pos.add(x, y, z));
this.placeLeaves(world, pos.add(x, y, z), changedLeaves, boundingBox);
}
}
}

View file

@ -97,7 +97,7 @@ public class CypressTreeFeature extends TreeFeatureBase
}
// generates a layer of leafs
public void generateLeafLayer(IWorld world, Random rand, BlockPos pos, int leavesRadius, int trunkStart, int trunkEnd)
public void generateLeafLayer(IWorld world, Random rand, BlockPos pos, int leavesRadius, int trunkStart, int trunkEnd, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
int start = trunkStart - leavesRadius;
int end = trunkEnd + leavesRadius;
@ -113,13 +113,13 @@ public class CypressTreeFeature extends TreeFeatureBase
// set leaves as long as it's not too far from the trunk to survive
if (distFromTrunk <= 2)
{
this.setLeaves(world, pos.add(x, 0, z));
this.placeLeaves(world, pos.add(x, 0, z), changedLeaves, boundingBox);
}
}
}
}
public void generateBranch(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox, IWorld world, Random rand, BlockPos pos, Direction direction, int length)
public void generateBranch(IWorld world, Random rand, BlockPos pos, Direction direction, int length, Set<BlockPos> changedLogs, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
Direction.Axis axis = direction.getAxis();
Direction sideways = direction.rotateY();
@ -131,15 +131,15 @@ public class CypressTreeFeature extends TreeFeatureBase
{
if (i < length || rand.nextInt(2) == 0)
{
this.setLeaves(world, pos1.offset(sideways, j));
this.placeLeaves(world, pos1.offset(sideways, j), changedLeaves, boundingBox);
}
}
if (length - i > 2)
{
this.setLeaves(world, pos1.up());
this.setLeaves(world, pos1.up().offset(sideways, -1));
this.setLeaves(world, pos1.up().offset(sideways, 1));
this.setLog(changedBlocks, world, pos1, axis, boundingBox);
this.placeLeaves(world, pos1.up(), changedLeaves, boundingBox);
this.placeLeaves(world, pos1.up().offset(sideways, -1), changedLeaves, boundingBox);
this.placeLeaves(world, pos1.up().offset(sideways, 1), changedLeaves, boundingBox);
this.placeLog(world, pos1, axis, changedLogs, boundingBox);
}
}
}
@ -179,7 +179,7 @@ public class CypressTreeFeature extends TreeFeatureBase
BlockPos pos = startPos.up(height);
// Leaves at the top
this.setLeaves(world, pos);
this.placeLeaves(world, pos, changedLeaves, boundingBox);
pos.down();
// Add layers of leaves
@ -199,18 +199,18 @@ public class CypressTreeFeature extends TreeFeatureBase
if (radius == 0)
{
this.setLeaves(world, pos);
this.placeLeaves(world, pos, changedLeaves, boundingBox);
}
else if (radius < 2)
{
this.generateLeafLayer(world, random, pos, radius, trunkStart, trunkEnd);
this.generateLeafLayer(world, random, pos, radius, trunkStart, trunkEnd, changedLeaves, boundingBox);
}
else
{
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkStart, 0, trunkStart), Direction.NORTH, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkEnd, 0, trunkStart), Direction.EAST, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkEnd, 0, trunkEnd), Direction.SOUTH, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkStart, 0, trunkEnd), Direction.WEST, radius);
this.generateBranch(world, random, pos.add(trunkStart, 0, trunkStart), Direction.NORTH, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkEnd, 0, trunkStart), Direction.EAST, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkEnd, 0, trunkEnd), Direction.SOUTH, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkStart, 0, trunkEnd), Direction.WEST, radius, changedLogs, changedLeaves, boundingBox);
}
pos = pos.down();
}
@ -232,7 +232,7 @@ public class CypressTreeFeature extends TreeFeatureBase
{
for (int z = trunkStart; z <= trunkEnd; z++)
{
this.setLog(changedLogs, world, startPos.add(x, y, z), boundingBox);
this.placeLog(world, startPos.add(x, y, z), changedLogs, boundingBox);
}
}
}
@ -241,11 +241,12 @@ public class CypressTreeFeature extends TreeFeatureBase
}
@Override
public boolean setLeaves(IWorld world, BlockPos pos)
public boolean placeLeaves(IWorld world, BlockPos pos, Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
{
if (world.getBlockState(pos).canBeReplacedByLeaves(world, pos))
{
this.setBlockState(world, pos, this.leaves);
this.placeBlock(world, pos, this.leaves, changedBlocks, boundingBox);
return true;
}
return false;

View file

@ -56,7 +56,7 @@ public class MahoganyTreeFeature extends BasicTreeFeature
if (this.replace.matches(world, middlePos))
{
this.setLog(changedBlocks, world, middlePos, boundingBox);
this.placeLog(world, middlePos, changedBlocks, boundingBox);
}
}
@ -74,11 +74,11 @@ public class MahoganyTreeFeature extends BasicTreeFeature
{
BlockPos pos;
if (replace.matches(world, pos = middle.offset(direction))) this.setLog(changedBlocks, world, pos, direction.getAxis(), boundingBox);
if (replace.matches(world, pos = middle.offset(direction))) this.placeLog(world, pos, direction.getAxis(), changedBlocks, boundingBox);
for (int i = 0; i <= height - 1; i++)
{
if (replace.matches(world, pos = middle.offset(direction, 2).up(i + 1))) this.setLog(changedBlocks, world, pos, Direction.Axis.Y, boundingBox);
if (replace.matches(world, pos = middle.offset(direction, 2).up(i + 1))) this.placeLog(world, pos, Direction.Axis.Y, changedBlocks, boundingBox);
}
Direction logDirection = direction.rotateY();
@ -86,7 +86,7 @@ public class MahoganyTreeFeature extends BasicTreeFeature
//Extend inner branches outwards to prevent decay
for (int i = -1; i <= 1; i++)
{
if (replace.matches(world, pos = middle.offset(direction, 3).offset(logDirection, i).up(height - 1))) this.setLog(changedBlocks, world, pos, logDirection.getAxis(), boundingBox);
if (replace.matches(world, pos = middle.offset(direction, 3).offset(logDirection, i).up(height - 1))) this.placeLog(world, pos, logDirection.getAxis(), changedBlocks, boundingBox);
}
}
}

View file

@ -101,12 +101,12 @@ public class PalmTreeFeature extends TreeFeatureBase
if (step == heightMinusTop)
{
// Generate top of tree
this.setLog(changedLogs, world, offsetPos, boundingBox);
generateLeavesTop(world, offsetPos, leavesRadius);
this.placeLog(world, offsetPos, changedLogs, boundingBox);
generateLeavesTop(world, offsetPos, leavesRadius, changedLeaves, boundingBox);
break;
}
this.setLog(changedLogs, world, offsetPos, boundingBox);
this.placeLog(world, offsetPos, changedLogs, boundingBox);
//As the height increases, slant more drastically
slantOffset *= slantMultiplier;
@ -136,31 +136,31 @@ public class PalmTreeFeature extends TreeFeatureBase
}
// generate the top of the tree (3 blocks)
public void generateLeavesTop(IWorld world, BlockPos pos, int maxRadius)
public void generateLeavesTop(IWorld world, BlockPos pos, int maxRadius, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
setLeaves(world, pos.add(2, -1, 0));
setLeaves(world, pos.add(-2, -1, 0));
setLeaves(world, pos.add(0, -1, 2));
setLeaves(world, pos.add(0, -1, -2));
placeLeaves(world, pos.add(2, -1, 0), changedLeaves, boundingBox);
placeLeaves(world, pos.add(-2, -1, 0), changedLeaves, boundingBox);
placeLeaves(world, pos.add(0, -1, 2), changedLeaves, boundingBox);
placeLeaves(world, pos.add(0, -1, -2), changedLeaves, boundingBox);
setLeaves(world, pos.add(1, 0, 0));
setLeaves(world, pos.add(-1, 0, 0));
setLeaves(world, pos.add(0, 0, 1));
setLeaves(world, pos.add(0, 0, -1));
setLeaves(world, pos.add(2, 0, 2));
setLeaves(world, pos.add(-2, 0, -2));
setLeaves(world, pos.add(2, 0, -2));
setLeaves(world, pos.add(-2, 0, 2));
placeLeaves(world, pos.add(1, 0, 0), changedLeaves, boundingBox);
placeLeaves(world, pos.add(-1, 0, 0), changedLeaves, boundingBox);
placeLeaves(world, pos.add(0, 0, 1), changedLeaves, boundingBox);
placeLeaves(world, pos.add(0, 0, -1), changedLeaves, boundingBox);
placeLeaves(world, pos.add(2, 0, 2), changedLeaves, boundingBox);
placeLeaves(world, pos.add(-2, 0, -2), changedLeaves, boundingBox);
placeLeaves(world, pos.add(2, 0, -2), changedLeaves, boundingBox);
placeLeaves(world, pos.add(-2, 0, 2), changedLeaves, boundingBox);
setLeaves(world, pos.add(1, 1, -1));
setLeaves(world, pos.add(-1, 1, 1));
setLeaves(world, pos.add(1, 1, 1));
setLeaves(world, pos.add(-1, 1, -1));
setLeaves(world, pos.add(0, 1, 0));
placeLeaves(world, pos.add(1, 1, -1), changedLeaves, boundingBox);
placeLeaves(world, pos.add(-1, 1, 1), changedLeaves, boundingBox);
placeLeaves(world, pos.add(1, 1, 1), changedLeaves, boundingBox);
placeLeaves(world, pos.add(-1, 1, -1), changedLeaves, boundingBox);
placeLeaves(world, pos.add(0, 1, 0), changedLeaves, boundingBox);
setLeaves(world, pos.add(2, 2, 0));
setLeaves(world, pos.add(-2, 2, 0));
setLeaves(world, pos.add(0, 2, 2));
setLeaves(world, pos.add(0, 2, -2));
placeLeaves(world, pos.add(2, 2, 0), changedLeaves, boundingBox);
placeLeaves(world, pos.add(-2, 2, 0), changedLeaves, boundingBox);
placeLeaves(world, pos.add(0, 2, 2), changedLeaves, boundingBox);
placeLeaves(world, pos.add(0, 2, -2), changedLeaves, boundingBox);
}
}

View file

@ -44,7 +44,6 @@ public class PoplarTreeFeature extends TreeFeatureBase
@Override
protected boolean place(Set<BlockPos> changedLogs, Set<BlockPos> changedLeaves, IWorld world, Random random, BlockPos startPos, MutableBoundingBox boundingBox)
{
// Move down until we reach the ground
while (startPos.getY() > 1 && world.isAirBlock(startPos) || world.getBlockState(startPos).getMaterial() == Material.LEAVES) {startPos = startPos.down();}
@ -72,7 +71,7 @@ public class PoplarTreeFeature extends TreeFeatureBase
// Generate bottom of tree (trunk only)
for(int i = 0; i < baseHeight; i++)
{
this.setLog(changedLogs, world, pos, boundingBox);
this.placeLog(world, pos, changedLogs, boundingBox);
pos = pos.up();
}
@ -82,7 +81,7 @@ public class PoplarTreeFeature extends TreeFeatureBase
{
for (int zz = -1; zz < 2; zz++)
{
this.setLeaves(world, pos.add(xx, i, zz));
this.placeLeaves(world, pos.add(xx, i, zz), changedLeaves, boundingBox);
}
}
}
@ -91,8 +90,8 @@ public class PoplarTreeFeature extends TreeFeatureBase
for(int i = 0; i < leavesHeight; i++)
{
int radius = radius(i, leavesHeight);
this.generateLeafLayer(world, pos, radius);
if (leavesHeight - i > 2) {this.setLog(changedLogs, world, pos, boundingBox);}
this.generateLeafLayer(world, pos, radius, changedLeaves, boundingBox);
if (leavesHeight - i > 2) {this.placeLog(world, pos, changedLogs, boundingBox);}
pos = pos.up();
}
@ -131,7 +130,7 @@ public class PoplarTreeFeature extends TreeFeatureBase
}
// generates a layer of leafs with the given radius
public void generateLeafLayer(IWorld world, BlockPos pos, int radius)
public void generateLeafLayer(IWorld world, BlockPos pos, int radius, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
for(int x = -radius; x <= radius; x++)
{
@ -141,7 +140,7 @@ public class PoplarTreeFeature extends TreeFeatureBase
{
if (x*x + z*z <= radius*radius)
{
this.setLeaves(world, pos.add(x, 0, z));
this.placeLeaves(world, pos.add(x, 0, z), changedLeaves, boundingBox);
}
}
else
@ -151,12 +150,12 @@ public class PoplarTreeFeature extends TreeFeatureBase
if (x == -radius || x == radius || z == -radius || z == radius)
{
if (world.getRandom().nextInt(3) != 0) {
this.setLeaves(world, pos.add(x, 0, z));
this.placeLeaves(world, pos.add(x, 0, z), changedLeaves, boundingBox);
}
}
else
{
this.setLeaves(world, pos.add(x, 0, z));
this.placeLeaves(world, pos.add(x, 0, z), changedLeaves, boundingBox);
}
}
}

View file

@ -86,7 +86,7 @@ public class RedwoodTreeFeature extends TreeFeatureBase
}
// generates a layer of leafs
public void generateLeafLayer(IWorld world, Random rand, BlockPos pos, int leavesRadius, int trunkStart, int trunkEnd)
public void generateLeafLayer(IWorld world, Random rand, BlockPos pos, int leavesRadius, int trunkStart, int trunkEnd, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
int start = trunkStart - leavesRadius;
int end = trunkEnd + leavesRadius;
@ -102,13 +102,13 @@ public class RedwoodTreeFeature extends TreeFeatureBase
// set leaves as long as it's not too far from the trunk to survive
if (distFromTrunk < 4 || (distFromTrunk == 4 && rand.nextInt(2) == 0))
{
this.setLeaves(world, pos.add(x, 0, z));
this.placeLeaves(world, pos.add(x, 0, z), changedLeaves, boundingBox);
}
}
}
}
public void generateBranch(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox, IWorld world, Random rand, BlockPos pos, Direction direction, int length)
public void generateBranch(IWorld world, Random rand, BlockPos pos, Direction direction, int length, Set<BlockPos> changedLogs, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
Direction.Axis axis = direction.getAxis();
Direction sideways = direction.rotateY();
@ -120,15 +120,15 @@ public class RedwoodTreeFeature extends TreeFeatureBase
{
if (i < length || rand.nextInt(2) == 0)
{
this.setLeaves(world, pos1.offset(sideways, j));
this.placeLeaves(world, pos1.offset(sideways, j), changedLeaves, boundingBox);
}
}
if (length - i > 2)
{
this.setLeaves(world, pos1.up());
this.setLeaves(world, pos1.up().offset(sideways, -1));
this.setLeaves(world, pos1.up().offset(sideways, 1));
this.setLog(changedBlocks, world, pos1, axis, boundingBox);
this.placeLeaves(world, pos1.up(), changedLeaves, boundingBox);
this.placeLeaves(world, pos1.up().offset(sideways, -1), changedLeaves, boundingBox);
this.placeLeaves(world, pos1.up().offset(sideways, 1), changedLeaves, boundingBox);
this.placeLog(world, pos1, axis, changedLogs, boundingBox);
}
}
}
@ -168,7 +168,7 @@ public class RedwoodTreeFeature extends TreeFeatureBase
BlockPos pos = startPos.up(height);
// Leaves at the top
this.setLeaves(world, pos);
this.placeLeaves(world, pos, changedLeaves, boundingBox);
pos.down();
// Add layers of leaves
@ -183,18 +183,18 @@ public class RedwoodTreeFeature extends TreeFeatureBase
int radius = Math.min(Math.min((i + 2) / 4, 2 + (leavesHeight - i)), 4);
if (radius == 0)
{
this.setLeaves(world, pos);
this.placeLeaves(world, pos, changedLeaves, boundingBox);
}
else if (radius < 2)
{
this.generateLeafLayer(world, random, pos, radius, trunkStart, trunkEnd);
this.generateLeafLayer(world, random, pos, radius, trunkStart, trunkEnd, changedLeaves, boundingBox);
}
else
{
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkStart, 0, trunkStart), Direction.NORTH, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkEnd, 0, trunkStart), Direction.EAST, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkEnd, 0, trunkEnd), Direction.SOUTH, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkStart, 0, trunkEnd), Direction.WEST, radius);
this.generateBranch(world, random, pos.add(trunkStart, 0, trunkStart), Direction.NORTH, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkEnd, 0, trunkStart), Direction.EAST, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkEnd, 0, trunkEnd), Direction.SOUTH, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkStart, 0, trunkEnd), Direction.WEST, radius, changedLogs, changedLeaves, boundingBox);
}
pos = pos.down();
}
@ -216,7 +216,7 @@ public class RedwoodTreeFeature extends TreeFeatureBase
{
for (int z = trunkStart; z <= trunkEnd; z++)
{
this.setLog(changedLogs, world, startPos.add(x, y, z), boundingBox);
this.placeLog(world, startPos.add(x, y, z), changedLogs, boundingBox);
}
}
}

View file

@ -84,7 +84,7 @@ public class TaigaTreeFeature extends TreeFeatureBase
}
// generates a layer of leafs
public void generateLeafLayer(IWorld world, Random rand, BlockPos pos, int leavesRadius, int trunkStart, int trunkEnd)
public void generateLeafLayer(IWorld world, Random rand, BlockPos pos, int leavesRadius, int trunkStart, int trunkEnd, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
int start = trunkStart - leavesRadius;
int end = trunkEnd + leavesRadius;
@ -100,13 +100,13 @@ public class TaigaTreeFeature extends TreeFeatureBase
// set leaves as long as it's not too far from the trunk to survive
if (distFromTrunk < 4 || (distFromTrunk == 4 && rand.nextInt(2) == 0))
{
this.setLeaves(world, pos.add(x, 0, z));
this.placeLeaves(world, pos.add(x, 0, z), changedLeaves, boundingBox);
}
}
}
}
public void generateBranch(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox, IWorld world, Random rand, BlockPos pos, Direction direction, int length)
public void generateBranch(IWorld world, Random rand, BlockPos pos, Direction direction, int length, Set<BlockPos> changedLogs, Set<BlockPos> changedLeaves, MutableBoundingBox boundingBox)
{
Direction.Axis axis = direction.getAxis();
Direction sideways = direction.rotateY();
@ -118,15 +118,15 @@ public class TaigaTreeFeature extends TreeFeatureBase
{
if (i < length || rand.nextInt(2) == 0)
{
this.setLeaves(world, pos1.offset(sideways, j));
this.placeLeaves(world, pos1.offset(sideways, j), changedLeaves, boundingBox);
}
}
if (length - i > 2)
{
this.setLeaves(world, pos1.up());
this.setLeaves(world, pos1.up().offset(sideways, -1));
this.setLeaves(world, pos1.up().offset(sideways, 1));
this.setLog(changedBlocks, world, pos1, axis, boundingBox);
this.placeLeaves(world, pos1.up(), changedLeaves, boundingBox);
this.placeLeaves(world, pos1.up().offset(sideways, -1), changedLeaves, boundingBox);
this.placeLeaves(world, pos1.up().offset(sideways, 1), changedLeaves, boundingBox);
this.placeLog(world, pos1, axis, changedLogs, boundingBox);
}
}
}
@ -166,7 +166,7 @@ public class TaigaTreeFeature extends TreeFeatureBase
BlockPos pos = startPos.up(height);
// Leaves at the top
this.setLeaves(world, pos);
this.placeLeaves(world, pos, changedLeaves, boundingBox);
pos.down();
// Add layers of leaves
@ -181,18 +181,18 @@ public class TaigaTreeFeature extends TreeFeatureBase
int radius = Math.min(Math.min((i + 2) / 3, 3 + (leavesHeight - i)), 6);
if (radius == 0)
{
this.setLeaves(world, pos);
this.placeLeaves(world, pos, changedLeaves, boundingBox);
}
else if (radius < 4)
{
// for smallish radius, do simple leaf layers
if (i % 2 == 0)
{
this.generateLeafLayer(world, random, pos, radius, trunkStart, trunkEnd);
this.generateLeafLayer(world, random, pos, radius, trunkStart, trunkEnd, changedLeaves, boundingBox);
}
else
{
this.generateLeafLayer(world, random, pos, radius / 2, trunkStart, trunkEnd);
this.generateLeafLayer(world, random, pos, radius / 2, trunkStart, trunkEnd, changedLeaves, boundingBox);
}
}
else
@ -200,10 +200,10 @@ public class TaigaTreeFeature extends TreeFeatureBase
// for bigger radius, need branches
if (i % 2 == 0)
{
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkStart, 0, trunkStart), Direction.NORTH, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkEnd, 0, trunkStart), Direction.EAST, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkEnd, 0, trunkEnd), Direction.SOUTH, radius);
this.generateBranch(changedLogs, boundingBox, world, random, pos.add(trunkStart, 0, trunkEnd), Direction.WEST, radius);
this.generateBranch(world, random, pos.add(trunkStart, 0, trunkStart), Direction.NORTH, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkEnd, 0, trunkStart), Direction.EAST, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkEnd, 0, trunkEnd), Direction.SOUTH, radius, changedLogs, changedLeaves, boundingBox);
this.generateBranch(world, random, pos.add(trunkStart, 0, trunkEnd), Direction.WEST, radius, changedLogs, changedLeaves, boundingBox);
}
}
pos = pos.down();
@ -226,7 +226,7 @@ public class TaigaTreeFeature extends TreeFeatureBase
{
for (int z = trunkStart; z <= trunkEnd; z++)
{
this.setLog(changedLogs, world, startPos.add(x, y, z), boundingBox);
this.placeLog(world, startPos.add(x, y, z), changedLogs, boundingBox);
}
}
}

View file

@ -10,7 +10,6 @@ package biomesoplenty.common.world.gen.feature.tree;
import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.util.block.BlockUtil;
import biomesoplenty.common.util.block.IBlockPosQuery;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.*;
import net.minecraft.state.IProperty;
import net.minecraft.tags.BlockTags;
@ -18,15 +17,12 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldWriter;
import net.minecraft.world.gen.IWorldGenerationReader;
import net.minecraft.world.gen.feature.AbstractTreeFeature;
import net.minecraft.world.gen.feature.BaseTreeFeatureConfig;
import net.minecraft.world.gen.feature.TreeFeatureConfig;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;
public abstract class TreeFeatureBase extends AbstractTreeFeature<BaseTreeFeatureConfig>
{
@ -119,29 +115,30 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature<BaseTreeFeatur
this.maxHeight = maxHeight;
}
public boolean setLeaves(IWorld world, BlockPos pos)
public boolean placeLeaves(IWorld world, BlockPos pos, Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
{
if (this.replace.matches(world, pos))
{
this.setBlockState(world, pos, this.leaves);
this.placeBlock(world, pos, this.leaves, changedBlocks, boundingBox);
return true;
}
return false;
}
public boolean setLog(Set<BlockPos> changedBlocks, IWorld world, BlockPos pos, MutableBoundingBox boundingBox)
public boolean placeLog(IWorld world, BlockPos pos, Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
{
return this.setLog(changedBlocks, world, pos, null, boundingBox);
return this.placeLog(world, pos, null, changedBlocks, boundingBox);
}
public boolean setLog(Set<BlockPos> changedBlocks, IWorld world, BlockPos pos, Direction.Axis axis, MutableBoundingBox boundingBox)
public boolean placeLog(IWorld world, BlockPos pos, Direction.Axis axis, Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
{
BlockState directedLog = (axis != null && this.logAxisProperty != null) ? this.log.with(this.logAxisProperty, axis) : this.log;
if (this.replace.matches(world, pos))
{
// Logs must be added to the "changedBlocks" so that the leaves have their distance property updated,
// preventing incorrect decay
this.setBlock(world, pos, directedLog, changedBlocks, boundingBox);
this.placeBlock(world, pos, directedLog, changedBlocks, boundingBox);
return true;
}
return false;
@ -201,7 +198,7 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature<BaseTreeFeatur
return false;
}
protected boolean setBlock(IWorld world, BlockPos pos, BlockState state, Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
protected boolean placeBlock(IWorld world, BlockPos pos, BlockState state, Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
{
if (!isAirOrLeaves(world, pos) && !isTallPlants(world, pos) && !isWater(world, pos))
{

View file

@ -75,11 +75,11 @@ public class TrunkTreeFeature extends TreeFeatureBase
if (step == heightMinusTop)
{
// Generate top of tree
this.setLog(changedLogs, world, offsetPos, boundingBox);
this.placeLog(world, offsetPos, changedLogs, boundingBox);
break;
}
this.setLog(changedLogs, world, offsetPos, boundingBox);
this.placeLog(world, offsetPos, changedLogs, boundingBox);
}
return true;

View file

@ -92,7 +92,7 @@ public class TwigletTreeFeature extends TreeFeatureBase
float leafChance;
for (int y = 0; y < height; y++)
{
if (!this.setLog(changedLogs, world, pos.up(y), boundingBox))
if (!this.placeLog(world, pos.up(y), changedLogs, boundingBox))
{
// abandon if the log can't grow
return true;
@ -104,19 +104,19 @@ public class TwigletTreeFeature extends TreeFeatureBase
} // no leaves below base height
if (random.nextFloat() < leafChance)
{
this.setLeaves(world, pos.add(1, y, 0));
this.placeLeaves(world, pos.add(1, y, 0), changedLeaves, boundingBox);
}
if (random.nextFloat() < leafChance)
{
this.setLeaves(world, pos.add(-1, y, 0));
this.placeLeaves(world, pos.add(-1, y, 0), changedLeaves, boundingBox);
}
if (random.nextFloat() < leafChance)
{
this.setLeaves(world, pos.add(0, y, 1));
this.placeLeaves(world, pos.add(0, y, 1), changedLeaves, boundingBox);
}
if (random.nextFloat() < leafChance)
{
this.setLeaves(world, pos.add(0, y, -1));
this.placeLeaves(world, pos.add(0, y, -1), changedLeaves, boundingBox);
}
if (this.trunkFruit != Blocks.AIR.getDefaultState())
@ -138,7 +138,7 @@ public class TwigletTreeFeature extends TreeFeatureBase
}
}
// finish with leaves on top
this.setLeaves(world, pos.add(0, height, 0));
this.placeLeaves(world, pos.add(0, height, 0), changedLeaves, boundingBox);
return true;
}