Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.