From f95da817c482cae8e3f7434384d731ddc0469d5c Mon Sep 17 00:00:00 2001 From: tterrag Date: Mon, 10 Sep 2018 02:45:06 -0400 Subject: [PATCH] Fix AnvilChunkLoader not having access to chunk cap dispatcher --- .../minecraft/world/chunk/Chunk.java.patch | 30 +++++++++++++++++++ .../chunk/storage/AnvilChunkLoader.java.patch | 23 +++++++------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch b/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch index 434707fa00..6dbc926a34 100644 --- a/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch @@ -17,3 +17,33 @@ } public Chunk(World p_i48703_1_, ChunkPrimer p_i48703_2_, int p_i48703_3_, int p_i48703_4_) { +@@ -1164,4 +1165,29 @@ + QUEUED, + CHECK; + } ++ ++ // FORGE start ++ ++ /** ++ * FOR INTERNAL USE ONLY ++ *

++ * Only public for use in {@link AnvilChunkLoader}. ++ */ ++ @java.lang.Deprecated ++ @javax.annotation.Nullable ++ public final NBTTagCompound writeCapsToNBT() ++ { ++ return this.serializeCaps(); + } ++ ++ /** ++ * FOR INTERNAL USE ONLY ++ *

++ * Only public for use in {@link AnvilChunkLoader}. ++ */ ++ @java.lang.Deprecated ++ public final void readCapsFromNBT(NBTTagCompound tag) ++ { ++ this.deserializeCaps(tag); ++ } ++} diff --git a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch index fad6efd867..88c6d519c6 100644 --- a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch @@ -1,31 +1,32 @@ --- a/net/minecraft/world/chunk/storage/AnvilChunkLoader.java +++ b/net/minecraft/world/chunk/storage/AnvilChunkLoader.java -@@ -445,7 +445,19 @@ +@@ -445,7 +445,20 @@ compound.setTag("Heightmaps", nbttagcompound2); compound.setTag("Structures", this.func_202160_a(chunkIn.x, chunkIn.z, chunkIn.func_201609_c(), chunkIn.func_201604_d())); + -+ if (chunkIn.getCapabilities() != null) ++ try + { -+ try ++ final NBTTagCompound capTag = chunkIn.writeCapsToNBT(); ++ if (capTag != null) + { -+ compound.setTag("ForgeCaps", chunkIn.getCapabilities().serializeNBT()); ++ compound.setTag("ForgeCaps", capTag); } -+ catch (Exception exception) -+ { -+ org.apache.logging.log4j.LogManager.getLogger().error("A capability provider has thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); -+ } ++ } ++ catch (Exception exception) ++ { ++ org.apache.logging.log4j.LogManager.getLogger().error("A capability provider has thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); + } + } private Chunk readChunkFromNBT(IWorld worldIn, NBTTagCompound compound) { int i = compound.getInteger("xPos"); -@@ -511,6 +523,10 @@ +@@ -511,6 +524,10 @@ chunk.setModified(true); } -+ if (chunk.getCapabilities() != null && compound.hasKey("ForgeCaps")) { -+ chunk.getCapabilities().deserializeNBT(compound.getCompoundTag("ForgeCaps")); ++ if (compound.hasKey("ForgeCaps")) { ++ chunk.readCapsFromNBT(compound.getCompoundTag("ForgeCaps")); + } + return chunk;