Jump to content

[1.7.2] Double Jump?


drok0920

Recommended Posts

@jabelar I have not tried anything yet because i dont know how i would go about doing it AT ALL, @Bedrock_Miner & @Zer0HD2 i want an actual double just not just a potion effect or setting there velocity(well i do need the velocity part but i already knew how to do that).

Link to comment
Share on other sites

Okay, but the reason I ask what you have tried is it helps determine what your modding skill level is, because the answer sometimes is different depending on your capability.

 

Your answer indicates you don't have much programming background.  That is okay, but may be a problem.  Let's see.

 

The way I'd do it is below.  Like anything in programming there are probably many other ways, perhaps better ways, to do it.

 

Like mentioned above, there is an event posted whenever a living entity jumps.  In my tutorial on events I actually have a "fun" example at the bottom where the console prints "boing" every time the player jumps.  Anyway, that tutorial should show you how to intercept the event.  See: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

 

To do a double jump, in programming you have to keep track of the "state" of the player character.  In otherwords, you can't do a double jump unless you know it is actually jumping.  So you'll need a field, maybe an extended player property that keeps track of whether he's in the middle of a jump, as you'll need to know that in order to create a double jump.  You should see CoolAlias' tutorial (http://www.minecraftforum.net/topic/1952901-172164-eventhandler-and-iextendedentityproperties/) on extended player properties (in his example he makes a mana property, but all you need one boolean property like isJumping that is true when jumping, and second boolean called isDoubleJumping).

 

So once you have the field for keeping track, you would intercept the jumping event (as mentioned above) and set the isJumping field to true.  And you would also need to detect when the player lands (probably by using LivingFallEvent but possibley by checking motionY) during PlayerTickEvent). When he lands you'll of course have to clear the isJumping to false.

 

Lastly, you'll need to handl the key input event and when space is pressed, check the player extended properties to test if isJumping is true and test that isDoubleJumping is false (you don't want to allow "triple jumping" so have to test if he's already double jumping).  If he's jumping but not double-jumping then you'd create the double jump, I believe by just adding some motionY.

 

So in summary:

  1) handle the LivingJumpEvent to set the isJumping variable

  2) handle the LivingFallEvent to detect when he's landed to clear the isJumping and isDoubleJumping variables

  3) handle the KeyInputEvent to detect space pressed, test if jumping but not already double jumping, and set motion for double jump and set the isDoubleJumping field to true.

 

Get the idea?  detect jumps, track when jumping, look for space pressed during jump to set double jump, clear when lands.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Ok I will try that later because I'm not at my computer. Thank you for all your help but how would I get a triple jump or a quad jump?

 

You would add player extended properties to keep track of each one.  isTripleJumping, isQuadrupleJumping, etc.

 

Then when you handle the key input for space, you'd check what it is already doing and then do the new thing.  When player lands all these would be cleared.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • How to fix file server-1.20.1-20230612.114412-srg.jar  
    • Just a few months ago I was creating my own plugin for Minecraft 1.20.2 spigot that did the same thing, but the skins were not saved, if you can understand this code that I made a long time ago it may help you.   //This is a class method private static String APIRequest(String value, String url, String toSearch) { try { URL api = new URL(url + value); HttpURLConnection connection = (HttpURLConnection) api.openConnection(); connection.setRequestMethod("GET"); int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder response = new StringBuilder(); for (String responseChar; (responseChar = reader.readLine()) != null; ) response.append(responseChar); reader.close(); JSONObject responseObject = new JSONObject(response.toString()); if (!toSearch.equals("id")) return responseObject .getJSONArray("properties") .getJSONObject(0) .getString("value"); else return responseObject.getString("id"); } else { AntiGianka.ConsoleMessage(ChatColor.RED, String.format( "Could not get %s. Response code: %s", ((toSearch.equals("id")) ? "UUID" : "texture"), responseCode )); } } catch (MalformedURLException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } catch (IOException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while attempting to connect to the URL. Error: " + error); } return ""; } //other class method private void SkinGetter() { String uuid; String textureCoded; if ((uuid = APIRequest(args[0], "https://api.mojang.com/users/profiles/minecraft/", "id")).isEmpty() || (textureCoded = APIRequest(uuid, "https://sessionserver.mojang.com/session/minecraft/profile/", "value")).isEmpty() ) sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); else SkinSetter(textureCoded); } //other more private void SkinSetter(String textureCoded) { JSONObject profile = new JSONObject(new String(Base64.getDecoder().decode(textureCoded))); try { URL textureUrl = new URL(profile.getJSONObject("textures"). getJSONObject("SKIN"). getString("url")); if (sender instanceof Player && args.length == 1) { PlayerTextures playerTextures = ((Player) sender).getPlayerProfile().getTextures(); playerTextures.setSkin(textureUrl); ((Player) sender).getPlayerProfile().setTextures(playerTextures); if (((Player) sender).getPlayerProfile().getTextures().getSkin() != null) sender.sendMessage(((Player) sender).getPlayerProfile().getTextures().getSkin().toString()); else sender.sendMessage("Null"); sender.sendMessage("Skin changed successfully.a"); } else { } AntiGianka.ConsoleMessage(ChatColor.GREEN, "Skin command executed successfully."); } catch (MalformedURLException error) { sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } }  
    • Use /locate structure The chat should show all available structures as suggestion For the Ancient City it is /locate structure ancient_city
    • So does it work without this mod? Did you test it with other builds?
  • Topics

×
×
  • Create New...

Important Information

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