Jump to content

[SOLVED] Disable Player Jumping.


deerangle

Recommended Posts

/**
* LivingJumpEvent is fired when an Entity jumps.<br>
* This event is fired whenever an Entity jumps in 
* EntityLivingBase#jump(), EntityMagmaCube#jump(),
* and EntityHorse#jump().<br>
* <br>
* This event is fired via the {@link ForgeHooks#onLivingJump(EntityLivingBase)}.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
public static class LivingJumpEvent extends LivingEvent
{
    public LivingJumpEvent(EntityLivingBase e){ super(e); }
}

 

I think coolAlias's solution is quite good. My first thought was to cancel the event, however it would seem that this particular even cannot be cancelled.

I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java.

 

Follow me on GitHub: https://github.com/yooksi

Contact me on Twitter: https://twitter.com/yooksi

Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/

Link to comment
Share on other sites

Just to note that other mods may also be listening for the jump event and applying their own modifiers (e.g. jump boost), and their listeners may or may not come before yours. If they come after, you might find that the player is still able to jump, albeit probably not as high as they would have without your event handler.

 

You can set a Priority level for your event handler; HIGHer priorities are handled first, and LOWer priorities handled last.

@SubscribeEvent(priority=EventPriority.LOWEST)
public void onJump(LivingJumpEvent event) {
  // this handler will now happen after all other non-LOWEST priority handlers
}

Generally, you want to leave your priority level alone, but if you disabling player jumping is integral to your mod, you can consider using LOW or LOWEST priority so that your handler has the last say.

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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