Fix AnvilChunkLoader not having access to chunk cap dispatcher
This commit is contained in:
parent
a4f2802306
commit
f95da817c4
2 changed files with 42 additions and 11 deletions
|
@ -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
|
||||
+
|
||||
+ /**
|
||||
+ * <strong>FOR INTERNAL USE ONLY</strong>
|
||||
+ * <p>
|
||||
+ * Only public for use in {@link AnvilChunkLoader}.
|
||||
+ */
|
||||
+ @java.lang.Deprecated
|
||||
+ @javax.annotation.Nullable
|
||||
+ public final NBTTagCompound writeCapsToNBT()
|
||||
+ {
|
||||
+ return this.serializeCaps();
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * <strong>FOR INTERNAL USE ONLY</strong>
|
||||
+ * <p>
|
||||
+ * Only public for use in {@link AnvilChunkLoader}.
|
||||
+ */
|
||||
+ @java.lang.Deprecated
|
||||
+ public final void readCapsFromNBT(NBTTagCompound tag)
|
||||
+ {
|
||||
+ this.deserializeCaps(tag);
|
||||
+ }
|
||||
+}
|
||||
|
|
|
@ -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
|
||||
+ {
|
||||
+ compound.setTag("ForgeCaps", chunkIn.getCapabilities().serializeNBT());
|
||||
+ final NBTTagCompound capTag = chunkIn.writeCapsToNBT();
|
||||
+ if (capTag != null)
|
||||
+ {
|
||||
+ 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);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue