Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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.

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

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

That code is called when the player is attacked, not the other way around.

Use AttackEntityEvent for that.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.