Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 02:50:09 +01:00
efd47e3a68
* Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: 2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor 201399fb PR-853: Add API for directly setting Display transformation matrices ecfa559a PR-849: Add InventoryView#setTitle 653d7edb SPIGOT-519: Add TNTPrimeEvent 22fccc09 PR-846: Add method to get chunk load level a070a52c PR-844: Add methods to convert Vector to and from JOML vectors cc7111fe PR-276: Add accessors to Wither's invulnerability ticks 777d24e9 SPIGOT-7209: Accessors and events for player's exp cooldown ccb2d01b SPIGOT-6308: Deprecate the location name property of map items cd04a31b PR-780: Add PlayerSpawnChangeEvent 7d1f5b64 SPIGOT-6780: Improve documentation for World#spawnFallingBlock 5696668a SPIGOT-6885: Add test and easier to debug code for reference in yaml configuration comments 2e13cff7 PR-589: Expand the FishHook API 2c7d3da5 PR-279: Minor edits to various Javadocs CraftBukkit Changes: 01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting 7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices a7cfc778f PR-1176: Add InventoryView#setTitle 563d42226 SPIGOT-519: Add TNTPrimeEvent ccbc6abca Add test for Chunk.LoadLevel mirroring 2926e0513 PR-1171: Add method to get chunk load level 63cad7f84 PR-375: Add accessors to Wither's invulnerability ticks bfd8b1ac8 SPIGOT-7209: Accessors and events for player's exp cooldown f92a41c39 PR-1181: Consolidate Location conversion code 10f866759 SPIGOT-6308: Deprecate the location name property of map items 82f7b658a PR-1095: Add PlayerSpawnChangeEvent b421af7e4 PR-808: Expand the FishHook API 598ad7b3f Increase outdated build delay Spigot Changes: d1bd3bd2 Rebuild patches e4265cc8 SPIGOT-7297: Entity Tracking Range option for Display entities * Work around javac bug * Call PlayerSpawnChangeEvent * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: 2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor 201399fb PR-853: Add API for directly setting Display transformation matrices CraftBukkit Changes: 01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting 7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices Spigot Changes: 7da74dae Rebuild patches
201 Zeilen
14 KiB
Diff
201 Zeilen
14 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Brokkonaut <hannos17@gmx.de>
|
|
Date: Mon, 18 Jun 2018 15:46:23 +0200
|
|
Subject: [PATCH] Implement EntityKnockbackByEntityEvent and
|
|
EntityPushedByEntityAttackEvent
|
|
|
|
Co-authored-by: aerulion <aerulion@gmail.com>
|
|
|
|
This event is called when an entity receives knockback by another entity.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 579b0c70043a545798a6c2871a84c77a5f011744..8b3beb78cf48ea7a23865ddc16c8421ecb047aba 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1775,8 +1775,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
}
|
|
|
|
public void push(double deltaX, double deltaY, double deltaZ) {
|
|
- this.setDeltaMovement(this.getDeltaMovement().add(deltaX, deltaY, deltaZ));
|
|
- this.hasImpulse = true;
|
|
+ // Paper start - call EntityPushedByEntityEvent
|
|
+ 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);
|
|
+ if (pushingEntity == null || new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(getBukkitEntity(), pushingEntity.getBukkitEntity(), delta).callEvent()) {
|
|
+ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ()));
|
|
+ this.hasImpulse = true;
|
|
+ }
|
|
+ // Paper end - call EntityPushedByEntityEvent
|
|
}
|
|
|
|
protected void markHurt() {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index cd0ae977eff36db8a2010596698835dcd9166ef9..10c6f6ac0c56eedf40190216e44d3f5d47b63deb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1445,7 +1445,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
d0 = (Math.random() - Math.random()) * 0.01D;
|
|
}
|
|
|
|
- this.knockback(0.4000000059604645D, d0, d1);
|
|
+ this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper
|
|
if (!flag) {
|
|
this.indicateDamage(d0, d1);
|
|
}
|
|
@@ -1494,7 +1494,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
protected void blockedByShield(LivingEntity target) {
|
|
- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ());
|
|
+ target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper
|
|
}
|
|
|
|
private boolean checkTotemDeathProtection(DamageSource source) {
|
|
@@ -1750,6 +1750,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
public void knockback(double strength, double x, double z) {
|
|
+ // Paper start - add knockbacking entity parameter
|
|
+ this.knockback(strength, x, z, null);
|
|
+ }
|
|
+ public void knockback(double strength, double x, double z, Entity knockingBackEntity) {
|
|
+ // Paper end - add knockbacking entity parameter
|
|
strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
|
|
if (strength > 0.0D) {
|
|
this.hasImpulse = true;
|
|
@@ -1757,6 +1762,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
Vec3 vec3d1 = (new Vec3(x, 0.0D, z)).normalize().scale(strength);
|
|
|
|
this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
|
|
+ // Paper start - call EntityKnockbackByEntityEvent
|
|
+ Vec3 currentMovement = this.getDeltaMovement();
|
|
+ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMovement.x - vec3d.x, currentMovement.y - vec3d.y, currentMovement.z - vec3d.z);
|
|
+ // Restore old velocity to be able to access it in the event
|
|
+ this.setDeltaMovement(vec3d);
|
|
+ if (knockingBackEntity == null || new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((org.bukkit.entity.LivingEntity) getBukkitEntity(), knockingBackEntity.getBukkitEntity(), (float) strength, delta).callEvent()) {
|
|
+ this.setDeltaMovement(vec3d.x + delta.getX(), vec3d.y + delta.getY(), vec3d.z + delta.getZ());
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
index 6f1755efd7f1cf9dd65d070a3ba7623333f341bc..984a33d5e1f790a9c78ba57f2dc21fb072a44b3d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -1631,7 +1631,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
|
|
|
if (flag) {
|
|
if (f1 > 0.0F && target instanceof LivingEntity) {
|
|
- ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
|
|
+ ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
|
|
}
|
|
|
|
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
|
|
index e319a46a21a94314c5d496820b1ac4879dcf56b9..4a3bcd988cf63452c4277ad55ba604ad43c8a623 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java
|
|
@@ -77,7 +77,7 @@ public class RamTarget extends Behavior<Goat> {
|
|
float f = 0.25F * (float)(i - j);
|
|
float g = Mth.clamp(entity.getSpeed() * 1.65F, 0.2F, 3.0F) + f;
|
|
float h = livingEntity.isDamageSourceBlocked(world.damageSources().mobAttack(entity)) ? 0.5F : 1.0F;
|
|
- livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z());
|
|
+ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity); // Paper
|
|
this.finishRam(world, entity);
|
|
world.playSound((Player)null, entity, this.getImpactSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F);
|
|
} else if (this.hasRammedHornBreakingBlock(world, entity)) {
|
|
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
|
|
index 29cfd065f246bbd3d3c2a5bbd32c3f4813a02951..03ec02f9a2fb5abb5387cd0d83c9481d6cbb0bd2 100644
|
|
--- 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
|
|
@@ -68,7 +68,7 @@ public class SonicBoom extends Behavior<Warden> {
|
|
target.hurt(world.damageSources().sonicBoom(entity), 10.0F);
|
|
double d = 0.5D * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE));
|
|
double e = 2.5D * (1.0D - 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
|
|
});
|
|
}
|
|
}
|
|
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
|
|
index 18a9050158f71245d5d88f9c0833fd5d4e5fdca6..55a8ab31a26a16adbe78b3b34366dc81851c02d4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
@@ -434,7 +434,7 @@ public class EnderDragon extends Mob implements Enemy {
|
|
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);
|
|
+ entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D, this); // Paper
|
|
if (!this.phaseManager.getCurrentPhase().isSitting() && ((LivingEntity) entity).getLastHurtByMobTimestamp() < entity.tickCount - 2) {
|
|
entity.hurt(this.damageSources().mobAttack(this), 5.0F);
|
|
this.doEnchantDamageEffects(this, entity);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
|
index f4aa2be477da34c37660f0f3d7997928d327545d..24dc43c7806e99be6dc37af48ec056a5edd19947 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java
|
|
@@ -274,7 +274,7 @@ public class Ravager extends Raider {
|
|
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);
|
|
+ entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D, this); // Paper
|
|
}
|
|
|
|
@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
|
|
index f8ccf0cf421bf2d8d6d6ccf8dd9e7c27eb9024ed..de73183166962d84b3fcbb408e011bc9e8486374 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
|
|
@@ -40,7 +40,7 @@ public interface HoglinBase {
|
|
double j = f * (double)(attacker.level.random.nextFloat() * 0.5F + 0.2F);
|
|
Vec3 vec3 = (new Vec3(g, 0.0D, h)).normalize().scale(j).yRot(i);
|
|
double k = f * (double)attacker.level.random.nextFloat() * 0.5D;
|
|
- target.push(vec3.x, k, vec3.z);
|
|
+ target.push(vec3.x, k, vec3.z, attacker); // Paper
|
|
target.hurtMarked = true;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index 457cafaa39907e85e1d1e9028f0eb75a90f3eb8e..2961e08fc315a0d5f3b95de9d127948da07e66c8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -1283,9 +1283,9 @@ public abstract class Player extends LivingEntity {
|
|
if (flag5) {
|
|
if (i > 0) {
|
|
if (target instanceof LivingEntity) {
|
|
- ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
|
|
+ ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
|
|
} else {
|
|
- target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F));
|
|
+ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper
|
|
}
|
|
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
|
|
@@ -1307,7 +1307,7 @@ public abstract class Player extends LivingEntity {
|
|
if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
|
|
// CraftBukkit start - Only apply knockback if the damage hits
|
|
if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) {
|
|
- entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
|
|
+ entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Pa
|
|
}
|
|
// CraftBukkit end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
index aabb5ad09dd7b11a7dfbaa0849726541c0401951..01ccd4f90ad8aed84a89630cf6df9f7ba9bc3fec 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
@@ -401,7 +401,7 @@ public abstract class AbstractArrow extends Projectile {
|
|
Vec3 vec3d = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale((double) this.knockback * 0.6D * d0);
|
|
|
|
if (vec3d.lengthSqr() > 0.0D) {
|
|
- entityliving.push(vec3d.x, 0.1D, vec3d.z);
|
|
+ entityliving.push(vec3d.x, 0.1D, vec3d.z, this); // Paper
|
|
}
|
|
}
|
|
|