Jump to content

Checking if the Player is Swimming In Lava


Draco18s

Recommended Posts

I'm trying to detect when the player is swimming in lava (that is, currently in lava and holding the space bar) so that I can add a little extra upward motion when they try and jump out because of this problem.  I'm fine with lava being dangerous, I am not fine with making "falling in lava" an instant-death scenario if it's bubbling and burbling out smoke once in a while to fill the air around the lava to make it more dangerous (seriously: the smoke causes blindness and that's about it).

 

isJumping is private (and even with reflection, the value is false)

motionY is not helpful (I don't want to keep adding the upward velocity after they stop trying to swim upwards, but the player will still have positive Y motion)

can't just check for isInMaterial because those are already going to return true, regardless of if the player is trying to swim or not.

 

I'm at a loss.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Check Entity#handleLavaMovement() to return if in lava, and check if the player is pressing the space bar on the client side and send a packet to let the server know.

 

I found that function already, I was hoping to avoid needing a key handler.  Oh well. :\

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

#$&%ing Key handlers.  Used this wiki page to get started.

 

Two problems that are immediately obvious:

1) I can't register a key that's already bound to something else (my bind takes precedence)

2) Going to options -> controls crashes the game with an unhelpful NPE

 

*Throws JAVA at the problem to make it go away*

Screw you Keybinder, TICK EVENTS AND KEYBOARD ACCESS!

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

KeyInputEvent

 

That was helpful, thanks.  Its hard to search for examples of key-stuff and not find Keybinds.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You probably are aware of this, but you can use Minecraft.getMinecraft().gameSettings.keyBindJump, for example, to get the vanilla key and check its getKeyCode() is equal to the key firing the KeyInputEvent - this way you are not checking for space bar explicitly and your code will always work properly, even people with game pads and such.

Link to comment
Share on other sites

You probably are aware of this, but you can use Minecraft.getMinecraft().gameSettings.keyBindJump, for example, to get the vanilla key and check its getKeyCode() is equal to the key firing the KeyInputEvent - this way you are not checking for space bar explicitly and your code will always work properly, even people with game pads and such.

 

I did what I could with this.  Slight problem:

The KeyInputEvent is not fired from mouse input.  You can bind jump to Mouse1, and it works as expected as far as vanilla is concerned; I do not know how to check for this situation for my purposes.  I also don't own a controller, so I am unable to test those.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Ah ha, of course.  Silly me.

 

Now to find a friend who owns a controller....

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.



×
×
  • Create New...

Important Information

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