Update ComponentRewriter

This commit is contained in:
KennyTV 2021-04-10 17:03:43 +02:00
parent 9f380a7598
commit 4473f863c6
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -28,23 +28,6 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
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.
* Also contains methods to register a few of the packets using components.
@ -63,7 +46,13 @@ public class ComponentRewriter {
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() {
@Override
public void registerMap() {
@ -72,6 +61,10 @@ public class ComponentRewriter {
});
}
public void registerChatMessage(ClientboundPacketType packetType) {
registerComponentPacket(packetType);
}
public void registerBossBar(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
@ -88,6 +81,9 @@ public class ComponentRewriter {
});
}
/**
* Handles sub 1.17 combat event components.
*/
public void registerCombatEvent(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
@ -103,6 +99,9 @@ public class ComponentRewriter {
});
}
/**
* Handles sub 1.17 title components.
*/
public void registerTitle(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override