3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Update ComponentRewriter

Dieser Commit ist enthalten in:
KennyTV 2021-04-10 17:03:43 +02:00
Ursprung 9f380a7598
Commit 4473f863c6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -28,23 +28,6 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
// Packets using components:
// ping (status)
// disconnect (play and login)
// chat
// bossbar
// open window
// combat event
// title
// tablist
// teams
// scoreboard
// player info
// map data
// declare commands
// advancements
// update sign
/** /**
* Handles json chat components, containing methods to override certain parts of the handling. * Handles json chat components, containing methods to override certain parts of the handling.
* Also contains methods to register a few of the packets using components. * Also contains methods to register a few of the packets using components.
@ -63,7 +46,13 @@ public class ComponentRewriter {
this.protocol = null; this.protocol = null;
} }
public void registerChatMessage(ClientboundPacketType packetType) { /**
* Processes components at the beginning of the packet.
* Used for packets that have components as their very first value, so no special pre-reading is necessary.
*
* @param packetType clientbound packet type
*/
public void registerComponentPacket(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -72,6 +61,10 @@ public class ComponentRewriter {
}); });
} }
public void registerChatMessage(ClientboundPacketType packetType) {
registerComponentPacket(packetType);
}
public void registerBossBar(ClientboundPacketType packetType) { public void registerBossBar(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
@ -88,6 +81,9 @@ public class ComponentRewriter {
}); });
} }
/**
* Handles sub 1.17 combat event components.
*/
public void registerCombatEvent(ClientboundPacketType packetType) { public void registerCombatEvent(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
@ -103,6 +99,9 @@ public class ComponentRewriter {
}); });
} }
/**
* Handles sub 1.17 title components.
*/
public void registerTitle(ClientboundPacketType packetType) { public void registerTitle(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override