use of com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2 in project ViaBackwards by ViaVersion.
the class Protocol1_16_1To1_16_2 method registerPackets.
@Override
protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_16_2To1_16_1.class, MAPPINGS::load);
translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR);
translatableRewriter.registerCombatEvent(ClientboundPackets1_16_2.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_16_2.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_16_2.TITLE);
translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW);
translatableRewriter.registerPing();
new CommandRewriter1_16_2(this).registerDeclareCommands(ClientboundPackets1_16_2.DECLARE_COMMANDS);
(blockItemPackets = new BlockItemPackets1_16_2(this)).register();
entityRewriter.register();
SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND);
soundRewriter.registerNamedSound(ClientboundPackets1_16_2.NAMED_SOUND);
soundRewriter.registerStopSound(ClientboundPackets1_16_2.STOP_SOUND);
registerClientbound(ClientboundPackets1_16_2.CHAT_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
JsonElement message = wrapper.passthrough(Type.COMPONENT);
translatableRewriter.processText(message);
byte position = wrapper.passthrough(Type.BYTE);
if (position == 2) {
// https://bugs.mojang.com/browse/MC-119145
wrapper.clearPacket();
wrapper.setId(ClientboundPackets1_16.TITLE.ordinal());
wrapper.write(Type.VAR_INT, 2);
wrapper.write(Type.COMPONENT, message);
}
});
}
});
// Recipe book data has been split into 2 separate packets
registerServerbound(ServerboundPackets1_16.RECIPE_BOOK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int type = wrapper.read(Type.VAR_INT);
if (type == 0) {
// Shown, change to its own packet
// Recipe
wrapper.passthrough(Type.STRING);
wrapper.setId(ServerboundPackets1_16_2.SEEN_RECIPE.ordinal());
} else {
wrapper.cancel();
// Settings
for (int i = 0; i < 3; i++) {
sendSeenRecipePacket(i, wrapper);
}
}
}
private void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) throws Exception {
boolean open = wrapper.read(Type.BOOLEAN);
boolean filter = wrapper.read(Type.BOOLEAN);
PacketWrapper newPacket = wrapper.create(ServerboundPackets1_16_2.RECIPE_BOOK_DATA);
newPacket.write(Type.VAR_INT, recipeType);
newPacket.write(Type.BOOLEAN, open);
newPacket.write(Type.BOOLEAN, filter);
newPacket.sendToServer(Protocol1_16_1To1_16_2.class);
}
});
}
});
new TagRewriter(this).register(ClientboundPackets1_16_2.TAGS, RegistryType.ENTITY);
new StatisticsRewriter(this).register(ClientboundPackets1_16_2.STATISTICS);
}
use of com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2 in project ViaBackwards by ViaVersion.
the class ViaBackwardsPlatform method init.
/**
* Initialize ViaBackwards.
*/
default void init(File dataFolder) {
ViaBackwardsConfig config = new ViaBackwardsConfig(new File(dataFolder, "config.yml"));
config.reloadConfig();
ViaBackwards.init(this, config);
if (isOutdated())
return;
Via.getManager().getSubPlatforms().add(IMPL_VERSION);
getLogger().info("Loading translations...");
TranslatableRewriter.loadTranslatables();
ProtocolManager protocolManager = Via.getManager().getProtocolManager();
protocolManager.registerProtocol(new Protocol1_9_4To1_10(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
protocolManager.registerProtocol(new Protocol1_10To1_11(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
protocolManager.registerProtocol(new Protocol1_11To1_11_1(), ProtocolVersion.v1_11, ProtocolVersion.v1_11_1);
protocolManager.registerProtocol(new Protocol1_11_1To1_12(), ProtocolVersion.v1_11_1, ProtocolVersion.v1_12);
protocolManager.registerProtocol(new Protocol1_12To1_12_1(), ProtocolVersion.v1_12, ProtocolVersion.v1_12_1);
protocolManager.registerProtocol(new Protocol1_12_1To1_12_2(), ProtocolVersion.v1_12_1, ProtocolVersion.v1_12_2);
protocolManager.registerProtocol(new Protocol1_12_2To1_13(), ProtocolVersion.v1_12_2, ProtocolVersion.v1_13);
protocolManager.registerProtocol(new Protocol1_13To1_13_1(), ProtocolVersion.v1_13, ProtocolVersion.v1_13_1);
protocolManager.registerProtocol(new Protocol1_13_1To1_13_2(), ProtocolVersion.v1_13_1, ProtocolVersion.v1_13_2);
protocolManager.registerProtocol(new Protocol1_13_2To1_14(), ProtocolVersion.v1_13_2, ProtocolVersion.v1_14);
protocolManager.registerProtocol(new Protocol1_14To1_14_1(), ProtocolVersion.v1_14, ProtocolVersion.v1_14_1);
protocolManager.registerProtocol(new Protocol1_14_1To1_14_2(), ProtocolVersion.v1_14_1, ProtocolVersion.v1_14_2);
protocolManager.registerProtocol(new Protocol1_14_2To1_14_3(), ProtocolVersion.v1_14_2, ProtocolVersion.v1_14_3);
protocolManager.registerProtocol(new Protocol1_14_3To1_14_4(), ProtocolVersion.v1_14_3, ProtocolVersion.v1_14_4);
protocolManager.registerProtocol(new Protocol1_14_4To1_15(), ProtocolVersion.v1_14_4, ProtocolVersion.v1_15);
protocolManager.registerProtocol(new Protocol1_15To1_15_1(), ProtocolVersion.v1_15, ProtocolVersion.v1_15_1);
protocolManager.registerProtocol(new Protocol1_15_1To1_15_2(), ProtocolVersion.v1_15_1, ProtocolVersion.v1_15_2);
protocolManager.registerProtocol(new Protocol1_15_2To1_16(), ProtocolVersion.v1_15_2, ProtocolVersion.v1_16);
protocolManager.registerProtocol(new Protocol1_16To1_16_1(), ProtocolVersion.v1_16, ProtocolVersion.v1_16_1);
protocolManager.registerProtocol(new Protocol1_16_1To1_16_2(), ProtocolVersion.v1_16_1, ProtocolVersion.v1_16_2);
protocolManager.registerProtocol(new Protocol1_16_2To1_16_3(), ProtocolVersion.v1_16_2, ProtocolVersion.v1_16_3);
protocolManager.registerProtocol(new Protocol1_16_3To1_16_4(), ProtocolVersion.v1_16_3, ProtocolVersion.v1_16_4);
protocolManager.registerProtocol(new Protocol1_16_4To1_17(), ProtocolVersion.v1_16_4, ProtocolVersion.v1_17);
protocolManager.registerProtocol(new Protocol1_17To1_17_1(), ProtocolVersion.v1_17, ProtocolVersion.v1_17_1);
protocolManager.registerProtocol(new Protocol1_17_1To1_18(), ProtocolVersion.v1_17_1, ProtocolVersion.v1_18);
protocolManager.registerProtocol(new Protocol1_18To1_18_2(), ProtocolVersion.v1_18, ProtocolVersion.v1_18_2);
}
Aggregations