diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index 0d59f9e93..ec779269f 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -80,7 +80,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_17_1 = register(756, "1.17.1"); public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1)); public static final ProtocolVersion v1_18_2 = register(758, "1.18.2"); - public static final ProtocolVersion v1_19 = register(759, 87, "1.19"); + public static final ProtocolVersion v1_19 = register(759, 89, "1.19"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static ProtocolVersion register(int version, String name) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java index 666659bb9..7430537ee 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/EntityPackets.java @@ -21,6 +21,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.Tag; +import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.data.entity.DimensionData; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types; @@ -77,7 +78,7 @@ public final class EntityPackets extends EntityRewriter { static { try { CHAT_REGISTRY = BinaryTagIO.readString(CHAT_REGISTRY_SNBT).get("minecraft:chat_type"); - } catch (IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } } @@ -214,11 +215,11 @@ public final class EntityPackets extends EntityRewriter { for (final Tag dimension : dimensions) { final CompoundTag dimensionCompound = (CompoundTag) dimension; final CompoundTag element = dimensionCompound.get("element"); - addMonsterSpawnData(element); - final String name = (String) dimensionCompound.get("name").getValue(); dimensionDataMap.put(name, new DimensionDataImpl(element)); dimensionsMap.put(element.clone(), name); + + addMonsterSpawnData(element); } tracker(wrapper.user()).setDimensions(dimensionDataMap); @@ -304,14 +305,18 @@ public final class EntityPackets extends EntityRewriter { }); } - private static void writeDimensionKey(PacketWrapper wrapper, DimensionRegistryStorage registryStorage) throws Exception { + private static void writeDimensionKey(final PacketWrapper wrapper, final DimensionRegistryStorage registryStorage) throws Exception { // Find dimension key by data final CompoundTag currentDimension = wrapper.read(Type.NBT); - addMonsterSpawnData(currentDimension); - final String dimensionKey = registryStorage.dimensionKey(currentDimension); if (dimensionKey == null) { - throw new IllegalArgumentException("Unknown dimension sent on join: " + currentDimension); + Via.getPlatform().getLogger().severe("The server tried to send dimension data from a dimension the client wasn't told about on join. " + + "Plugins and mods have to make sure they are not creating new dimension types while players are online, and proxies need to make sure they don't scramble dimension data." + + " Known dimensions:"); + for (final Map.Entry entry : registryStorage.dimensions().entrySet()) { + Via.getPlatform().getLogger().severe(entry.getValue() + ": " + entry.getKey()); + } + throw new IllegalArgumentException("Dimension not found in registry data from join packet: " + currentDimension); } wrapper.write(Type.STRING, dimensionKey); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/storage/DimensionRegistryStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/storage/DimensionRegistryStorage.java index 1cc41b3eb..3f1dce0de 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/storage/DimensionRegistryStorage.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/storage/DimensionRegistryStorage.java @@ -35,6 +35,10 @@ public final class DimensionRegistryStorage implements StorableObject { this.dimensions = dimensions; } + public Map dimensions() { + return dimensions; + } + @Override public boolean clearOnServerSwitch() { return false; diff --git a/gradle.properties b/gradle.properties index 95511bbc2..cf07c9e20 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project properties - we put these here so they can be modified without causing a recompile of the build scripts -projectVersion=4.3.0-1.19-pre3-SNAPSHOT +projectVersion=4.3.0-1.19-pre5-SNAPSHOT # Gradle properties org.gradle.daemon=true