Jump to content

Recommended Posts

Posted

When I call EntityPlayer#attackEntityFrom, it would post the LivingAttackEvent twice, as the EntityPlayer first post an event, and then call the super.attackEntityFrom, which would post the same event too.

How could I identify these two event, or maybe it's a bug that forge make? BTW, I'm using 9.10.1.871.

Posted

It does it once on the server and once on the client. Most actions are just needed for the server and you can specify them by using:

worldobj.isRemote

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

//In EntityPlayer
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
    {
        if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2)) return false;
       //some intermediate code
                    return super.attackEntityFrom(par1DamageSource, par2);
                }
            }
        }
    }
//In EntityLivingBase
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
    {
        if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2)) return false;

Sounds redundant, huh ?

 

Well actually, there is no difference between these too, when considering EntityPlayer. They both call LivingAttackEvent, and further processing is cancel when the event is.

Except the first one is called sooner, even if player is immune or damage is 0.

Does it matter ? I don't think so.

Posted

In my mod maybe there actually is difference.

I'm trying to apply some potion effect when the player(or other mobs) attack, no matter if the target take damage. And trying to change the interval of the attack action of the player(using EntityLivingBase#attacktime which seems to no use for player). That may cause the potion effect apply twice, and attack interval become hard to handle.

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

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

Announcements



×
×
  • Create New...

Important Information

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