Dynamic "Leaves" Support (Dynamic Trees mod)
Opened this issue ยท 6 comments
PLEASE add support for it :D thanks.
i'm so sorry if it's about Dynamic Trees. thanks
The mod modifies the BlockLeaves class, so if Dynamic Trees leaf blocks override the method in question or do not extend that class, this mod will not work. Nothing we could do about that though.
A pull request for this feature in Dynamic Trees has already been merged but not yet released on curseforge. Currently it's enabled via the Dynamic Trees config file but I plan to make the feature auto-enable when it detects the passable-leaves mod.
Due to PassableLeaves modifying of the vanilla Minecraft BlockLeaves
class directly (required to make ALL child classes 'passable'), for proper compatibility, when detecting if PassableLeaves is present, you should simply defer to the superclass methods in the overrides for BlockDynamicLeaves
.
The easiest approach would probably be to create a static variable somewhere (let's call it SomeClass.passableLeavesCompatibility
) that is initialsed false
, but set to true
during preInit if PassableLeaves is loaded.
During FMLPreInitializationEvent
:
SomeClass.passableLeavesCompatibility = net.minecraftforge.fml.common.Loader.isModLoaded("passableleaves");
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
if (SomeClass.passableLeavesCompatibility) {
super(world, pos, state, entity);
}
else {
if (entity.motionY < 0.0D && entity.fallDistance < 2.0f) {
entity.fallDistance = 0.0f;
entity.motionY *= 0.5D;//Slowly sink into the block
} else
if (entity.motionY > 0 && entity.motionY < 0.25D) {
entity.motionY += 0.025;//Allow a little climbing
}
entity.setSprinting(false);//One cannot sprint upon tree tops
entity.motionX *= 0.25D;//Make travel slow and laborious
entity.motionZ *= 0.25D;
}
}
@Override
public boolean isPassable(IBlockAccess p_isPassable_1_, BlockPos p_isPassable_2_) {
if (SomeClass.passableLeavesCompatibility) {
super(p_isPassable_1_, p_isPassable_2_);
}
else {
return ModConfigs.isLeavesPassable;
}
}
Or something similar.
If the BlockDynamicLeaves
overrides were to execute in their current state while PassableLeaves is loaded, the functionality would work correctly, but it would only affect leaf blocks added by DynamicTrees and would differ from all other leaf blocks extended from Minecraft's BlockLeaves
.
Sounds like a solid plan. Thanks for the suggestion. That's how I'll proceed.