properly override push/knockback methods

This prevent the creaking from being pushed with knockback
enchant when it can't move
This commit is contained in:
Lulu13022002 2024-12-04 21:05:57 +01:00
parent 2a4ba00d9f
commit 4806ce5cd5
No known key found for this signature in database
GPG key ID: 491C8F0B8ACDEB01
7 changed files with 86 additions and 27 deletions

View file

@ -1622,10 +1622,31 @@ index 35c6594fd1040a1af1029e7260e5e3a9307b107d..d58719ee75bef8bc265bfc81bc5d88a4
void addChargedProjectile(@NotNull ItemStack item); void addChargedProjectile(@NotNull ItemStack item);
} }
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..5cc1d77a09d2877992433b020ad2c591bb94d3fd 100644 index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..66315ae78d6143ac6bde2b3a2b40b617dc4b1aab 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -767,7 +767,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -293,7 +293,7 @@ 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();
@@ -626,11 +626,6 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/**
* Gets the item which this item will convert to when used.
- * <p>
- * 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
*/
@@ -767,7 +762,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* The returned component is a snapshot of its current state and does not * 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 * reflect a live view of what is on an item. After changing any value on
* this component, it must be set with * this component, it must be set with
@ -1634,7 +1655,7 @@ index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..5cc1d77a09d2877992433b020ad2c591
* to apply the changes. * to apply the changes.
* *
* @return component * @return component
@@ -776,7 +776,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -776,7 +771,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
JukeboxPlayableComponent getJukeboxPlayable(); JukeboxPlayableComponent getJukeboxPlayable();
/** /**
@ -1643,7 +1664,7 @@ index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..5cc1d77a09d2877992433b020ad2c591
* *
* @param jukeboxPlayable new component * @param jukeboxPlayable new component
*/ */
@@ -803,7 +803,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -803,7 +798,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/** /**
* Return an immutable copy of all {@link Attribute}s and their * Return an immutable copy of all {@link Attribute}s and their
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.<br> * {@link AttributeModifier}s for a given {@link EquipmentSlot}.<br>

View file

@ -1748,7 +1748,7 @@ index 597a18a767b68b47e81454b7d44613c7178c1366..bc3440eb72127824b3961fbdae583bb6
public ItemStack getInput() { public ItemStack getInput() {
return this.ingredient.getItemStack(); return this.ingredient.getItemStack();
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 5cc1d77a09d2877992433b020ad2c591bb94d3fd..eb14949da2b96aee75e3bba63af8176c5550a380 100644 index 66315ae78d6143ac6bde2b3a2b40b617dc4b1aab..b770541429649cefed3f7f907cc1d9653e395937 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -152,6 +152,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -152,6 +152,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@ -1775,7 +1775,7 @@ index 5cc1d77a09d2877992433b020ad2c591bb94d3fd..eb14949da2b96aee75e3bba63af8176c
* @param name the name to set * @param name the name to set
* @deprecated meta no longer exists * @deprecated meta no longer exists
*/ */
@@ -772,7 +775,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -767,7 +770,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* *
* @return component * @return component
*/ */

View file

