Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Checking for EntityPlayer on LivingHurtEvent
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
nil

Checking for EntityPlayer on LivingHurtEvent

By nil, October 28 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

nil    0

nil

nil    0

  • Tree Puncher
  • nil
  • Members
  • 0
  • 41 posts
Posted October 28

In my WorldEvents class, i want to implement a damage reduction and need to filter out if the hurt entity is the player.

I tried this:

if(event.getEntityLiving().getClass().equals(EntityPlayer.class))

and this:

if(event.getEntityLiving().getClass() == EntityPlayer.class

but it refuses to go into the if.

 

How do i get this to work?

 

  • Quote

Share this post


Link to post
Share on other sites

DavidM    102

DavidM

DavidM    102

  • World Shaper
  • DavidM
  • Members
  • 102
  • 1135 posts
Posted October 29

Use the instanceof keyword.

  • Quote

Share this post


Link to post
Share on other sites

Differentiation    27

Differentiation

Differentiation    27

  • Dragon Slayer
  • Differentiation
  • Members
  • 27
  • 573 posts
Posted October 29
11 hours ago, nil said:

In my WorldEvents class, i want to implement a damage reduction and need to filter out if the hurt entity is the player.

I tried this:

if(event.getEntityLiving().getClass().equals(EntityPlayer.class))

and this:

if(event.getEntityLiving().getClass() == EntityPlayer.class

but it refuses to go into the if.

 

How do i get this to work?

 

if (LivingHurtEvent###getEntityLiving instanceof EntityPlayer)

 

Since EntityPlayer extends EntityLivingBase.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • DaemonUmbra
      Forge 28.1.10 won't show on launcher + 28.1.0 fails to work

      By DaemonUmbra · Posted 4 minutes ago

      Where are you looking in the launcher? I suspect you are looking at Profiles/Installations rather than Versions
    • Simon_kungen
      [1.14.4] Sync ItemStack Capability Data + Multi-Capability Provider casting error

      By Simon_kungen · Posted 13 minutes ago

      So yeah... looks like none of my questions has been answered lately. Should I give up on capabilities for now?
    • TheGreenSquarez
      Forge 28.1.10 won't show on launcher + 28.1.0 fails to work

      By TheGreenSquarez · Posted 52 minutes ago

      here's the screenshot.
    • TheGreenSquarez
      Forge 28.1.10 won't show on launcher + 28.1.0 fails to work

      By TheGreenSquarez · Posted 54 minutes ago

      I'm quite sure it just updated to the latest version.
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      Ok, i want try Something, pls wait.
  • Topics

    • TheGreenSquarez
      4
      Forge 28.1.10 won't show on launcher + 28.1.0 fails to work

      By TheGreenSquarez
      Started Yesterday at 11:21 AM

    • Simon_kungen
      1
      [1.14.4] Sync ItemStack Capability Data + Multi-Capability Provider casting error

      By Simon_kungen
      Started 23 hours ago

    • DragonITA
      33
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

    • jun2040
      1
      Game crashing when the block is activated

      By jun2040
      Started 1 hour ago

    • Prasodym
      7
      produces unregistered item minecraft:wooden_door

      By Prasodym
      Started April 28

  • Who's Online (See full list)

    • DaemonUmbra
    • Cerandior
    • Choonster
    • Simon_kungen
    • DragonITA
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Checking for EntityPlayer on LivingHurtEvent
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community