Files
Purpur/patches/server/0087-Add-player-death-exp-control-options.patch
William Blake Galbreath 4757060211 Updated Upstream (Paper)
Upstream has released updates that appears to apply and compile correctly

Paper Changes:
df0d7b0d Update upstream CB
6ea3c2cf [CI-SKIP] Rebuild patches
d7bed4cb Heavily optimise random block ticking (#2914)
b66d9ff8 Update upstream CB
ba71c5d6 Stop stripping private use block Unicode from signs
28d9dcfc Entity Jump API (#1587)
9976a768 Fix PlayerNaturallySpawnCreaturesEvent boolean inversion
054e20da Clean up imports on ThrownEggHatchEvent
a8984ccb Add ThrownEggHatchEvent (#1982)
9f24d495 Allow nerfed blazes, endermen to take water damage (#2847)
2020-02-12 21:21:34 -06:00

62 lines
3.4 KiB
Diff

From 8fc6b3ab7cec00691e7708dd84da8b8fb1703fd9 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
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 12e5ff43f..427a32cdd 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 (javax.script.ScriptException 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 4f85b4ea8..5c12f199f 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -163,6 +163,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;
@@ -189,6 +191,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