Jump to content

[1.15.2] Custom Tree Trunk Issue [SOLVED]


MadHatAK

Recommended Posts

I have based my custom tree off of the spruce tree but, when I bonemeal it to make it grow, the trunk is only 1 block high (with random 1 more) and, the leaves generate as they should. Just no trunk to the top of the tree.

Tree Class

Spoiler

public class BlackSpruceTree extends SpruceTree
{
	public static final TreeFeatureConfig BLACKSPRUCE_TREE_CONFIG = (new TreeFeatureConfig.Builder(
			new SimpleBlockStateProvider(BlockInit.blackspruce_log.get().getDefaultState()), 
			new SimpleBlockStateProvider(BlockInit.blackspruce_leaves.get().getDefaultState()), 
			new SpruceFoliagePlacer(2, 1))).baseHeight(8).heightRandA(4).trunkHeight(1).trunkHeightRandom(1).trunkTopOffsetRandom(2).ignoreVines()
				.setSapling((IPlantable)BlockInit.blackspruce_sapling.get()).build();
	
	@Override
	protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random randomIn, boolean booleanIn)
	{
		return Feature.NORMAL_TREE.withConfiguration(BLACKSPRUCE_TREE_CONFIG);
	}
}

 

Sapling Class
 

Spoiler

public class CasWillorSaplingBlock extends BushBlock implements IGrowable
{
	public static final IntegerProperty STAGE = BlockStateProperties.STAGE_0_1;
	protected static final VoxelShape SHAPE = Block.makeCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
	private final Supplier<Tree> tree;
	
	public CasWillorSaplingBlock(Supplier<Tree> treeIn, Properties properties) 
	{
		super(properties);
		this.tree = treeIn;
		this.setDefaultState(this.stateContainer.getBaseState().with(STAGE, Integer.valueOf(0)));
	}
	
	@Override
	public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
	{
		return SHAPE;
	}
	
	@SuppressWarnings("deprecation")
	@Override
	public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand)
	{
		super.tick(state, worldIn, pos, rand);
		if(!worldIn.isAreaLoaded(pos, 1)) return;
		
		if(worldIn.getLight(pos.up()) >= 9 && rand.nextInt(7) == 0)
		{
			this.grow(worldIn, pos, state, rand);
		}
	}
	
	public void grow(ServerWorld serverWorld, BlockPos pos, BlockState state, Random rand)
	{
		if(state.get(STAGE) == 0)
		{
			serverWorld.setBlockState(pos, state.cycle(STAGE), 4);
		}
		else
		{
			if(!ForgeEventFactory.saplingGrowTree(serverWorld, rand, pos)) return;
			this.tree.get().func_225545_a_(serverWorld, serverWorld.getChunkProvider().getChunkGenerator(), pos, state, rand);
		}
	}
	
	@Override
	public void grow(ServerWorld serverWorld, Random rand, BlockPos pos, BlockState state)
	{
		this.grow(serverWorld, pos, state, rand);
	}
	
	@Override
	public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient)
	{
		return true;
	}
	
	@Override
	public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, BlockState state)
	{
		return (double)worldIn.rand.nextFloat() < 0.45D;
	}
	
	@Override
	protected void fillStateContainer(Builder<Block, BlockState> builder)
	{
		builder.add(STAGE);
	}
}

 

 

Edited by MadHatAK
Forge Version in Title, solved Issue
Link to comment
Share on other sites

No, it just tells the leaves how far above ground level to generate.
 



I did figure this out. Overriding the leaves, and logs, tag in resources/data/minecraft/tags/blocks solves this issue.

Spoiler

{
  "replace": false,
  "values": [
    "minecraft:jungle_leaves",
    "minecraft:oak_leaves",
    "minecraft:spruce_leaves",
    "minecraft:dark_oak_leaves",
    "minecraft:acacia_leaves",
    "minecraft:birch_leaves",
    "yourmodid:your_leaves"
    
  ]
}

 

Do the same for your logs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.