Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Checking if the Player is Swimming In Lava
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Draco18s

Checking if the Player is Swimming In Lava

By Draco18s, February 2, 2015 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted February 2, 2015

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.

  • Quote

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.

Share this post


Link to post
Share on other sites

coolAlias    746

coolAlias

coolAlias    746

  • Reality Controller
  • coolAlias
  • Members
  • 746
  • 2805 posts
Posted February 2, 2015

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.

  • Quote

width=228 height=100http://i.imgur.com/NdrFdld.png[/img]

Share this post


Link to post
Share on other sites

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted February 2, 2015

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

  • Quote

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.

Share this post


Link to post
Share on other sites

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted February 2, 2015

#$&%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!

  • Quote

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.

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 2, 2015

You don't need keybinds for this...

KeyInputEvent fires for every LWJGL Keyboard event (key release, key down).

In that event you can get what happened using the Keyboard.getEventKey / Keyboard.getEventKeyState methods. Then keep a static boolean in that class that remembers whether or not the key is down.

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted February 2, 2015
KeyInputEvent

 

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

  • Quote

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.

Share this post


Link to post
Share on other sites

coolAlias    746

coolAlias

coolAlias    746

  • Reality Controller
  • coolAlias
  • Members
  • 746
  • 2805 posts
Posted February 3, 2015

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.

  • Quote

width=228 height=100http://i.imgur.com/NdrFdld.png[/img]

Share this post


Link to post
Share on other sites

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted February 3, 2015

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.

  • Quote

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.

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted February 3, 2015

MouseInputEvent.

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted February 3, 2015

Ah ha, of course.  Silly me.

 

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

  • Quote

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.

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Pixelovski
      Stuck on "Configuration file X is not correct. Correcting"

      By Pixelovski · Posted 6 minutes ago

      Hello, My friends and I just bought a Minecraft hosting to use with forge. And we're encountering problem where the server starts fine, we can connect, but it just keeps spitting out warnings about incorrect config files and it's really annoying and I think it eats up some resources... When we tried forge by itself without any mods there wasn't any issue. When I try to run the server with the exact same files on my pc it works fine. So is there way to just stop the server from trying to correct the config files (or whatever it is that it is doing) or something? Thank you in advance.   Here is the link to the latest log file: https://www.dropbox.com/s/1ni8tko383q4mlg/2021-03-07-10.log?dl=0
    • Nyko
      [1.16.5] overwriting the maximum build height

      By Nyko · Posted 8 minutes ago

      thanks for the info, since the whole thing sounds pretty complicated, I will probably not change it
    • ChocoCookies33
      Description: Exception in server tick loop

      By ChocoCookies33 · Posted 21 minutes ago

      local server set up not working, help is appreciated.  crash-2021-03-07_00.55.37-server.txt
    • LessyDoggy
      Forge 1.12.2 Installing Bug

      By LessyDoggy · Posted 1 hour ago

      So I used forge 1.16.5 but now I cant change it too 1.12.2 no mather what. I have tried Installing client, Installing server and extract but nothing works. I even removed forge 1.16.5 from my computer but I still have that verison on and idk how to change it.
    • Yourskillx2
      !!Keeps crashing during launch!!

      By Yourskillx2 · Posted 2 hours ago

      I have a decent sized mod pack with around 90 mods and every time I go to launch the game, it loads some stuff then crashes with exit code 0, I cannot figure out if its a mod in the pack doing it, like maybe not a release version or if it just doesn't work with Mc like its supposed to.
  • Topics

    • Pixelovski
      0
      Stuck on "Configuration file X is not correct. Correcting"

      By Pixelovski
      Started 6 minutes ago

    • Nyko
      4
      [1.16.5] overwriting the maximum build height

      By Nyko
      Started 14 hours ago

    • ChocoCookies33
      0
      Description: Exception in server tick loop

      By ChocoCookies33
      Started 21 minutes ago

    • LessyDoggy
      0
      Forge 1.12.2 Installing Bug

      By LessyDoggy
      Started 1 hour ago

    • Yourskillx2
      0
      !!Keeps crashing during launch!!

      By Yourskillx2
      Started 2 hours ago

  • Who's Online (See full list)

    • Pixelovski
    • Kreepydude
    • loordgek
    • Nyko
    • zlappedx3
    • Helios885
    • ChocoCookies33
    • vemerion
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Checking if the Player is Swimming In Lava
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community