Jump to content

d18240

Members
  • Posts

    3
  • Joined

  • Last visited

d18240's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. @diesieben07 Thanks a bunch for the recommendations - it inspired me to look at the various Forge events available to me. I ended up going with LivingAttackEvent, as this seems to be a bit more generalized. And for anyone stumbling upon this later, in order to "call knockback" you literally just call knockback - the LivingEntity class has a knockback method. I didn't know this and it stumped me for while. Including code for those curious (granted it's probably not good code, any suggestions welcome).
  2. I did try event.getEntity() and event.getEntityLiving() - they both return the same thing, which is the Entity being knocked back. I've also looked through all parent classes - LivingEvent, EntityEvent, and Event. LivingKnockBackEvent and LivingEvent pass the entity through to EntityEvent which only handles the entity which is being effected, and Event has nothing relevant in it. It looks like the 1.15.x code has exactly what I need: public LivingKnockBackEvent(LivingEntity target, Entity attacker, float strength, double ratioX, double ratioZ) { super(target); this.attacker = this.originalAttacker = attacker; this.strength = this.originalStrength = strength; this.ratioX = this.originalRatioX = ratioX; this.ratioZ = this.originalRatioZ = ratioZ; } But all traces of "attacker" or "originalAttacker" are removed in 1.16.x: public LivingKnockBackEvent(LivingEntity target, float strength, double ratioX, double ratioZ) { super(target); this.strength = this.originalStrength = strength; this.ratioX = this.originalRatioX = ratioX; this.ratioZ = this.originalRatioZ = ratioZ; }
  3. Hey, I'm new to modding and new to this forum so hopefully I'm doing things alright. I'm attempting to implement increased knockback for a custom weapon in my mod. I've created the item and am trying to figure out how to add the increased knockback effect. This post suggests subscribing to `LivingKnockBackEvent` - which I have successfully done and I'm able to effect the degree of knockback by using `event.setStrength`. However, I'm unable to conditionally set the knockback strength, as I don't have access to the entity which attacked through this method. Which is odd, because both the forum post AND the 1.16.x documentation inside of the code allude to an `Entity attacker` parameter which does not exist. I went back and looked at an older version (1.15.x and earlier) of Forge, and there did indeed used to be an `Entity attacker` parameter, but it was removed in 1.16.x for a reason I can't find. Because of this, I'm unable to find the weapon that was used to cause the knockback event - which is required for my task. Did this get removed because there's a more modern way to access a knockback attacker entity? Or am I just out of luck? Alternatively, is there another way to set an items' knockback amount? I tried setting the `ATTACK_KNOCKBACK` attribute in the weapon modifier properties, but it turns out that doesn't work on items - only on mobs (which is to say, it shows up on the item as "+20 Attack Knockback", but it has no effect). Any help would be appreciated, thanks! [As a note, I am using Forge 1.16.5-36.1.0]
×
×
  • Create New...

Important Information

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