Fix logic for unconditional xp orb merging

Fixes GH-936
This commit is contained in:
Zach Brown 2017-11-13 20:30:45 -05:00
parent 9af72652cd
commit ac880e00b4
No known key found for this signature in database
GPG Key ID: CC9DA35FC5450B76
1 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
From 087039842d17fe274692739ca184f79170dc56e8 Mon Sep 17 00:00:00 2001
From 9a01c82ac164d387248cbb3d008629db0d87f176 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 10 Nov 2017 23:03:12 -0500
Subject: [PATCH] Option for maximum exp value when merging orbs
@ -20,16 +20,17 @@ index 14f652d4..47d35228 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 9aec59d3..26d63369 100644
index 9aec59d3..f9c5da59 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1158,16 +1158,29 @@ public abstract class World implements IBlockAccess {
@@ -1158,16 +1158,30 @@ public abstract class World implements IBlockAccess {
EntityExperienceOrb xp = (EntityExperienceOrb) entity;
double radius = spigotConfig.expMerge;
if (radius > 0) {
+ // Paper start - Maximum exp value when merging - Whole section has been tweaked, see comments for specifics
+ final int maxValue = paperConfig.expMergeMaxValue;
+ if (maxValue <= 0 || xp.value < maxValue) { // Paper - Skip iteration if unnecessary
+ final boolean mergeUnconditionally = maxValue <= 0;
+ if (mergeUnconditionally || xp.value < maxValue) { // Paper - Skip iteration if unnecessary
+
List<Entity> entities = this.getEntities(entity, entity.getBoundingBox().grow(radius, radius, radius));
for (Entity e : entities) {
@ -39,7 +40,7 @@ index 9aec59d3..26d63369 100644
+ if (!loopItem.dead && !(maxValue > 0 && loopItem.value >= maxValue)) { // Paper
xp.value += loopItem.value;
+ // Paper start
+ if (xp.value > maxValue) {
+ if (!mergeUnconditionally && xp.value > maxValue) {
+ loopItem.value = xp.value - maxValue;
+ xp.value = maxValue;
+ break;
@ -55,5 +56,5 @@ index 9aec59d3..26d63369 100644
} // Spigot end
--
2.14.2
2.14.3