Handle new container id

This commit is contained in:
Nassim Jahnke 2023-03-01 16:09:56 +01:00
parent 708d6bed52
commit 565944c317
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
3 changed files with 21 additions and 2 deletions

View File

@ -5,7 +5,7 @@ plugins {
allprojects { allprojects {
group = "com.viaversion" group = "com.viaversion"
version = "4.6.0-1.19.4-pre1-SNAPSHOT" version = "4.6.0-1.19.4-pre3-SNAPSHOT"
description = "Allow older clients to join newer server versions." description = "Allow older clients to join newer server versions."
} }

View File

@ -66,7 +66,6 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
translatableRewriter.registerBossBar(ClientboundPackets1_19_4.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_19_4.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_19_4.DISCONNECT); translatableRewriter.registerDisconnect(ClientboundPackets1_19_4.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_19_4.TAB_LIST); translatableRewriter.registerTabList(ClientboundPackets1_19_4.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_19_4.OPEN_WINDOW);
translatableRewriter.registerCombatKill(ClientboundPackets1_19_4.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_19_4.COMBAT_KILL);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SYSTEM_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SYSTEM_CHAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.DISGUISED_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.DISGUISED_CHAT);

View File

@ -20,6 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter; import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4; import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
@ -43,6 +44,25 @@ public final class BlockItemPackets1_19_4 extends ItemRewriter<ClientboundPacket
blockRewriter.registerChunkData1_19(ClientboundPackets1_19_4.CHUNK_DATA, Chunk1_18Type::new); blockRewriter.registerChunkData1_19(ClientboundPackets1_19_4.CHUNK_DATA, Chunk1_18Type::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA); blockRewriter.registerBlockEntityData(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA);
protocol.registerClientbound(ClientboundPackets1_19_4.OPEN_WINDOW, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT); // Container id
map(Type.VAR_INT); // Container type
map(Type.COMPONENT); // Title
handler(wrapper -> {
final int windowType = wrapper.get(Type.VAR_INT, 1);
if (windowType == 21) { // New smithing menu
wrapper.cancel();
} else if (windowType > 21) {
wrapper.set(Type.VAR_INT, 1, windowType - 1);
}
protocol.getTranslatableRewriter().processText(wrapper.get(Type.COMPONENT, 0));
});
}
});
registerSetCooldown(ClientboundPackets1_19_4.COOLDOWN); registerSetCooldown(ClientboundPackets1_19_4.COOLDOWN);
registerWindowItems1_17_1(ClientboundPackets1_19_4.WINDOW_ITEMS); registerWindowItems1_17_1(ClientboundPackets1_19_4.WINDOW_ITEMS);
registerSetSlot1_17_1(ClientboundPackets1_19_4.SET_SLOT); registerSetSlot1_17_1(ClientboundPackets1_19_4.SET_SLOT);