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

Hello, how would I go about checking the block a player lands on when a player takes fall damage. I have the code for the event:

 


@ForgeSubscribe
public void onHurtEvent(LivingHurtEvent e) {
	if (e.entity instanceof EntityPlayer) {
		DamageSource source = e.source;
		EntityPlayer player = (EntityPlayer) e.entity;
		if (!player.worldObj.isRemote) {
                            if (source == DamageSource.fall) {
                                // Unsure of what to do here to check the block the player landed on.

 

The idea is, if a player lands on a certain block, I want the damage to be set to 0. I know how to set the damage and all of that fun stuff.

 

Do you think this would work?

 

int x = (int)Math.floor(player.posX);
int y = (int)Math.floor(player.posY);
int z = (int)Math.floor(player.posZ);

int blockID = player.worldObj.getBlockId(x, y, z);

 

edit: actually the block bellow the player would have y - 1 I think.

did you see my edit? I think the block below the player's feet would be changin this:

 

int blockID = player.worldObj.getBlockId(x, y, z);

 

to this:

 

int blockID = player.worldObj.getBlockId(x, y - 1, z);

 

edit: sorry... we're both posting without seeing each other's answers. That thing that says "someone posted to this thread while you were typing" or something is not working  :-\

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.