Add entity knockback events

- EntityKnockbackEvent
- EntityPushedByEntityAttackEvent
- EntityKnockbackByEntityEvent

Co-authored-by: aerulion <aerulion@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
Brokkonaut
2018-06-18 15:46:23 +02:00
parent d68fcd321f
commit 991875920d
16 changed files with 356 additions and 180 deletions

View File

@@ -49,7 +49,7 @@
+ // CraftBukkit start - handle the owner before the rest of things
+ this(type, x, y, z, world, stack, weapon, null);
+ }
+
+ protected AbstractArrow(EntityType<? extends AbstractArrow> entitytypes, double d0, double d1, double d2, Level world, ItemStack itemstack, @Nullable ItemStack itemstack1, @Nullable LivingEntity ownerEntity) {
+ this(entitytypes, world);
+ this.setOwner(ownerEntity);
@@ -57,7 +57,7 @@
+ this.pickupItemStack = itemstack.copy();
+ this.setCustomName((Component) itemstack.get(DataComponents.CUSTOM_NAME));
+ Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE);
+
if (unit != null) {
this.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
}
@@ -118,6 +118,18 @@
}
}
@@ -386,9 +410,9 @@
}
@Override
- public void push(double deltaX, double deltaY, double deltaZ) {
+ public void push(double deltaX, double deltaY, double deltaZ, @Nullable Entity pushingEntity) { // Paper - add push source entity param
if (!this.isInGround()) {
- super.push(deltaX, deltaY, deltaZ);
+ super.push(deltaX, deltaY, deltaZ, pushingEntity); // Paper - add push source entity param
}
}
@@ -423,7 +447,7 @@
}
@@ -160,6 +172,15 @@
}
}
}
@@ -538,7 +568,7 @@
Vec3 vec3d = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale(d0 * 0.6D * d1);
if (vec3d.lengthSqr() > 0.0D) {
- target.push(vec3d.x, 0.1D, vec3d.z);
+ target.push(vec3d.x, 0.1D, vec3d.z, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
}
@@ -675,7 +705,7 @@
}

View File

@@ -10,6 +10,15 @@
public abstract class AbstractWindCharge extends AbstractHurtingProjectile implements ItemSupplier {
@@ -98,7 +101,7 @@
}
@Override
- public void push(double deltaX, double deltaY, double deltaZ) {}
+ public void push(double deltaX, double deltaY, double deltaZ, @Nullable Entity pushingEntity) {} // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
public abstract void explode(Vec3 pos);
@@ -111,7 +114,7 @@
Vec3 vec3d1 = blockHitResult.getLocation().add(vec3d);