Posted December 7, 201311 yr 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.
December 7, 201311 yr 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.
December 7, 201311 yr //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.
December 8, 201311 yr Author 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.
December 8, 201311 yr That code is called when the player is attacked, not the other way around. Use AttackEntityEvent for that.
December 8, 201311 yr Author Okay, I dont know this event before. But how about when the mob attack the player?
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.