Skip to content

Commit

Permalink
Revert "Revert "Add function to merge NBTTagCompound, its present on …
Browse files Browse the repository at this point in the history
…modern versions, it might help compatibility with a few plugins.""

We can keep "merge" function, we just can't edit any other.

This reverts commit 73744e8.
  • Loading branch information
EverNife committed Apr 19, 2022
1 parent 73744e8 commit 4eab54a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion patches/net/minecraft/nbt/NBTTagCompound.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,39 @@
return nbttagcompound;
}

@@ -407,4 +418,29 @@
@@ -407,4 +418,57 @@
throw new ReportedException(crashreport);
}
}
+
+ /**
+ * Merges copies of data contained in {@code other} into this compound tag.
+ */
+ public void merge(NBTTagCompound other)
+ {
+ for (String s : other.tagMap.keySet())
+ {
+ NBTBase nbtbase = other.tagMap.get(s);
+
+ if (nbtbase.getId() == 10)
+ {
+ if (this.hasKey(s, 10))
+ {
+ NBTTagCompound nbttagcompound = this.getCompoundTag(s);
+ nbttagcompound.merge((NBTTagCompound)nbtbase);
+ }
+ else
+ {
+ this.setTag(s, nbtbase.copy());
+ }
+ }
+ else
+ {
+ this.setTag(s, nbtbase.copy());
+ }
+ }
+ }
+
+ @Override
+ public String crucible_toString()
+ {
Expand Down

0 comments on commit 4eab54a

Please sign in to comment.