From fa10f4cc523f68d46eb80a97bce16813e360c85e Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Fri, 25 Apr 2025 23:55:05 +0800 Subject: [PATCH] Leaves Fix SculkCatalyst exp skip (Leaves#471) --- ...10-Leaves-Fix-SculkCatalyst-exp-skip.patch | 88 +++++++++++++++++++ ...til.patch => 0052-Lithium-fast-util.patch} | 0 ...cessary-calculations-if-player-is-n.patch} | 6 +- ... => 0054-Fix-SculkCatalyst-exp-skip.patch} | 33 ++++++- 4 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 luminol-api/paper-patches/features/0010-Leaves-Fix-SculkCatalyst-exp-skip.patch rename luminol-server/minecraft-patches/features/{0053-Lithium-fast-util.patch => 0052-Lithium-fast-util.patch} (100%) rename luminol-server/minecraft-patches/features/{0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch => 0053-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch} (87%) rename luminol-server/minecraft-patches/features/{0052-Leaves-Fix-SculkCatalyst-exp-skip.patch => 0054-Fix-SculkCatalyst-exp-skip.patch} (64%) diff --git a/luminol-api/paper-patches/features/0010-Leaves-Fix-SculkCatalyst-exp-skip.patch b/luminol-api/paper-patches/features/0010-Leaves-Fix-SculkCatalyst-exp-skip.patch new file mode 100644 index 0000000..e0d2db2 --- /dev/null +++ b/luminol-api/paper-patches/features/0010-Leaves-Fix-SculkCatalyst-exp-skip.patch @@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Sun, 6 Apr 2025 10:42:47 +0800 +Subject: [PATCH] Fix SculkCatalyst exp skip + + +diff --git a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java +index 42ffb81708b327f765ba3235fdd1ab69cd7589fd..0a7e37420f8d024ffba1fd1c52edc50c10408e6e 100644 +--- a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java ++++ b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java +@@ -25,17 +25,25 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca + private float deathSoundVolume; + private float deathSoundPitch; + // Paper end ++ private int rewardExp; // Leaves - exp fix + + public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull DamageSource damageSource, @NotNull final List drops) { + this(entity, damageSource, drops, 0); + } + + public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp) { ++ // Leaves start - exp fix ++ this(what, damageSource, drops, droppedExp, droppedExp); ++ } ++ ++ public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, final int rewardExp) { + super(what); + this.damageSource = damageSource; + this.drops = drops; + this.dropExp = droppedExp; ++ this.rewardExp = rewardExp; + } ++ // Leaves end - exp fix + + @NotNull + @Override +@@ -75,6 +83,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca + */ + public void setDroppedExp(int exp) { + this.dropExp = exp; ++ this.rewardExp = exp; // Leaves - exp fix + } + + /** +@@ -226,4 +235,14 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca + this.deathSoundPitch = pitch; + } + // Paper end ++ ++ // Leaves start - exp fix ++ public int getRewardExp() { ++ return rewardExp; ++ } ++ ++ public void setRewardExp(int rewardExp) { ++ this.rewardExp = rewardExp; ++ } ++ // Leaves end - exp fix + } +diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +index ab7584873e46020148bceecbd42a43055684e6a0..7c99b1c6f5fc8e4ce442d111e7598ddb89d6ee05 100644 +--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java ++++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +@@ -18,6 +18,7 @@ public class PlayerDeathEvent extends EntityDeathEvent { + private boolean keepLevel = false; + private boolean keepInventory = false; + private boolean doExpDrop; // Paper - shouldDropExperience API ++ private boolean useApiExpDropStatus = false; // Leaves - exp fix + // Paper start - adventure + @org.jetbrains.annotations.ApiStatus.Internal + public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final @Nullable net.kyori.adventure.text.Component deathMessage) { +@@ -122,9 +123,16 @@ public class PlayerDeathEvent extends EntityDeathEvent { + */ + public void setShouldDropExperience(boolean doExpDrop) { + this.doExpDrop = doExpDrop; ++ this.useApiExpDropStatus = true; // Leaves - exp fix + } + // Paper end - shouldDropExperience API + ++ // Leaves start - exp fix ++ public boolean forceUseEventDropStatus() { ++ return this.useApiExpDropStatus; ++ } ++ // Leaves end - exp fix ++ + @NotNull + @Override + public Player getEntity() { diff --git a/luminol-server/minecraft-patches/features/0053-Lithium-fast-util.patch b/luminol-server/minecraft-patches/features/0052-Lithium-fast-util.patch similarity index 100% rename from luminol-server/minecraft-patches/features/0053-Lithium-fast-util.patch rename to luminol-server/minecraft-patches/features/0052-Lithium-fast-util.patch diff --git a/luminol-server/minecraft-patches/features/0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch b/luminol-server/minecraft-patches/features/0053-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch similarity index 87% rename from luminol-server/minecraft-patches/features/0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch rename to luminol-server/minecraft-patches/features/0053-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch index 8653562..ce8d504 100644 --- a/luminol-server/minecraft-patches/features/0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch +++ b/luminol-server/minecraft-patches/features/0053-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch @@ -12,10 +12,10 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 658aa09aecf8d64145feedb82dc9be2a55201450..1df158d30622ea71fcc937140c682d0e994d54c1 100644 +index 2293c3db45e9ecce4e0d4b2f87b8e90228e44d94..015a6c45241148eb5a26f9494ca731354273f3cd 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -2644,6 +2644,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2642,6 +2642,7 @@ public abstract class LivingEntity extends Entity implements Attackable { } protected void updateSwingTime() { @@ -23,7 +23,7 @@ index 658aa09aecf8d64145feedb82dc9be2a55201450..1df158d30622ea71fcc937140c682d0e int currentSwingDuration = this.getCurrentSwingDuration(); if (this.swinging) { this.swingTime++; -@@ -3569,6 +3570,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3567,6 +3568,7 @@ public abstract class LivingEntity extends Entity implements Attackable { protected void updateFallFlying() { this.checkSlowFallDistance(); if (!this.level().isClientSide) { diff --git a/luminol-server/minecraft-patches/features/0052-Leaves-Fix-SculkCatalyst-exp-skip.patch b/luminol-server/minecraft-patches/features/0054-Fix-SculkCatalyst-exp-skip.patch similarity index 64% rename from luminol-server/minecraft-patches/features/0052-Leaves-Fix-SculkCatalyst-exp-skip.patch rename to luminol-server/minecraft-patches/features/0054-Fix-SculkCatalyst-exp-skip.patch index 971be6c..2a7d394 100644 --- a/luminol-server/minecraft-patches/features/0052-Leaves-Fix-SculkCatalyst-exp-skip.patch +++ b/luminol-server/minecraft-patches/features/0054-Fix-SculkCatalyst-exp-skip.patch @@ -1,11 +1,40 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Sun, 6 Apr 2025 10:42:45 +0800 -Subject: [PATCH] Leaves Fix SculkCatalyst exp skip +Subject: [PATCH] Fix SculkCatalyst exp skip +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index c2562b8f7ca3bc815a5abe5ae00a6fe1654b002d..884d338e00017ff351b91c70fb51186cbdfb1fe6 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -1346,7 +1346,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + } + + // SPIGOT-5478 must be called manually now +- if (event.shouldDropExperience()) this.dropExperience(this.serverLevel(), cause.getEntity()); // Paper - tie to event ++ if (shouldDropExperience(event.shouldDropExperience(), event.forceUseEventDropStatus())) this.dropExperience(this.serverLevel(), cause.getEntity()); // Paper - tie to event // Leaves - exp fix + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { + // Paper start - PlayerDeathEvent#getItemsToKeep +@@ -1380,6 +1380,15 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.setClientLoaded(false); + } + ++ // Leaves start - exp fix ++ private boolean shouldDropExperience(boolean eventResult, boolean forceUseEvent) { ++ if (forceUseEvent) { ++ return eventResult; ++ } ++ return wasExperienceConsumed() ? false : eventResult; ++ } ++ // Leaves end - exp fix ++ + private void tellNeutralMobsThatIDied() { + AABB aabb = new AABB(this.blockPosition()).inflate(32.0, 10.0, 32.0); + this.level() diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 2293c3db45e9ecce4e0d4b2f87b8e90228e44d94..658aa09aecf8d64145feedb82dc9be2a55201450 100644 +index 015a6c45241148eb5a26f9494ca731354273f3cd..1df158d30622ea71fcc937140c682d0e994d54c1 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -293,6 +293,7 @@ public abstract class LivingEntity extends Entity implements Attackable {