Jump to content

[1.8]Double Jump


maikyy

Recommended Posts

So when working on my mod I suddenly had the brilliant idea of adding a double jump. so after some work I finally got it in but there is one little problem, i want to reset my fall height as soon as you jump for the second time, now the problem comes in that i don't really know where to exactly call the 'player.falldistance'

 

to start off here is what i got right now.

 

PlayerHandler.class

http://pastebin.com/nPr9Lz5D

(Don't worry about the 'EntityPlayer player = (EntityPlayer) event.entity;' I already removed it)

 

KeyHandler.class

http://pastebin.com/RqXK7PwA

 

And I have these two lines in my main mod class under the init

MinecraftForge.EVENT_BUS.register(new PlayerHandler());
FMLCommonHandler.instance().bus().register(new KeyHandler());

 

And another quick note, right now when I jump the jumpheight is dependend on when I jump if that makes any sense.

so when I jump for the first time and Immediatly jump again I can jump 3 blocks high, but when I jump and wait a little I can't even jump 1 block high with my second jump. so there must be something i did horribly wrong :P

obviously needed to SET velocity and not ADD velocity :P

 

Edit:

Oh lol I just found out that I really did mess something up because my minecraft client was running in the background and as soon as another entity jumps my game crashes :P

I'm dutch so expect terrible grammar and mistakes :D

Link to comment
Share on other sites

Nononono

 

Just do player.onGround = true

 

whenever the player jump method is called or something and then they can jump again

 

So you mean where I have:

@SubscribeEvent
public void OnKeyInput(KeyInputEvent event)
{
	if(!FMLClientHandler.instance().isGUIOpen(GuiChat.class))
	{
		if(Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed())
		{
			if(PlayerHandler.isJumping && !PlayerHandler.isDoubleJumping && PlayerHandler.canDoubleJump)
			{
				Minecraft.getMinecraft().thePlayer.setVelocity(0.0F, 0.5F, 0.0F);
				Minecraft.getMinecraft().thePlayer.fallDistance = 0.0F;
				PlayerHandler.isDoubleJumping = true;
			}
		}
	}
}

 

because if I check for anything to do with the player here It crashes as soon as I jump again. That is basicly how I started it out, at first I had something like this in here:

public static boolean isDoubleJumping;
EntityPlayer EntityPlayer;
EntityPlayer player = EntityPlayer;

if(player.onground) {
   isDoubleJumping = false;
}

@SubscribeEvent
public void OnKeyInput(KeyInputEvent event)
{
if(!FMLClientHandler.instance().isGUIOpen(GuiChat.class))
{
	if(Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed())
	{
		if(!player.onground && !isDoubleJumping)
		{
			player.setVelocity(0.0F, 0.5F, 0.0F);
			player.fallDistance = 0.0F;
			isDoubleJumping = true;
		}
	}
}
}

 

But that just kept throwing errors at me so that's why I do it the other way now because that seemed to kind of work :P

I'm dutch so expect terrible grammar and mistakes :D

Link to comment
Share on other sites

Don't set onGround to true unless the player is on the ground.

 

Your trouble is caused because you are setting fall distance on the CLIENT, but the player's fall distance on the SERVER is what results in the player taking damage.

 

You need to send a packet telling the server that your player is trying to double-jump and let the server say, 'okay, s/he can do that, and now I'm resetting fallDistance'.

Link to comment
Share on other sites

Don't set onGround to true unless the player is on the ground.

 

Your trouble is caused because you are setting fall distance on the CLIENT, but the player's fall distance on the SERVER is what results in the player taking damage.

 

You need to send a packet telling the server that your player is trying to double-jump and let the server say, 'okay, s/he can do that, and now I'm resetting fallDistance'.

 

Thanks, that makes sense now you say that. well ,Time to go and learn how to deal with packets :P

I'm dutch so expect terrible grammar and mistakes :D

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

    • Yesterday I buy a minecraft server to play with my friends you know... One of my friends send me the list of mods to add and then i start to dowload them, when i add them to the server it start crashing but i don't know about this things because it's my first time buying a minecraft server This is the error: https://paste.ee/p/sJf7B
    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m
    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER web [ ht tps:// muyerntrusthack.solutions/ ] for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m  
    • Do you have still this problem? (I have it too so I want to know if you did something with it)  
  • Topics

×
×
  • Create New...

Important Information

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