Files
Purpur/patches/server/0073-Add-player-death-exp-control-options.patch
BillyGalbreath b8fb7ff5b5 Updated Upstream (Paper)
Upstream has released updates that appears to apply and compile correctly

Paper Changes:
821ce25d9 Significantly improve performance of the end generation
2b2e4fd65 Add Wandering Trader spawn rate config options
7263cbca7 [CI-SKIP] [Auto] Rebuild Patches
1c63aff6d Villager resetOffers API
8d8d74a5f Patch 2 references an invalid variable
e6d7bdca1 [CI-SKIP] fixed sed -i for bsd sed (#4782)
7ae47d4eb [CI-SKIP] Remove Waving banner fix (#4786)
2020-11-19 21:31:10 -06:00

60 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 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
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 335cb9c4a..75f987411 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -85,6 +85,8 @@ public abstract class EntityHuman extends EntityLiving {
// CraftBukkit end
// Purpur start
+ private javax.script.ScriptEngine scriptEngine = new javax.script.ScriptEngineManager().getEngineByName("rhino");
+
public void setAfk(boolean setAfk){
}
@@ -1716,9 +1718,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 7088bee59..adcd1779c 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -123,6 +123,13 @@ public class PurpurWorldConfig {
tridentLoyaltyVoidReturnHeight = getDouble("gameplay-mechanics.trident-loyalty-void-return-height", tridentLoyaltyVoidReturnHeight);
}
+ public String playerDeathExpDropEquation = "expLevel * 7";
+ public int playerDeathExpDropMax = 100;
+ private void playerDeathExpSettings() {
+ playerDeathExpDropEquation = getString("gameplay-mechanics.player.exp-dropped-on-death.equation", playerDeathExpDropEquation);
+ playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax);
+ }
+
public int playerSpawnInvulnerableTicks = 60;
public boolean playerInvulnerableWhileAcceptingResourcePack = false;
private void playerInvulnerabilities() {