MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"my custom sugarcane/cactus blocks just continues to grow instead of stopping at 3"
-- You need to override the tick method in your custom block class to check the height of the block and stop it from growing beyond 3. public class CustomSugarcaneBlock extends SugarcaneBlock { public CustomSugarcaneBlock(AbstractBlock.Properties properties) { super(properties); } @Override public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { int height = 1; while (worldIn.getBlockState(pos.up(height)).getBlock() == this) { height++; } if (height <= 3) { super.tick(state, worldIn, pos, random); } else { worldIn.setBlockState(pos, this.getDefaultState().with(AGE, 0)); } } } public class CustomCactusBlock extends CactusBlock { public CustomCactusBlock(AbstractBlock.Properties properties) { super(properties); } @Override public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { int height = 1; while (worldIn.getBlockState(pos.up(height)).getBlock() == this) { height++; } if (height <= 3) { super.tick(state, worldIn, pos, random); } else { worldIn.setBlockState(pos, this.getDefaultState().with(AGE, 0)); } } }