use of com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3 in project ViaBackwards by ViaVersion.
the class PlayerPackets1_11 method register.
public void register(Protocol1_10To1_11 protocol) {
protocol.registerClientbound(ClientboundPackets1_9_3.TITLE, new PacketRemapper() {
@Override
public void registerMap() {
// 0 - Action
map(Type.VAR_INT);
handler(wrapper -> {
int action = wrapper.get(Type.VAR_INT, 0);
if (action == 2) {
// Handle the new ActionBar
JsonElement message = wrapper.read(Type.COMPONENT);
wrapper.clearPacket();
wrapper.setId(ClientboundPackets1_9_3.CHAT_MESSAGE.ordinal());
// https://bugs.mojang.com/browse/MC-119145to
String legacy = LegacyComponentSerializer.legacySection().serialize(GsonComponentSerializer.gson().deserialize(message.toString()));
message = new JsonObject();
message.getAsJsonObject().addProperty("text", legacy);
wrapper.write(Type.COMPONENT, message);
wrapper.write(Type.BYTE, (byte) 2);
} else if (action > 2) {
// Move everything one position down
wrapper.set(Type.VAR_INT, 0, action - 1);
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
@Override
public void registerMap() {
// 0 - Collected entity id
map(Type.VAR_INT);
// 1 - Collector entity id
map(Type.VAR_INT);
// Ignore item pickup count
handler(wrapper -> wrapper.read(Type.VAR_INT));
}
});
protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
@Override
public void registerMap() {
// 0 - Location
map(Type.POSITION);
// 1 - Face
map(Type.VAR_INT);
// 2 - Hand
map(Type.VAR_INT);
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
map(Type.UNSIGNED_BYTE, TO_NEW_FLOAT);
}
});
}
Aggregations