9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0115-Fix-SculkCatalyst-exp-skip.patch
2025-08-12 21:52:25 +08:00

79 lines
4.9 KiB
Diff

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] Fix SculkCatalyst exp skip
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 70b35fa479bdfcda2f404b3b86547552f7d6da8e..eb391c3ef663ea0267c90a8e46a658e4390040d4 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -1105,7 +1105,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
}
// SPIGOT-5478 must be called manually now
- if (event.shouldDropExperience()) this.dropExperience(this.level(), cause.getEntity()); // Paper - tie to event
+ if (shouldDropExperience(event.shouldDropExperience(), event.forceUseEventDropStatus())) this.dropExperience(this.level(), 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
@@ -1152,6 +1152,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 2cc5c081a75997be637fe753ccdd222e862170c0..e3673ababa41a4d65b87adbc6d79d53a196564b7 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -277,6 +277,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
private Waypoint.Icon locatorBarIcon = new Waypoint.Icon();
// CraftBukkit start
public int expToDrop;
+ public int expToReward; // Leaves - exp fix
public List<DefaultDrop> drops = new java.util.ArrayList<>(); // Paper - Restore vanilla drops behavior
public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
public boolean collides = true;
@@ -1861,6 +1862,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
entity.killedEntity((ServerLevel) this.level(), this);
}
this.gameEvent(GameEvent.ENTITY_DIE);
+ if (!this.wasExperienceConsumed()) this.dropExperience((ServerLevel) this.level(), damageSource.getEntity()); // Leaves - exp fix
} else {
this.dead = false;
this.setHealth((float) deathEvent.getReviveHealth());
@@ -1934,7 +1936,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
this.drops = new java.util.ArrayList<>();
// this.dropEquipment(level); // CraftBukkit - moved up
// CraftBukkit end
- this.dropExperience(level, damageSource.getEntity());
+ // this.dropExperience(level, damageSource.getEntity()); // Leaves - exp fix
return deathEvent; // Paper
}
diff --git a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
index 0a94670dc20bb9c521b0395633eb100393895f6a..a2f73e8210ac554a7529067bbe9f50267f2bf0e2 100644
--- a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
@@ -96,8 +96,7 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi
public boolean handleGameEvent(ServerLevel level, Holder<GameEvent> gameEvent, GameEvent.Context context, Vec3 pos) {
if (gameEvent.is(GameEvent.ENTITY_DIE) && context.sourceEntity() instanceof LivingEntity livingEntity) {
if (!livingEntity.wasExperienceConsumed()) {
- DamageSource lastDamageSource = livingEntity.getLastDamageSource();
- int experienceReward = livingEntity.getExperienceReward(level, Optionull.map(lastDamageSource, DamageSource::getEntity));
+ int experienceReward = livingEntity.expToReward; // Leaves - exp fix
if (livingEntity.shouldDropExperience() && experienceReward > 0) {
this.sculkSpreader.addCursors(BlockPos.containing(pos.relative(Direction.UP, 0.5)), experienceReward);
this.tryAwardItSpreadsAdvancement(level, livingEntity);