Good day Gentlemen,
I'm programming a Mod for 1.16. and I've created a custom tree,
futhermore I wanted to use a event (SaplingGrowTreeEvent) to change a block in the trunk.
Sadly I haven't found a solution to actually get it to work,
the problem I'm facing, which I pressume is that the event is executed before the tree is grown, thuse hindering the tree to actually grow.
If anyone know a way to fix it I would be very gratefull.
Here the code:
@Mod.EventBusSubscriber(modid = AdvancedIndustries.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ModClientEvents {
@SubscribeEvent
public static void onRubberTreeGrown(SaplingGrowTreeEvent event) {
BlockPos blockPos = event.getPos();
IWorld world = event.getWorld();
if (!(event.getWorld().getBlockState(event.getPos()).getBlock() instanceof RubberTreeSapling))
return;
if (event.hasResult()) {
if (world.getBlockState(blockPos).getBlock() == RegistryHandler.RUBBER_TREE_SAPLING.get()) {
AdvancedIndustries.LOGGER.info("Generator running");
world.setBlockState(blockPos.add(0,2,0), Blocks.DIAMOND_BLOCK.getDefaultState(), 1);
}
}
}
}
If you required more inedepth view to my code, notfiy me please.
Yours truthfully
Rizen