From 86ce2067dc9ee3dc2ddaefb176cf93ecfdf6644e Mon Sep 17 00:00:00 2001 From: silnarm Date: Sun, 13 Aug 2023 06:31:43 +1000 Subject: [PATCH 1/2] fix-fake-player-xp-not-resetting-on-death * remove XP on bot death * fixes #1797 --- src/main/java/carpet/patches/EntityPlayerMPFake.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index db02223034..1bce9e3208 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -187,6 +187,7 @@ public void die(DamageSource cause) shakeOff(); super.die(cause); setHealth(20); + giveExperienceLevels(-(experienceLevel + 1)); this.foodData = new FoodData(); kill(this.getCombatTracker().getDeathMessage()); } From 71b8eaef7bd9d41ceef5606ef9dab229b1139030 Mon Sep 17 00:00:00 2001 From: silnarm Date: Sun, 13 Aug 2023 11:30:42 +1000 Subject: [PATCH 2/2] fix-fake-player-xp-not-resetting-on-death * only remove XP if not KEEPINVENTORY --- src/main/java/carpet/patches/EntityPlayerMPFake.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index 1bce9e3208..7b003c8498 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -23,6 +23,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.food.FoodData; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.SkullBlockEntity; @@ -187,7 +188,9 @@ public void die(DamageSource cause) shakeOff(); super.die(cause); setHealth(20); - giveExperienceLevels(-(experienceLevel + 1)); + if (!this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY)) { + giveExperienceLevels(-(experienceLevel + 1)); + } this.foodData = new FoodData(); kill(this.getCombatTracker().getDeathMessage()); }