Jump to content

Check the block a player lands on when they take fall damage


MistPhizzle
 Share

Recommended Posts

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.

 

Link to comment
Share on other sites

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

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

 Share



×
×
  • Create New...

Important Information

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