2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Brokkonaut <hannos17@gmx.de>
|
|
|
|
Date: Mon, 18 Jun 2018 15:46:23 +0200
|
2024-05-30 22:17:16 +02:00
|
|
|
Subject: [PATCH] Add entity knockback events
|
2022-12-23 20:59:11 +01:00
|
|
|
|
2024-05-30 22:17:16 +02:00
|
|
|
- EntityKnockbackEvent
|
|
|
|
- EntityPushedByEntityAttackEvent
|
|
|
|
- EntityKnockbackByEntityEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2024-05-30 22:17:16 +02:00
|
|
|
Co-authored-by: aerulion <aerulion@gmail.com>
|
|
|
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2022-12-23 20:59:11 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-11-04 18:42:38 +01:00
|
|
|
index 46cb5722be10182af7af41f733405ab5fe137576..ab7740d1753cd8540189c77053e5ca1f71c1b024 100644
|
2022-12-23 20:59:11 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -2051,7 +2051,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2022-12-23 20:59:11 +01:00
|
|
|
}
|
|
|
|
|
2024-06-13 21:04:27 +02:00
|
|
|
public void push(double deltaX, double deltaY, double deltaZ) {
|
2024-06-22 20:11:34 +02:00
|
|
|
- this.setDeltaMovement(this.getDeltaMovement().add(deltaX, deltaY, deltaZ));
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
2022-12-23 20:59:11 +01:00
|
|
|
+ this.push(deltaX, deltaY, deltaZ, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void push(double deltaX, double deltaY, double deltaZ, @org.jetbrains.annotations.Nullable Entity pushingEntity) {
|
|
|
|
+ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(deltaX, deltaY, deltaZ);
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
+ if (pushingEntity != null) {
|
2024-05-30 22:17:16 +02:00
|
|
|
+ io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent event = new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(this.getBukkitEntity(), io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.PUSH, pushingEntity.getBukkitEntity(), delta);
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
+ if (!event.callEvent()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2024-05-30 22:17:16 +02:00
|
|
|
+ delta = event.getKnockback();
|
2022-12-23 20:59:11 +01:00
|
|
|
+ }
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
+ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ()));
|
2024-01-21 19:37:09 +01:00
|
|
|
+ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
2024-05-30 22:17:16 +02:00
|
|
|
this.hasImpulse = true;
|
2022-12-23 20:59:11 +01:00
|
|
|
}
|
2024-06-22 20:11:34 +02:00
|
|
|
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-11-04 18:42:38 +01:00
|
|
|
index 9e21f77689eb246ad72cdbd7ee19211dcb2ed738..61124dfec84792fa23ce1b0f03cbd97b1a6bde5b 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
2024-10-27 18:11:15 +01:00
|
|
|
@@ -1563,7 +1563,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-06-13 21:04:27 +02:00
|
|
|
d1 = source.getSourcePosition().z() - this.getZ();
|
2024-05-30 22:17:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- this.knockback(0.4000000059604645D, d0, d1, entity1, entity1 == null ? EntityKnockbackEvent.KnockbackCause.DAMAGE : EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
|
|
|
|
+ this.knockback(0.4000000059604645D, d0, d1, entity1, entity1 == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events
|
|
|
|
if (!flag) {
|
|
|
|
this.indicateDamage(d0, d1);
|
|
|
|
}
|
2024-10-27 18:11:15 +01:00
|
|
|
@@ -1620,7 +1620,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void blockedByShield(LivingEntity target) {
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), null, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // CraftBukkit
|
2024-05-30 22:17:16 +02:00
|
|
|
+ target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean checkTotemDeathProtection(DamageSource source) {
|
2024-10-27 18:11:15 +01:00
|
|
|
@@ -1906,10 +1906,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-05-30 22:17:16 +02:00
|
|
|
|
|
|
|
public void knockback(double strength, double x, double z) {
|
|
|
|
// CraftBukkit start - EntityKnockbackEvent
|
|
|
|
- this.knockback(strength, x, z, null, EntityKnockbackEvent.KnockbackCause.UNKNOWN);
|
|
|
|
+ this.knockback(strength, x, z, null, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.UNKNOWN); // Paper - knockback events
|
2024-02-17 00:44:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- public void knockback(double d0, double d1, double d2, Entity attacker, EntityKnockbackEvent.KnockbackCause cause) {
|
2024-05-30 22:17:16 +02:00
|
|
|
+ public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events
|
2024-02-17 00:44:43 +01:00
|
|
|
d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
|
|
|
|
if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0
|
|
|
|
//this.hasImpulse = true; // CraftBukkit - Move down
|
2024-10-27 18:11:15 +01:00
|
|
|
@@ -1922,13 +1922,17 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
2024-06-13 21:04:27 +02:00
|
|
|
|
2024-05-30 22:17:16 +02:00
|
|
|
Vec3 vec3d1 = (new Vec3(d1, 0.0D, d2)).normalize().scale(d0);
|
|
|
|
|
|
|
|
- EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) this.getBukkitEntity(), attacker, cause, d0, vec3d1, vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
|
|
|
|
+ // Paper start - knockback events
|
|
|
|
+ Vec3 finalVelocity = new Vec3(vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
|
|
|
|
+ Vec3 diff = finalVelocity.subtract(vec3d);
|
2024-08-09 22:57:55 +02:00
|
|
|
+ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) this.getBukkitEntity(), attacker, attacker, cause, d0, diff);
|
2024-05-30 22:17:16 +02:00
|
|
|
+ // Paper end - knockback events
|
|
|
|
if (event.isCancelled()) {
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
this.hasImpulse = true;
|
|
|
|
- this.setDeltaMovement(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ());
|
2024-05-30 22:17:16 +02:00
|
|
|
+ this.setDeltaMovement(vec3d.add(event.getKnockback().getX(), event.getKnockback().getY(), event.getKnockback().getZ())); // Paper - knockback events
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
// CraftBukkit end
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
2024-05-30 22:17:16 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index 51381c32c8650400331a122a4b6c8d95c9d0632b..2b8bfccbf520f9a356f816522ac3a5caa51e44e1 100644
|
2024-05-30 22:17:16 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -1685,7 +1685,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
2024-06-13 21:04:27 +02:00
|
|
|
|
2024-10-23 11:04:00 +02:00
|
|
|
if (f1 > 0.0F && target instanceof LivingEntity) {
|
|
|
|
entityliving = (LivingEntity) target;
|
2024-06-13 21:04:27 +02:00
|
|
|
- entityliving.knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
|
|
|
|
+ entityliving.knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events
|
2024-05-30 22:17:16 +02:00
|
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
|
|
|
|
}
|
|
|
|
|
2021-07-26 18:41:26 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java b/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index 8bf5f18b5835ac97114dfea7dde3876c13433ab4..de81e34cf65318fa5e3034405719ff2a2b05458c 100644
|
2021-07-26 18:41:26 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java
|
2024-06-13 21:04:27 +02:00
|
|
|
@@ -89,7 +89,7 @@ public class RamTarget extends Behavior<Goat> {
|
2024-04-16 21:44:59 +02:00
|
|
|
float f = 0.25F * (float)(i - j);
|
2022-12-07 19:52:24 +01:00
|
|
|
float g = Mth.clamp(entity.getSpeed() * 1.65F, 0.2F, 3.0F) + f;
|
2023-03-14 19:59:51 +01:00
|
|
|
float h = livingEntity.isDamageSourceBlocked(world.damageSources().mobAttack(entity)) ? 0.5F : 1.0F;
|
2024-04-16 21:44:59 +02:00
|
|
|
- livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z());
|
2024-05-30 22:17:16 +02:00
|
|
|
+ livingEntity.knockback(h * g * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
2022-12-07 19:52:24 +01:00
|
|
|
this.finishRam(world, entity);
|
2024-04-12 21:14:06 +02:00
|
|
|
world.playSound(null, entity, this.getImpactSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F);
|
2022-12-07 19:52:24 +01:00
|
|
|
} else if (this.hasRammedHornBreakingBlock(world, entity)) {
|
2022-12-23 20:59:11 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java b/src/main/java/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index dbae113f3447f66e154b302ce0634b0fe446381c..d0fb32feb10f75444e3ed0a50c70ef6f12fb8e18 100644
|
2022-12-23 20:59:11 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java
|
2024-04-24 04:21:40 +02:00
|
|
|
@@ -83,7 +83,7 @@ public class SonicBoom extends Behavior<Warden> {
|
2024-10-23 11:04:00 +02:00
|
|
|
if (target.hurtServer(world, world.damageSources().sonicBoom(entity), 10.0F)) {
|
2024-04-24 04:21:40 +02:00
|
|
|
double d = 0.5 * (1.0 - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE));
|
|
|
|
double e = 2.5 * (1.0 - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE));
|
|
|
|
- target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e);
|
|
|
|
+ target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e, entity); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
|
|
|
}
|
2024-04-12 21:14:06 +02:00
|
|
|
});
|
2022-12-23 20:59:11 +01:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index 0012ab1f56180081d210c8836e2a59d543b950b8..ba1bb0f82634054e02c5f4bc062c1822a356e2a6 100644
|
2022-12-23 20:59:11 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -441,7 +441,7 @@ public class EnderDragon extends Mob implements Enemy {
|
2022-12-23 20:59:11 +01:00
|
|
|
double d3 = entity.getZ() - d1;
|
|
|
|
double d4 = Math.max(d2 * d2 + d3 * d3, 0.1D);
|
|
|
|
|
|
|
|
- entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
|
2024-01-21 19:37:09 +01:00
|
|
|
+ entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
2024-06-13 21:04:27 +02:00
|
|
|
if (!this.phaseManager.getCurrentPhase().isSitting() && entityliving.getLastHurtByMobTimestamp() < entity.tickCount - 2) {
|
|
|
|
DamageSource damagesource = this.damageSources().mobAttack(this);
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/BlockAttachedEntity.java b/src/main/java/net/minecraft/world/entity/decoration/BlockAttachedEntity.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index 19f9f4bceca158d9b35be2cdc4d7aa502f44a4b9..cd0a2270b58b6c0dba67270e7e1d1ba253eb7953 100644
|
2024-06-13 21:04:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/BlockAttachedEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/BlockAttachedEntity.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -161,7 +161,7 @@ public abstract class BlockAttachedEntity extends Entity {
|
2024-03-10 00:16:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- public void push(double deltaX, double deltaY, double deltaZ) {
|
2024-06-13 21:04:27 +02:00
|
|
|
+ public void push(double deltaX, double deltaY, double deltaZ, @Nullable Entity pushingEntity) { // Paper - override correct overload
|
2024-10-23 11:04:00 +02:00
|
|
|
Level world = this.level();
|
|
|
|
|
|
|
|
if (world instanceof ServerLevel worldserver) {
|
2024-03-10 00:16:27 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index 6a90feef8eb2d65c925c44bc97305a51e3fb7cf0..7dfbcb2ed831cff5d002d79fb81514e6abf587a4 100644
|
2024-03-10 00:16:27 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -129,9 +129,9 @@ public class ItemFrame extends HangingEntity {
|
2024-03-10 00:16:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- public void push(double deltaX, double deltaY, double deltaZ) {
|
|
|
|
+ public void push(double deltaX, double deltaY, double deltaZ, @org.jetbrains.annotations.Nullable Entity pushingEntity) { // Paper - add push source entity param
|
|
|
|
if (!this.fixed) {
|
|
|
|
- super.push(deltaX, deltaY, deltaZ);
|
|
|
|
+ super.push(deltaX, deltaY, deltaZ, pushingEntity); // Paper - add push source entity param
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-12-23 20:59:11 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index c4397afa53a36ecf867525c4dcf2231a52d058dd..32973d9c7bf4c4105d7bd82d3723e0b70cd79644 100644
|
2022-12-23 20:59:11 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -292,7 +292,7 @@ public class Ravager extends Raider {
|
2022-12-23 20:59:11 +01:00
|
|
|
double d1 = entity.getZ() - this.getZ();
|
|
|
|
double d2 = Math.max(d0 * d0 + d1 * d1, 0.001D);
|
|
|
|
|
|
|
|
- entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D);
|
2024-01-21 19:37:09 +01:00
|
|
|
+ entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
2022-12-23 20:59:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index 8b80f5c2749106f634d962fd0f381aa20e7ef335..a1e3375519fe676b14788d6729a7e71d089cca37 100644
|
2022-12-23 20:59:11 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -45,7 +45,7 @@ public interface HoglinBase {
|
2024-04-16 21:44:59 +02:00
|
|
|
double j = f * (double)(attacker.level().random.nextFloat() * 0.5F + 0.2F);
|
2024-04-12 21:14:06 +02:00
|
|
|
Vec3 vec3 = new Vec3(g, 0.0, h).normalize().scale(j).yRot(i);
|
2024-04-16 21:44:59 +02:00
|
|
|
double k = f * (double)attacker.level().random.nextFloat() * 0.5;
|
2022-12-23 20:59:11 +01:00
|
|
|
- target.push(vec3.x, k, vec3.z);
|
2024-01-21 19:37:09 +01:00
|
|
|
+ target.push(vec3.x, k, vec3.z, attacker); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
2022-12-23 20:59:11 +01:00
|
|
|
target.hurtMarked = true;
|
|
|
|
}
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index df0cfd316d24e285f927c713ab1f9a912857928c..ba0ea4d6b67c9c52f170e0235e4b972aad3ce211 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -1271,9 +1271,9 @@ public abstract class Player extends LivingEntity {
|
2024-06-13 21:04:27 +02:00
|
|
|
if (target instanceof LivingEntity) {
|
|
|
|
LivingEntity entityliving1 = (LivingEntity) target;
|
|
|
|
|
|
|
|
- entityliving1.knockback((double) (f5 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
|
|
|
|
+ entityliving1.knockback((double) (f5 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - knockback events
|
|
|
|
} else {
|
|
|
|
- target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * f5 * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * f5 * 0.5F));
|
|
|
|
+ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * f5 * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * f5 * 0.5F), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -1301,7 +1301,7 @@ public abstract class Player extends LivingEntity {
|
2024-07-06 21:19:14 +02:00
|
|
|
continue;
|
2024-05-30 22:17:16 +02:00
|
|
|
}
|
2024-06-13 21:04:27 +02:00
|
|
|
// CraftBukkit end
|
2024-07-06 21:19:14 +02:00
|
|
|
- entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
|
|
|
|
+ entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // CraftBukkit // Paper - knockback events
|
|
|
|
// entityliving2.hurt(damagesource, f7); // CraftBukkit - moved up
|
2024-06-13 21:04:27 +02:00
|
|
|
Level world = this.level();
|
2024-07-06 21:19:14 +02:00
|
|
|
|
2022-12-23 20:59:11 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index a1b1c6385d3a1fbe38f5ae4471b8e4f6ef2c80b3..78053060dbff7f8a859f9fecb356491f497eed7e 100644
|
2022-12-23 20:59:11 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -553,7 +553,7 @@ public abstract class AbstractArrow extends Projectile {
|
2024-06-13 21:04:27 +02:00
|
|
|
Vec3 vec3d = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale(d0 * 0.6D * d1);
|
2022-12-23 20:59:11 +01:00
|
|
|
|
2024-06-13 21:04:27 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2022-12-23 20:59:11 +01:00
|
|
|
|
2024-04-25 05:40:32 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index 6541ab0d8da28785b19fa50d18d6a484ea38cef8..a325a223d06e155c01f664562db0edd0b180e356 100644
|
2024-04-25 05:40:32 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -101,7 +101,7 @@ public abstract class AbstractWindCharge extends AbstractHurtingProjectile imple
|
2024-04-25 05:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
- public void push(double deltaX, double deltaY, double deltaZ) {}
|
|
|
|
+ public void push(double deltaX, double deltaY, double deltaZ, @org.jetbrains.annotations.Nullable Entity pushingEntity) {} // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
|
|
|
|
|
2024-06-13 21:04:27 +02:00
|
|
|
public abstract void explode(Vec3 pos);
|
2024-04-25 05:40:32 +02:00
|
|
|
|
2024-10-23 11:04:00 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
|
|
index 3afacd201683f46fd75cd6f9a7f3d43a7050cf4a..9f37d7284c81d529551107e2836627977efabd65 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java
|
|
|
|
@@ -258,13 +258,10 @@ public class ServerExplosion implements Explosion {
|
2024-05-30 22:17:16 +02:00
|
|
|
|
|
|
|
// CraftBukkit start - Call EntityKnockbackEvent
|
|
|
|
if (entity instanceof LivingEntity) {
|
2024-10-23 11:04:00 +02:00
|
|
|
- Vec3 result = entity.getDeltaMovement().add(vec3d);
|
|
|
|
- org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d6, vec3d, result.x, result.y, result.z);
|
2024-05-30 22:17:16 +02:00
|
|
|
-
|
|
|
|
- // SPIGOT-7640: Need to subtract entity movement from the event result,
|
|
|
|
- // since the code below (the setDeltaMovement call as well as the hitPlayers map)
|
|
|
|
- // want the vector to be the relative velocity will the event provides the absolute velocity
|
2024-10-23 11:04:00 +02:00
|
|
|
- vec3d = (event.isCancelled()) ? Vec3.ZERO : new Vec3(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement());
|
|
|
|
+ // Paper start - knockback events
|
|
|
|
+ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d6, vec3d);
|
|
|
|
+ vec3d = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getKnockback());
|
|
|
|
+ // Paper end - knockback events
|
2024-02-17 00:44:43 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2024-10-23 11:04:00 +02:00
|
|
|
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d));
|
2024-05-30 22:17:16 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2024-10-23 11:04:00 +02:00
|
|
|
index f05a19f868be0d685c4fbf64e1dfbefda71131ac..60a16ac62a27a92b763bf90e72fab4ed01aeb592 100644
|
2024-05-30 22:17:16 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2024-10-23 11:04:00 +02:00
|
|
|
@@ -1936,19 +1936,33 @@ public class CraftEventFactory {
|
2024-05-30 22:17:16 +02:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
- public static EntityKnockbackEvent callEntityKnockbackEvent(CraftLivingEntity entity, Entity attacker, EntityKnockbackEvent.KnockbackCause cause, double force, Vec3 raw, double x, double y, double z) {
|
|
|
|
- Vector bukkitRaw = new Vector(-raw.x, raw.y, -raw.z); // Due to how the knockback calculation works, we need to invert x and z.
|
|
|
|
+ // Paper start - replace knockback events
|
2024-08-09 22:57:55 +02:00
|
|
|
+ public static io.papermc.paper.event.entity.EntityKnockbackEvent callEntityKnockbackEvent(CraftLivingEntity entity, Entity pusher, Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause, double force, Vec3 knockback) {
|
2024-05-30 22:17:16 +02:00
|
|
|
+ Vector apiKnockback = CraftVector.toBukkit(knockback);
|
|
|
|
+
|
|
|
|
+ final Vector currentVelocity = entity.getVelocity();
|
|
|
|
+ final Vector legacyFinalKnockback = currentVelocity.clone().add(apiKnockback);
|
|
|
|
+ final org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause legacyCause = org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.valueOf(cause.name());
|
|
|
|
+ EntityKnockbackEvent legacyEvent;
|
2024-08-09 22:57:55 +02:00
|
|
|
+ if (pusher != null) {
|
|
|
|
+ legacyEvent = new EntityKnockbackByEntityEvent(entity, pusher.getBukkitEntity(), legacyCause, force, apiKnockback, legacyFinalKnockback);
|
|
|
|
+ } else {
|
2024-05-30 22:17:16 +02:00
|
|
|
+ legacyEvent = new EntityKnockbackEvent(entity, legacyCause, force, apiKnockback, legacyFinalKnockback);
|
2024-08-09 22:57:55 +02:00
|
|
|
+ }
|
2024-05-30 22:17:16 +02:00
|
|
|
+ legacyEvent.callEvent();
|
|
|
|
|
2024-08-09 22:57:55 +02:00
|
|
|
- EntityKnockbackEvent event;
|
2024-05-30 22:17:16 +02:00
|
|
|
+ final io.papermc.paper.event.entity.EntityKnockbackEvent event;
|
|
|
|
+ apiKnockback = legacyEvent.getFinalKnockback().subtract(currentVelocity);
|
2024-08-09 22:57:55 +02:00
|
|
|
if (attacker != null) {
|
|
|
|
- event = new EntityKnockbackByEntityEvent(entity, attacker.getBukkitEntity(), cause, force, new Vector(-raw.x, raw.y, -raw.z), new Vector(x, y, z));
|
2024-05-30 22:17:16 +02:00
|
|
|
+ event = new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent(entity, attacker.getBukkitEntity(), cause, (float) force, apiKnockback);
|
2024-08-09 22:57:55 +02:00
|
|
|
} else {
|
|
|
|
- event = new EntityKnockbackEvent(entity, cause, force, new Vector(-raw.x, raw.y, -raw.z), new Vector(x, y, z));
|
2024-05-30 22:17:16 +02:00
|
|
|
+ event = new io.papermc.paper.event.entity.EntityKnockbackEvent(entity, cause, apiKnockback);
|
2024-08-09 22:57:55 +02:00
|
|
|
}
|
|
|
|
-
|
|
|
|
- Bukkit.getPluginManager().callEvent(event);
|
2024-05-30 22:17:16 +02:00
|
|
|
+ event.setCancelled(legacyEvent.isCancelled());
|
|
|
|
+ event.callEvent();
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
+ // Paper end - replace knockback events
|
|
|
|
|
|
|
|
public static void callEntityRemoveEvent(Entity entity, EntityRemoveEvent.Cause cause) {
|
|
|
|
if (entity instanceof ServerPlayer) {
|