Posted February 6, 20169 yr Is there a way, to prevent the player from jumping. Maybe player.capabilities?
February 6, 20169 yr My first thought would be to subscribe to LivingJumpEvent and, if the jumping entity is a player, set their motionY value to zero. http://i.imgur.com/NdrFdld.png[/img]
February 6, 20169 yr /** * 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/
February 6, 20169 yr 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. http://i.imgur.com/NdrFdld.png[/img]
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.