From 54ac7a2b6f7e81728aee7fd6a1aea8e187dfb25e Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Tue, 21 Nov 2023 21:16:06 +0100 Subject: [PATCH] Fixed resource pack handling inconsistencies --- .../net/raphimc/viabedrock/protocol/BedrockProtocol.java | 1 + .../raphimc/viabedrock/protocol/packets/JoinPackets.java | 8 +++++--- .../raphimc/viabedrock/protocol/storage/ChunkTracker.java | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java b/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java index 5b7fe58a..96954954 100644 --- a/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java +++ b/src/main/java/net/raphimc/viabedrock/protocol/BedrockProtocol.java @@ -119,6 +119,7 @@ public void register(ViaProviders providers) { public void init(UserConnection user) { user.put(new ClientSettingsStorage("en_us", 12, 0, true, (short) 127, 1, false, true)); user.put(new SpawnPositionStorage()); + user.put(new ResourcePacksStorage()); user.put(new BlobCache(user)); user.put(new PlayerListStorage()); user.put(new PacketSyncStorage(user)); diff --git a/src/main/java/net/raphimc/viabedrock/protocol/packets/JoinPackets.java b/src/main/java/net/raphimc/viabedrock/protocol/packets/JoinPackets.java index 049bd12b..60733acf 100644 --- a/src/main/java/net/raphimc/viabedrock/protocol/packets/JoinPackets.java +++ b/src/main/java/net/raphimc/viabedrock/protocol/packets/JoinPackets.java @@ -50,6 +50,7 @@ import net.raphimc.viabedrock.protocol.types.JavaTypes; import java.util.Map; +import java.util.UUID; import java.util.logging.Level; import java.util.stream.Collectors; @@ -66,9 +67,10 @@ public static void register(final BedrockProtocol protocol) { return; // Mojang client silently ignores multiple start game packets } - if (resourcePacksStorage == null || !resourcePacksStorage.hasCompletedTransfer()) { - BedrockProtocol.kickForIllegalState(wrapper.user(), "Pack negotiation not completed"); - return; + if (!resourcePacksStorage.hasFinishedLoading()) { + ViaBedrock.getPlatform().getLogger().log(Level.WARNING, "Pack negotiation not completed before joining game. Skipping resource pack loading"); + resourcePacksStorage.setCompletedTransfer(); + resourcePacksStorage.setPackStack(new UUID[0], new UUID[0]); } final long uniqueEntityId = wrapper.read(BedrockTypes.VAR_LONG); // unique entity id diff --git a/src/main/java/net/raphimc/viabedrock/protocol/storage/ChunkTracker.java b/src/main/java/net/raphimc/viabedrock/protocol/storage/ChunkTracker.java index 9cd3cdd0..8d807f55 100644 --- a/src/main/java/net/raphimc/viabedrock/protocol/storage/ChunkTracker.java +++ b/src/main/java/net/raphimc/viabedrock/protocol/storage/ChunkTracker.java @@ -631,6 +631,8 @@ private Chunk remapChunk(final Chunk chunk) throws Exception { } else { remappedBlockPalette.setIdAt(x, y, z, remappedBlockState); } + } else { + ViaBedrock.getPlatform().getLogger().log(Level.WARNING, "Invalid layer 2 block state. L1: " + prevBlockState + ", L2: " + blockState); } } }