@ -112,7 +112,7 @@ index ff6818b6d9e0207eafdd749928f33aeac3f27191..992f39da07bafe9769effaa7dc6adc01
* Checks to see if this item has a maximum amount of damage. * Checks to see if this item has a maximum amount of damage.
* *
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 0151a0523069b00a1cf682ad6b54142aaffcfaa6..7cfdeaafa31b0659cc51848346f5105eb82f8ec4 100644 index e95eac71ab43cadccf99ff594cc77a6d364c46bd..f32102441df03645c1b8c80fdfc944018e5544ca 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -351,7 +351,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -351,7 +351,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@ -124,7 +124,7 @@ index 0151a0523069b00a1cf682ad6b54142aaffcfaa6..7cfdeaafa31b0659cc51848346f5105e
*/ */
void setEnchantable(@Nullable Integer enchantable); void setEnchantable(@Nullable Integer enchantable);
@@ -900,8 +900,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -895,8 +895,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/** /**
* Set all {@link Attribute}s and their {@link AttributeModifier}s. * Set all {@link Attribute}s and their {@link AttributeModifier}s.

View file

@ -228,10 +228,10 @@ index 6d266c111bfa2bd51338e03ed740f6ac81ed07c7..d71531c384c57ea44d1e1fbe394214c1
return key; return key;
} }
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 7cfdeaafa31b0659cc51848346f5105eb82f8ec4..2f0a775a6754554b00ad9140886da9b0101acaf5 100644 index f32102441df03645c1b8c80fdfc944018e5544ca..403c4e7138bcee1321b16fb3aa4cffb2178d4757 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -1033,4 +1033,98 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -1028,4 +1028,98 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@SuppressWarnings("javadoc") @SuppressWarnings("javadoc")
@NotNull @NotNull
ItemMeta clone(); ItemMeta clone();

View file

@ -11,7 +11,7 @@ Co-authored-by: aerulion <aerulion@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9175c61a5c0b8a79c46869649320beaf731a2ab4..3c29f5e1338754728e1acb4676526945b1e7f67c 100644 index 9175c61a5c0b8a79c46869649320beaf731a2ab4..8d2618d82ca37ef084cec2cdcb5423d806d6ddea 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2074,7 +2074,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -2074,7 +2074,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@ -23,7 +23,7 @@ index 9175c61a5c0b8a79c46869649320beaf731a2ab4..3c29f5e1338754728e1acb4676526945
+ this.push(deltaX, deltaY, deltaZ, null); + 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); + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(deltaX, deltaY, deltaZ);
+ if (pushingEntity != null) { + 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); + 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);
@ -158,7 +158,7 @@ index 19f9f4bceca158d9b35be2cdc4d7aa502f44a4b9..cd0a2270b58b6c0dba67270e7e1d1ba2
if (world instanceof ServerLevel worldserver) { if (world instanceof ServerLevel worldserver) {
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
index 6a90feef8eb2d65c925c44bc97305a51e3fb7cf0..7dfbcb2ed831cff5d002d79fb81514e6abf587a4 100644 index 6a90feef8eb2d65c925c44bc97305a51e3fb7cf0..2597f203662cf239f81bd3c75ed70eafbf951169 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java --- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -129,9 +129,9 @@ public class ItemFrame extends HangingEntity { @@ -129,9 +129,9 @@ public class ItemFrame extends HangingEntity {
@ -166,7 +166,7 @@ index 6a90feef8eb2d65c925c44bc97305a51e3fb7cf0..7dfbcb2ed831cff5d002d79fb81514e6
@Override @Override
- public void push(double deltaX, double deltaY, double deltaZ) { - 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) { if (!this.fixed) {
- super.push(deltaX, deltaY, deltaZ); - super.push(deltaX, deltaY, deltaZ);
+ super.push(deltaX, deltaY, deltaZ, pushingEntity); // Paper - add push source entity param + super.push(deltaX, deltaY, deltaZ, pushingEntity); // Paper - add push source entity param
@ -186,6 +186,34 @@ index 1d15465069c8aa57fa89521a8e75c1aeb1cfc096..6c909ea334310f1f9b2d9a2e2cc2f23f
} }
@Override @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 bdf2b22f3f57e99ad7bbc24d391c7773663fda41..6a7e725edece3043c8523d387e2929d5ba8932cb 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
@@ -198,9 +198,9 @@ 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
}
}
@@ -502,9 +502,9 @@ 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 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 8b80f5c2749106f634d962fd0f381aa20e7ef335..a1e3375519fe676b14788d6729a7e71d089cca37 100644 index 8b80f5c2749106f634d962fd0f381aa20e7ef335..a1e3375519fe676b14788d6729a7e71d089cca37 100644
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java --- a/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java
@ -225,9 +253,21 @@ index 3c02f29b3114220b2634d69b413a6724ee4cfdf8..02d8ada43669134695e7edcf33fdac45
Level world = this.level(); Level world = this.level();
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java 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 dd115d514aeb3d124bc99456044f7d176850acab..a05fc651a952b57a8a2fcb32d26d024875037d38 100644 index dd115d514aeb3d124bc99456044f7d176850acab..2b4df4e417b5655341a640a1c133457f78338970 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -410,9 +410,9 @@ 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
}
}
@@ -568,7 +568,7 @@ public abstract class AbstractArrow extends Projectile { @@ -568,7 +568,7 @@ public abstract class AbstractArrow extends Projectile {
Vec3 vec3d = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale(d0 * 0.6D * d1); Vec3 vec3d = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale(d0 * 0.6D * d1);
@ -238,7 +278,7 @@ index dd115d514aeb3d124bc99456044f7d176850acab..a05fc651a952b57a8a2fcb32d26d0248
} }
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 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
index dd14e76ca0813e19a7a531e9009b8f156ae8d896..8022d2d9415d8b2dedee2db0e4f1f0aab8c55bde 100644 index dd14e76ca0813e19a7a531e9009b8f156ae8d896..821c1236901ca0a7d7e0d4c12a69f69e2b5c4363 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java --- a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java +++ b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
@@ -101,7 +101,7 @@ public abstract class AbstractWindCharge extends AbstractHurtingProjectile imple @@ -101,7 +101,7 @@ public abstract class AbstractWindCharge extends AbstractHurtingProjectile imple
@ -246,7 +286,7 @@ index dd14e76ca0813e19a7a531e9009b8f156ae8d896..8022d2d9415d8b2dedee2db0e4f1f0aa
@Override @Override
- public void push(double deltaX, double deltaY, double deltaZ) {} - 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); public abstract void explode(Vec3 pos);

View file

@ -19,7 +19,7 @@ public net.minecraft.world.entity.LivingEntity getDeathSound()Lnet/minecraft/sou
public net.minecraft.world.entity.LivingEntity getSoundVolume()F public net.minecraft.world.entity.LivingEntity getSoundVolume()F
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0a5aeb9b50dfec3b791040348f6a9e929ef8e59c..cec8e2b8867e348d8c92e76983211e29edd46ed1 100644 index 0a5aeb9b50dfec3b791040348f6a9e929ef8e59c..6c3569435cdfcf28acaa7b2dac8664dd14e3e6c2 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -294,6 +294,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { @@ -294,6 +294,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
@ -65,7 +65,7 @@ index 0a5aeb9b50dfec3b791040348f6a9e929ef8e59c..cec8e2b8867e348d8c92e76983211e29
- return super.hurtServer(world, source, amount); - return super.hurtServer(world, source, amount);
+ // Paper start - cancellable death events + // Paper start - cancellable death events
+ //return super.hurt(world, source, amount); + // return super.hurtServer(world, source, amount);
+ this.queueHealthUpdatePacket = true; + this.queueHealthUpdatePacket = true;
+ boolean damaged = super.hurtServer(world, source, amount); + boolean damaged = super.hurtServer(world, source, amount);
+ this.queueHealthUpdatePacket = false; + this.queueHealthUpdatePacket = false;

View file

@ -103,22 +103,20 @@ index 2715ba6325ecf82dee237bb53372e3aac3972112..95c2e2d73aefcf7c436fad3066e1fedc
if (nbt.contains("Brain", 10)) { if (nbt.contains("Brain", 10)) {
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 13064a73a9e3b45d32a098c4179cd980be508abc..8ac12520650501139d53f6db3ae1ee6417db7bb9 100644 index 13064a73a9e3b45d32a098c4179cd980be508abc..a66ed6527d95b9c40b6c5983455fc078fd9eb2bf 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -609,9 +609,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @@ -609,7 +609,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
this.readLeashData(nbt); this.readLeashData(nbt);
this.setLeftHanded(nbt.getBoolean("LeftHanded")); this.setLeftHanded(nbt.getBoolean("LeftHanded"));
if (nbt.contains("DeathLootTable", 8)) { if (nbt.contains("DeathLootTable", 8)) {
- this.lootTable = Optional.of(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("DeathLootTable")))); - this.lootTable = Optional.of(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("DeathLootTable"))));
- } else { + this.lootTable = Optional.ofNullable(ResourceLocation.tryParse(nbt.getString("DeathLootTable"))).map((rs) -> ResourceKey.create(Registries.LOOT_TABLE, rs)); // Paper - Validate ResourceLocation
- this.lootTable = Optional.empty(); } 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 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 0abe2fe6d7cf0a2084b7219c3ab0c5118586a8fe..9c781ad45fd0295cc8ffe5ba901dc7a59ece06f2 100644 index 758fa49f9b420fdbb583ca3443b81ca151478ea8..6edb5a76a503242a6528875184ccd62d6499205f 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -710,7 +710,7 @@ public abstract class AbstractArrow extends Projectile { @@ -710,7 +710,7 @@ public abstract class AbstractArrow extends Projectile {