zerozhou Posted December 7, 2013 Share Posted December 7, 2013 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. Quote Link to comment Share on other sites More sharing options...
Busti Posted December 7, 2013 Share Posted December 7, 2013 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 Quote PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered. Link to comment Share on other sites More sharing options...
GotoLink Posted December 7, 2013 Share Posted December 7, 2013 //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. Quote Link to comment Share on other sites More sharing options...
zerozhou Posted December 8, 2013 Author Share Posted December 8, 2013 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. Quote Link to comment Share on other sites More sharing options...
GotoLink Posted December 8, 2013 Share Posted December 8, 2013 That code is called when the player is attacked, not the other way around. Use AttackEntityEvent for that. Quote Link to comment Share on other sites More sharing options...
zerozhou Posted December 8, 2013 Author Share Posted December 8, 2013 Okay, I dont know this event before. But how about when the mob attack the player? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.