From 7d18cb068e225bf108f5241a1d0a74a586a14db6 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Wed, 4 Dec 2024 21:05:57 +0100 Subject: [PATCH] properly override push/knockback methods This prevent the creaking from being pushed with knockback enchant when it can't move --- patches/api/Fix-upstream-javadocs.patch | 21 +++++++++ .../server/Add-entity-knockback-events.patch | 46 +++++++++++++++++-- patches/server/Improve-death-events.patch | 2 +- ...date-ResourceLocation-in-NBT-reading.patch | 8 ++-- 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/patches/api/Fix-upstream-javadocs.patch b/patches/api/Fix-upstream-javadocs.patch index d212be493a..c3739490fa 100644 --- a/patches/api/Fix-upstream-javadocs.patch +++ b/patches/api/Fix-upstream-javadocs.patch @@ -1625,6 +1625,27 @@ diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + /** + * Gets the enchantable component. Higher values allow higher enchantments. + * +- * @return max_stack_size ++ * @return the enchantable value + */ + int getEnchantable(); + +@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + + /** + * Gets the item which this item will convert to when used. +- *

+- * The returned component is a snapshot of its current state and does not +- * reflect a live view of what is on an item. After changing any value on +- * this component, it must be set with {@link #setUseRemainder(ItemStack)} +- * to apply the changes. + * + * @return remainder + */ @@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste * The returned component is a snapshot of its current state and does not * reflect a live view of what is on an item. After changing any value on diff --git a/patches/server/Add-entity-knockback-events.patch b/patches/server/Add-entity-knockback-events.patch index d1706de016..5f71fe64ba 100644 --- a/patches/server/Add-entity-knockback-events.patch +++ b/patches/server/Add-entity-knockback-events.patch @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.push(deltaX, deltaY, deltaZ, null); + } + -+ public void push(double deltaX, double deltaY, double deltaZ, @org.jetbrains.annotations.Nullable Entity pushingEntity) { ++ public void push(double deltaX, double deltaY, double deltaZ, @Nullable Entity pushingEntity) { + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(deltaX, deltaY, deltaZ); + if (pushingEntity != null) { + 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); @@ -166,7 +166,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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 ++ public void push(double deltaX, double deltaY, double deltaZ, @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 @@ -186,6 +186,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @Override +diff --git a/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java b/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java ++++ b/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java +@@ -0,0 +0,0 @@ public class Creaking extends Monster { + } + + @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.canMove()) { +- super.push(deltaX, deltaY, deltaZ); ++ super.push(deltaX, deltaY, deltaZ, pushingEntity); // Paper - add push source entity param + } + } + +@@ -0,0 +0,0 @@ public class Creaking extends Monster { + } + + @Override +- public void knockback(double strength, double x, double z) { ++ public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events + if (this.canMove()) { +- super.knockback(strength, x, z); ++ super.knockback(strength, x, z, attacker, cause); // Paper - knockback events + } + } + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java @@ -228,6 +256,18 @@ diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +@@ -0,0 +0,0 @@ public abstract class AbstractArrow extends Projectile { + } + + @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 + } + } + @@ -0,0 +0,0 @@ public abstract class AbstractArrow extends Projectile { Vec3 vec3d = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale(d0 * 0.6D * d1); @@ -246,7 +286,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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 ++ public void push(double deltaX, double deltaY, double deltaZ, @Nullable Entity pushingEntity) {} // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent public abstract void explode(Vec3 pos); diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index 56bb5dc527..3619c91b26 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - return super.hurtServer(world, source, amount); + // Paper start - cancellable death events -+ //return super.hurt(world, source, amount); ++ // return super.hurtServer(world, source, amount); + this.queueHealthUpdatePacket = true; + boolean damaged = super.hurtServer(world, source, amount); + this.queueHealthUpdatePacket = false; diff --git a/patches/server/Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch index 4bd5c4d2e5..6143036e60 100644 --- a/patches/server/Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch @@ -111,12 +111,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.setLeftHanded(nbt.getBoolean("LeftHanded")); if (nbt.contains("DeathLootTable", 8)) { - this.lootTable = Optional.of(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("DeathLootTable")))); -- } else { -- this.lootTable = Optional.empty(); -+ this.lootTable = Optional.ofNullable(ResourceLocation.tryParse(nbt.getString("DeathLootTable"))).map((rs) -> ResourceKey.create(Registries.LOOT_TABLE, rs)); // Paper - Validate ResourceLocation } else { ++ this.lootTable = Optional.ofNullable(ResourceLocation.tryParse(nbt.getString("DeathLootTable"))).map((rs) -> ResourceKey.create(Registries.LOOT_TABLE, rs)); // Paper - Validate ResourceLocation + } else { + this.lootTable = Optional.empty(); } - - this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java