Posted August 24, 201312 yr 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.
August 24, 201312 yr 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.
August 24, 201312 yr 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.