Files
Purpur/patches/server/0066-Add-player-death-exp-control-options.patch
BillyGalbreath e53522571d Updated Upstream (Paper & Tuinity)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
808bd9198 Add fast alternative constructor for Vector3f (#5339)
e849c51da fix #5336
0b25bacfc fix patch 'Remove streams from SensorNearest' (fixes #5330)
4d287e31c Use Adventure for `/version` command feedback, add copy to clipboard click event (#5333)

Tuinity Changes:
5b6d8beec: Update Upstream (Paper)
81d5fc1dd: Fix NPE in pickup logic for arrow
19ac6608f: Move region chunk unload & poi unload hook up
38ad5a1bd: Do not run close logic for inventories on chunk load
fb75a6f83: Do not allow the server to unload chunks at request of plugins
f87cb795f: Make entity tracker use highest range of passengers
71b089f18: Do not run raytrace logic for AIR
09e1a1036: Fix NPE in light exception handler
0ae7c2c23: Dump even more info for ticking entities
2e4a930c4: Store changed positions inside field on light engine
7734ef0a9: Detail player ticking in watchdog dumps
2021-03-11 15:01:23 -06:00

60 lines
2.9 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 390aae2733e397ac5c6c457c76bf75f9c8dcd873..ab2ad054ce8d896e38ab4eb6ed38d8ea73d42954 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 d5adf653c6a561fe1de9e340d85c9439f8c559f5..c5574ac52d050cc1b89ab2dbd4dad5ce5e331f83 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() {