Skip to content

Commit

Permalink
Hotfix to make it more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jul 12, 2023
1 parent c2c35fb commit 5e7e55c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ public static void register() {
PolymerClientNetworking.AFTER_DISABLE.register(InternalClientRegistry::disable);

PolymerClientNetworking.BEFORE_METADATA_SYNC.register(() -> {
var lang = MinecraftClient.getInstance().getLanguageManager().getLanguage();
if (lang == null) {
lang = "en_us";
}

PolymerClientNetworking.setClientMetadata(ClientMetadataKeys.BLOCKSTATE_BITS, NbtInt.of(MathHelper.ceilLog2(Block.STATE_IDS.size())));
PolymerClientNetworking.setClientMetadata(ClientMetadataKeys.MINECRAFT_PROTOCOL, NbtInt.of(SharedConstants.getProtocolVersion()));
PolymerClientNetworking.setClientMetadata(ClientMetadataKeys.LANGUAGE, NbtString.of(MinecraftClient.getInstance().getLanguageManager().getLanguage()));
PolymerClientNetworking.setClientMetadata(ClientMetadataKeys.LANGUAGE, NbtString.of(lang));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void register() {

PolymerServerNetworking.AFTER_HANDSHAKE_APPLY.register((handler, x) -> {
var lang = PolymerServerNetworking.getMetadata(handler, ClientMetadataKeys.LANGUAGE, NbtString.TYPE);
PolymerServerProtocol.sendSyncPackets(handler, lang != null && lang.asString().equals("en_us"));
PolymerServerProtocol.sendSyncPackets(handler, (lang != null && lang.asString().equals("en_us")) || CommonImplUtils.isMainPlayer(handler.player));
});

ServerMetadataKeys.setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public abstract class ServerPlayNetworkHandlerMixin {

@Inject(method = "onClientSettings", at = @At("TAIL"))
private void polymerCore$resendLanguage(ClientSettingsC2SPacket packet, CallbackInfo ci) {
if (!this.polymerCore$language.equals(packet.language()) && !CommonImplUtils.isMainPlayer(this.player)) {
if (CommonImplUtils.isMainPlayer(this.player)) {
return;
}

if (!this.polymerCore$language.equals(packet.language())) {
Runnable runnable = () -> {
PolymerServerProtocol.sendSyncPackets(player.networkHandler, true);
this.sendPacket(new SynchronizeTagsS2CPacket(TagPacketSerializer.serializeTags(this.player.getServerWorld().getServer().getCombinedDynamicRegistries())));
Expand Down

0 comments on commit 5e7e55c

Please sign in to comment.