mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
58 lines
2.8 KiB
Diff
58 lines
2.8 KiB
Diff
From 8d9bb64a27b05a9a4fa1f3d89929feecec49b475 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 7b54b02e2..69ac51935 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -1866,9 +1866,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 (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 3bb968cfa..915b3beb2 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -178,9 +178,13 @@ public class PurpurWorldConfig {
|
|
elytraDamagePerTridentBoost = getInt("elytra.damage-per-boost.trident", elytraDamagePerTridentBoost);
|
|
}
|
|
|
|
+ public String playerDeathExpDropEquation = "expLevel * 7";
|
|
+ public int playerDeathExpDropMax = 100;
|
|
public boolean playerSleepOnlyWithCondition = false;
|
|
public String playerSleepCondition = "time >= 12541 && time <= 23458";
|
|
private void playerSettings() {
|
|
+ playerDeathExpDropEquation = getString("player.exp-dropped-on-death.equation", playerDeathExpDropEquation);
|
|
+ playerDeathExpDropMax = getInt("player.exp-dropped-on-death.maximum", playerDeathExpDropMax);
|
|
playerSleepOnlyWithCondition = getBoolean("player.sleep.only-with-condition", playerSleepOnlyWithCondition);
|
|
playerSleepCondition = getString("player.sleep.condition", playerSleepCondition);
|
|
}
|
|
--
|
|
2.24.0
|
|
|