Don't assume that entries exist for SafeNBTCopy

This commit is contained in:
Shane Freeder 2020-10-17 12:20:44 +01:00
parent 595734a57e
commit 85eccb571b

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..fd75bca8d42b2b70e6fe71d6e1b8402eb56e507a 100644 index f18cb4aedc4a6536bf45db591b6d2b64cefce676..c27078630bffe1b2493b42c9ae4431fb1cc5ca09 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..fd75bca8d42b2b70e6fe71d6e1b8402e
} 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,45 @@ public class ChunkRegionLoader { @@ -270,6 +264,48 @@ public class ChunkRegionLoader {
return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading
} }
} }
@ -52,7 +52,10 @@ index f18cb4aedc4a6536bf45db591b6d2b64cefce676..fd75bca8d42b2b70e6fe71d6e1b8402e
+ public SafeNBTCopy(NBTTagCompound base, String... keys) { + public SafeNBTCopy(NBTTagCompound base, String... keys) {
+ for (String key : keys) { + for (String key : keys) {
+ this.keys.add(key); + this.keys.add(key);
+ this.set(key, base.get(key)); + final NBTBase nbtBase = base.get(key);
+ if (nbtBase != null) {
+ this.set(key, nbtBase);
+ }
+ } + }
+ } + }
+ +