Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Ok, so when my item is right clicked, it sends the player launching in the direction they are looking. (Thank you hydroflame :D) This would be fine, but, however, if the player is in survival mode, they, of course, take massive amounts of fall damage. So, this is what I tried doing (yes, I do have the fallDistance variable):

 

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {

	player.motionY = 0.7;
	double calculatedX = 10 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f);
	double calculatedZ = 10 * (double) (MathHelper.cos(player.rotationYaw	/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f);
	double calculatedY = 10 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * 0.4f);
	player.motionY = calculatedY;
	player.motionX = calculatedX;
	player.motionZ = calculatedZ;
	player.fallDistance = 0.0f;

	return itemStack;

}

 

Of course, though, when you right click again, it just makes you fly again, adding more fallDistance, which means you always take fall damage. I'm having trouble finding a fix. If I could find a way to do a loop when holding this item (It would be OK to negate all fall damage when holding this) and continually set fall distance to 0. Of course, I have very limited Java knowledge so I do not know how to do this. If someone could help, that would be great! :D

put this in your item class, It gets called every tick on both sides so should work:

@Override
public void onUpdate(ItemStack par1ItemStack, World par2World,
		Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
	par3Entity.fallDistance = 0;
}

 

have fun :)

  • Author

put this in your item class, It gets called every tick on both sides so should work:

@Override
public void onUpdate(ItemStack par1ItemStack, World par2World,
		Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
	par3Entity.fallDistance = 0;
}

 

have fun :)

 

Applause to you, sir! I could never figure out this kinda code on my own xD I am new to coding.

hardly anything complicated, it's overriding a single vanilla method and adding a single line of code...

 

I would take a look at learning a bit more basic coding before you continue with modding. If you want to make anything worthwhile you will need a lot more knowledge

  • Author

hardly anything complicated, it's overriding a single vanilla method and adding a single line of code...

 

I would take a look at learning a bit more basic coding before you continue with modding. If you want to make anything worthwhile you will need a lot more knowledge

 

I'm mostly just making a mod for my server, and I really do want to learn how to be a better modder.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.