Skip to content

Commit

Permalink
Add support for 1.16.1 join game codec (fix error)
Browse files Browse the repository at this point in the history
  • Loading branch information
retrooper committed Oct 28, 2024
1 parent f66626a commit 5247ccd
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,25 @@ public static void handleLegacyRegistries(
) {
Object cacheKey = PacketEvents.getAPI().getServerManager().getRegistryCacheKey(user, version);
for (NBT tag : registryData.getTags().values()) {
NBTCompound compound = (NBTCompound) tag;
// extract registry name
ResourceLocation registryName = new ResourceLocation(compound.getStringTagValueOrThrow("type"));
// extract registry entries
NBTList<NBTCompound> nbtElements = compound.getCompoundListTagOrNull("value");
if (nbtElements != null) {
// store registry elements
handleRegistry(user, version, registryName,
RegistryElement.convertNbt(nbtElements), cacheKey);
//On 1.16 they send an NBTList for dimension.
if (tag instanceof NBTList) {
NBTList<NBTCompound> list = (NBTList<NBTCompound>) tag;
handleRegistry(user, version, DimensionTypes.getRegistry().getRegistryKey(),
RegistryElement.convertNbt(list), cacheKey);

}
//Newer versions
else {
NBTCompound compound = (NBTCompound) tag;
// extract registry name
ResourceLocation registryName = new ResourceLocation(compound.getStringTagValueOrThrow("type"));
// extract registry entries
NBTList<NBTCompound> nbtElements = compound.getCompoundListTagOrNull("value");
if (nbtElements != null) {
// store registry elements
handleRegistry(user, version, registryName,
RegistryElement.convertNbt(nbtElements), cacheKey);
}
}
}
}
Expand Down

0 comments on commit 5247ccd

Please sign in to comment.