Basically the title. Unfortunately I am pretty new to Java reflection so I cant get it to work. The attached script is attempting to give the player a speed boost upon finishing a parkour move from the mod ParCool. Any help or pointers would be so appreciated, thanks
Here my running script:
// Import Java reflection classes
const Action = Java.loadClass("com.alrex.parcool.common.action.Action");
PlayerEvents.tick(event => {
const player = event.player;
const actionInstance = player.getCapability('com.alrex.parcool.common.capability.Parkourability').orElse(null);
// Check if the player has completed the parkour move
if (actionInstance && actionInstance.getClass().getMethod('isDoing').invoke(actionInstance)) {
const isActionCompleted = !actionInstance.getClass().getMethod('isDoing').invoke(actionInstance);
if (isActionCompleted) {
// Give the player a speed boost
player.potionEffects.add('speed', 600, 1); // Speed for 30 seconds (600 ticks)
// Optionally reset the action state
actionInstance.getClass().getMethod('setDoing', java.lang.Boolean.TYPE).invoke(actionInstance, false);
}
}
});
And here is the Github for the ParCool mod that I am trying to work with: