Skip to content

Commit

Permalink
Fixing errors occurring on servers using ResourceLocation Compressor
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonCaramel committed Feb 22, 2024
1 parent 3cf1ee7 commit 19237fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ else if (event.getPacketType() == PacketType.Configuration.Server.REGISTRY_DATA)
// Store world data
NBTCompound registryDataTag = registryData.getRegistryData();
if (registryDataTag != null) {
NBTList<NBTCompound> list = registryDataTag
.getCompoundTagOrNull("minecraft:dimension_type")
NBTCompound dimension = registryDataTag
.getCompoundTagOrNull("minecraft:dimension_type");
if (dimension == null) {
dimension = registryDataTag
.getCompoundTagOrNull("dimension_type");
}
NBTList<NBTCompound> list = dimension
.getCompoundListTagOrNull("value");
user.setWorldNBT(list);
}
Expand All @@ -109,8 +114,13 @@ else if (event.getPacketType() == PacketType.Play.Server.JOIN_GAME) {
// Store world data
NBTCompound dimensionCodec = joinGame.getDimensionCodec();
if (dimensionCodec != null) {
NBTList<NBTCompound> list = dimensionCodec
.getCompoundTagOrNull("minecraft:dimension_type")
NBTCompound dimension = dimensionCodec
.getCompoundTagOrNull("minecraft:dimension_type");
if (dimension == null) {
dimension = dimensionCodec
.getCompoundTagOrNull("dimension_type");
}
NBTList<NBTCompound> list = dimension
.getCompoundListTagOrNull("value");
user.setWorldNBT(list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,17 @@ public NBTCompound getWorldNBT(String worldName) {
}
return null;
}

@Nullable
public NBTCompound getWorldNBT(final com.github.retrooper.packetevents.resources.ResourceLocation worldName) {
if (worldNBT == null) {
return null;
}
for (NBTCompound compound : worldNBT) {
if (new com.github.retrooper.packetevents.resources.ResourceLocation(compound.getStringTagOrNull("name").getValue()).equals(worldName)) {
return compound;
}
}
return null;
}
}

0 comments on commit 19237fd

Please sign in to comment.