SPIGOT-5553, #1336: Add EntityKnockbackEvent
By: Jishuna <joshl5324@gmail.com>
This commit is contained in:
@@ -96,7 +96,22 @@
|
||||
}
|
||||
|
||||
double d12 = (1.0D - d7) * (double) getSeenPercent(vec3d, entity);
|
||||
@@ -287,9 +337,63 @@
|
||||
@@ -247,6 +297,14 @@
|
||||
d10 *= d13;
|
||||
Vec3D vec3d1 = new Vec3D(d8, d9, d10);
|
||||
|
||||
+ // CraftBukkit start - Call EntityKnockbackEvent
|
||||
+ if (entity instanceof EntityLiving) {
|
||||
+ Vec3D result = entity.getDeltaMovement().add(vec3d1);
|
||||
+ org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d13, vec3d1, result.x, result.y, result.z);
|
||||
+
|
||||
+ vec3d1 = (event.isCancelled()) ? Vec3D.ZERO : new Vec3D(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1));
|
||||
if (entity instanceof EntityHuman) {
|
||||
EntityHuman entityhuman = (EntityHuman) entity;
|
||||
@@ -287,9 +345,63 @@
|
||||
|
||||
SystemUtils.shuffle(this.toBlow, this.level.random);
|
||||
ObjectListIterator objectlistiterator = this.toBlow.iterator();
|
||||
@@ -160,7 +175,7 @@
|
||||
|
||||
this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> {
|
||||
addOrAppendStack(list, itemstack, blockposition1);
|
||||
@@ -314,7 +418,11 @@
|
||||
@@ -314,7 +426,11 @@
|
||||
BlockPosition blockposition1 = (BlockPosition) objectlistiterator1.next();
|
||||
|
||||
if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition1).isAir() && this.level.getBlockState(blockposition1.below()).isSolidRender(this.level, blockposition1.below())) {
|
||||
@@ -173,7 +188,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,6 +430,7 @@
|
||||
@@ -322,6 +438,7 @@
|
||||
}
|
||||
|
||||
private static void addOrAppendStack(List<Pair<ItemStack, BlockPosition>> list, ItemStack itemstack, BlockPosition blockposition) {
|
||||
|
||||
Reference in New Issue
Block a user