From add580a44ba97074cfef1eab62e1175a452beea2 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Thu, 26 Dec 2019 22:08:37 -0600 Subject: [PATCH] Add player death exp control options --- .../java/net/minecraft/server/EntityHuman.java | 15 ++++++++++++--- .../java/net/pl3x/purpur/PurpurWorldConfig.java | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 22e17e3de..14b57d678 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -1862,9 +1862,18 @@ public abstract class EntityHuman extends EntityLiving { @Override protected int getExpValue(EntityHuman entityhuman) { if (!this.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY) && !this.isSpectator()) { - int i = this.expLevel * 7; - - return i > 100 ? 100 : i; + // Purpur start + int toDrop; + try { + scriptEngine.eval("expLevel = " + expLevel); + scriptEngine.eval("expTotal = " + expTotal); + scriptEngine.eval("exp = " + exp); + toDrop = (int) Math.round((Double) scriptEngine.eval(world.purpurConfig.playerDeathExpDropEquation)); + } catch (Exception ignore) { + toDrop = expLevel * 7; + } + return Math.min(toDrop, world.purpurConfig.playerDeathExpDropMax); + // Purpur end } else { return 0; } diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 7d2c51a2f..caf7f0e84 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -155,6 +155,8 @@ public class PurpurWorldConfig { public boolean disableDropsOnCrammingDeath = false; public boolean fixClimbingBypassingCrammingRule = false; public boolean milkCuresBadOmen = true; + public String playerDeathExpDropEquation = "expLevel * 7"; + public int playerDeathExpDropMax = 100; public boolean playerSleepOnlyWithCondition = false; public String playerSleepCondition = "time >= 12541 && time <= 23458"; public boolean useBetterMending = false; @@ -181,6 +183,8 @@ public class PurpurWorldConfig { disableDropsOnCrammingDeath = getBoolean("gameplay-mechanics.disable-drops-on-cramming-death", disableDropsOnCrammingDeath); fixClimbingBypassingCrammingRule = getBoolean("gameplay-mechanics.fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule); milkCuresBadOmen = getBoolean("gameplay-mechanics.milk-cures-bad-omen", milkCuresBadOmen); + playerDeathExpDropEquation = getString("gameplay-mechanics.player.exp-dropped-on-death.equation", playerDeathExpDropEquation); + playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax); playerSleepOnlyWithCondition = getBoolean("gameplay-mechanics.player.sleep.only-with-condition", playerSleepOnlyWithCondition); playerSleepCondition = getString("gameplay-mechanics.player.sleep.condition", playerSleepCondition); useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending); -- 2.24.0