Fix SafeNBTCopy#hasKey semantics

Fixes hasKey to check that a key actually exists, while retaining the
option to scream at keys which are requested which haven't been marked as
needing to be copied
This commit is contained in:
Shane Freeder 2020-10-17 12:46:35 +01:00
parent 85eccb571b
commit 8319e912f4

View file

@ -16,7 +16,7 @@ We further improve it by making a copy of the nbt tag with only the memory
it needs, so that we dont have to hold a copy to the entire compound. it needs, so that we dont have to hold a copy to the entire compound.
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index f18cb4aedc4a6536bf45db591b6d2b64cefce676..c27078630bffe1b2493b42c9ae4431fb1cc5ca09 100644 index f18cb4aedc4a6536bf45db591b6d2b64cefce676..5eb14b330d3f175e22650f292aa6c040f24e9492 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -156,15 +156,9 @@ public class ChunkRegionLoader { @@ -156,15 +156,9 @@ public class ChunkRegionLoader {
@ -38,7 +38,7 @@ index f18cb4aedc4a6536bf45db591b6d2b64cefce676..c27078630bffe1b2493b42c9ae4431fb
} else { } else {
ProtoChunk protochunk = new ProtoChunk(chunkcoordintpair, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, worldserver); // Paper - Anti-Xray - Add parameter ProtoChunk protochunk = new ProtoChunk(chunkcoordintpair, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, worldserver); // Paper - Anti-Xray - Add parameter
@@ -270,6 +264,48 @@ public class ChunkRegionLoader { @@ -270,6 +264,50 @@ public class ChunkRegionLoader {
return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading
} }
} }
@ -61,8 +61,10 @@ index f18cb4aedc4a6536bf45db591b6d2b64cefce676..c27078630bffe1b2493b42c9ae4431fb
+ +
+ @Override + @Override
+ public boolean hasKey(String s) { + public boolean hasKey(String s) {
+ if (this.keys.contains(s)) { + if (super.hasKey(s)) {
+ return true; + return true;
+ } else if (keys.contains(s)) {
+ return false;
+ } + }
+ throw new IllegalStateException("Missing Key " + s + " in SafeNBTCopy"); + throw new IllegalStateException("Missing Key " + s + " in SafeNBTCopy");
+ } + }