Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Only send tags early for 1.20.5+ clients, track early send properly in 1.20->1.20.2
Dieser Commit ist enthalten in:
Ursprung
c525575d37
Commit
5772ee4a93
@ -166,8 +166,8 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
wrapper.write(Types.VAR_INT_ARRAY_PRIMITIVE, tag.getValue().clone());
|
||||
}
|
||||
});
|
||||
if (w.user().getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_2)) {
|
||||
// Make sure it's included in the configuration packets
|
||||
if (w.user().getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||
// Make sure it's included in the configuration packets as it may already be required for registry data
|
||||
tagsPacket.send(Protocol1_12_2To1_13.class);
|
||||
} else {
|
||||
tagsPacket.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
|
@ -77,6 +77,7 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol<ClientboundPa
|
||||
cancelServerbound(ServerboundPackets1_20_3.CONTAINER_SLOT_STATE_CHANGED);
|
||||
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_20_2.UPDATE_TAGS);
|
||||
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_2.UPDATE_TAGS);
|
||||
|
||||
final SoundRewriter<ClientboundPacket1_20_2> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_2.SOUND);
|
||||
@ -307,7 +308,6 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
registerServerbound(ServerboundConfigurationPackets1_20_2.RESOURCE_PACK, resourcePackStatusHandler());
|
||||
registerClientbound(ClientboundConfigurationPackets1_20_2.RESOURCE_PACK, ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_PUSH, resourcePackHandler(ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_POP));
|
||||
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_2.UPDATE_TAGS);
|
||||
}
|
||||
|
||||
private PacketHandler resourcePackStatusHandler() {
|
||||
|
@ -124,11 +124,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
|
||||
wrapper.resetReader();
|
||||
wrapper.user().put(new LastTags(wrapper));
|
||||
});
|
||||
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.UPDATE_TAGS, wrapper -> {
|
||||
tagRewriter.handleGeneric(wrapper);
|
||||
wrapper.resetReader();
|
||||
wrapper.user().put(new LastTags(wrapper));
|
||||
});
|
||||
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.UPDATE_TAGS, this::handleConfigTags);
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_4.SET_DISPLAY_OBJECTIVE, wrapper -> {
|
||||
final byte slot = wrapper.read(Types.BYTE);
|
||||
@ -229,6 +225,15 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
|
||||
});
|
||||
}
|
||||
|
||||
private void handleConfigTags(final PacketWrapper wrapper) {
|
||||
tagRewriter.handleGeneric(wrapper);
|
||||
wrapper.resetReader();
|
||||
|
||||
final LastTags lastTags = new LastTags(wrapper);
|
||||
lastTags.setSentDuringConfigPhase(true);
|
||||
wrapper.user().put(lastTags);
|
||||
}
|
||||
|
||||
private static void sanitizeCustomPayload(final PacketWrapper wrapper) {
|
||||
final String channel = Key.namespaced(wrapper.get(Types.STRING, 0));
|
||||
if (channel.equals("minecraft:brand")) {
|
||||
@ -299,6 +304,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
|
||||
} else if (unmappedId == ClientboundPackets1_19_4.UPDATE_ENABLED_FEATURES.getId()) {
|
||||
packetWrapper.setPacketType(ClientboundConfigurationPackets1_20_2.UPDATE_ENABLED_FEATURES);
|
||||
} else if (unmappedId == ClientboundPackets1_19_4.UPDATE_TAGS.getId()) {
|
||||
handleConfigTags(packetWrapper); // Manually put through handler
|
||||
packetWrapper.setPacketType(ClientboundConfigurationPackets1_20_2.UPDATE_TAGS);
|
||||
} else {
|
||||
// Not a packet that can be mapped to the configuration protocol
|
||||
@ -327,8 +333,12 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
final LastTags lastTags = connection.get(LastTags.class);
|
||||
if (lastTags != null) {
|
||||
// The server might still follow up with a tags packet, but we wouldn't know
|
||||
lastTags.sendLastTags(connection);
|
||||
if (lastTags.sentDuringConfigPhase()) {
|
||||
lastTags.setSentDuringConfigPhase(false);
|
||||
} else {
|
||||
// The server might still follow up with a tags packet, but we wouldn't know
|
||||
lastTags.sendLastTags(connection);
|
||||
}
|
||||
}
|
||||
|
||||
if (lastResourcePack != null && connection.getProtocolInfo().protocolVersion() == ProtocolVersion.v1_20_2) {
|
||||
|
@ -31,6 +31,7 @@ import java.util.List;
|
||||
public class LastTags implements StorableObject {
|
||||
|
||||
private final List<RegistryTags> registryTags = new ArrayList<>();
|
||||
private boolean sentDuringConfigPhase;
|
||||
|
||||
public LastTags(final PacketWrapper wrapper) {
|
||||
final int length = wrapper.passthrough(Types.VAR_INT);
|
||||
@ -65,6 +66,14 @@ public class LastTags implements StorableObject {
|
||||
packet.send(Protocol1_20To1_20_2.class);
|
||||
}
|
||||
|
||||
public void setSentDuringConfigPhase(final boolean sentDuringConfigPhase) {
|
||||
this.sentDuringConfigPhase = sentDuringConfigPhase;
|
||||
}
|
||||
|
||||
public boolean sentDuringConfigPhase() {
|
||||
return sentDuringConfigPhase;
|
||||
}
|
||||
|
||||
private record RegistryTags(String registryKey, List<TagData> tags) {
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren