From a75c747cd71af4a12a2477b4abba5fd88a304c2b Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 3 Aug 2018 20:59:35 -0400 Subject: [PATCH] Fix logic bug in negative XP bug fix - Closes #1169 --- .../Always-process-chunk-removal-in-removeEntity.patch | 2 +- ...id-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch | 2 +- Spigot-Server-Patches/ExperienceOrbMergeEvent.patch | 6 +++--- .../Ignore-Dead-Entities-in-entityList-iteration.patch | 2 +- .../Option-for-maximum-exp-value-when-merging-orbs.patch | 7 ++++--- .../Prevent-Saving-Bad-entities-to-chunks.patch | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Spigot-Server-Patches/Always-process-chunk-removal-in-removeEntity.patch b/Spigot-Server-Patches/Always-process-chunk-removal-in-removeEntity.patch index 845d2407e..f8bfde448 100644 --- a/Spigot-Server-Patches/Always-process-chunk-removal-in-removeEntity.patch +++ b/Spigot-Server-Patches/Always-process-chunk-removal-in-removeEntity.patch @@ -8,7 +8,7 @@ which can keep them in the chunk when they shouldnt be if done during entity ticking. diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 0aa2f99838..8822d17745 100644 +index 2a4405638e..eabcb4c8f9 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { diff --git a/Spigot-Server-Patches/Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch b/Spigot-Server-Patches/Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch index bbf73d5df..a64c9d60c 100644 --- a/Spigot-Server-Patches/Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch +++ b/Spigot-Server-Patches/Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch @@ -22,7 +22,7 @@ index d24d45fdd3..4757081090 100644 this.a(entity, entity.ac); } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 986670f689..a01488e985 100644 +index e361883099..5de8da65c0 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { diff --git a/Spigot-Server-Patches/ExperienceOrbMergeEvent.patch b/Spigot-Server-Patches/ExperienceOrbMergeEvent.patch index 0c371550f..d2bfd66c1 100644 --- a/Spigot-Server-Patches/ExperienceOrbMergeEvent.patch +++ b/Spigot-Server-Patches/ExperienceOrbMergeEvent.patch @@ -8,7 +8,7 @@ Plugins can cancel this if they want to ensure experience orbs do not lose impor metadata such as spawn reason, or conditionally move data from source to target. diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index c0e79796bd..986670f689 100644 +index 60bfe2608d..e361883099 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { @@ -18,6 +18,6 @@ index c0e79796bd..986670f689 100644 - if (!loopItem.dead && !(maxValue > 0 && loopItem.value >= maxValue)) { + if (!loopItem.dead && !(maxValue > 0 && loopItem.value >= maxValue) && new com.destroystokyo.paper.event.entity.ExperienceOrbMergeEvent((org.bukkit.entity.ExperienceOrb) entity.getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) loopItem.getBukkitEntity()).callEvent()) { long newTotal = (long)xp.value + (long)loopItem.value; - if (newTotal > (long)maxValue) { - loopItem.value = xp.value - maxValue; + if ((int) newTotal < 0) continue; // Overflow + if (maxValue > 0 && newTotal > (long)maxValue) { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch b/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch index 949ed5abc..d704ce52c 100644 --- a/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch +++ b/Spigot-Server-Patches/Ignore-Dead-Entities-in-entityList-iteration.patch @@ -35,7 +35,7 @@ index 1e64d5fcd6..45e149f4a3 100644 public float length; public float I; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 8822d17745..3ce6f9778b 100644 +index eabcb4c8f9..d763b48167 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { diff --git a/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch b/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch index dc1dcec08..7925d5ecd 100644 --- a/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch +++ b/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch @@ -20,7 +20,7 @@ index 4d30cdbc8b..535a8d3ed1 100644 + } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 3561507de1..b6b4d52718 100644 +index 3561507de1..b2f04595a6 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { @@ -42,8 +42,9 @@ index 3561507de1..b6b4d52718 100644 + // Paper start + if (!loopItem.dead && !(maxValue > 0 && loopItem.value >= maxValue)) { + long newTotal = (long)xp.value + (long)loopItem.value; -+ if (newTotal > (long)maxValue) { -+ loopItem.value = xp.value - maxValue; ++ if ((int) newTotal < 0) continue; // Overflow ++ if (maxValue > 0 && newTotal > (long)maxValue) { ++ loopItem.value = (int) (newTotal - maxValue); + xp.value = maxValue; + } else { + xp.value += loopItem.value; diff --git a/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch b/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch index 5185e2456..c2a9c259f 100644 --- a/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch +++ b/Spigot-Server-Patches/Prevent-Saving-Bad-entities-to-chunks.patch @@ -57,7 +57,7 @@ index bcce5e8b7e..bad287fca4 100644 nbttagcompound.set("Entities", nbttaglist1); NBTTagList nbttaglist2 = new NBTTagList(); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 3012768cb9..0aa2f99838 100644 +index c53e77b821..2a4405638e 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {