Handle translatable changes

This commit is contained in:
Nassim Jahnke 2021-11-19 22:09:36 +01:00
parent 888441b81d
commit e70f595f76
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
7 changed files with 97 additions and 4 deletions

View File

@ -5,7 +5,7 @@ plugins {
allprojects {
group = "com.viaversion"
version = "4.1.0-1.18-pre2-SNAPSHOT"
version = "4.1.0-1.18-pre5-SNAPSHOT"
description = "Allow older clients to join newer server versions."
}

View File

@ -123,6 +123,17 @@ public class TranslatableRewriter extends ComponentRewriter {
});
}
public void registerCombatKill(ClientboundPacketType packetType) {
protocol.registerClientbound(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
map(Type.INT);
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
}
});
}
@Override
protected void handleTranslate(JsonObject root, String translate) {
String newTranslate = newTranslatables.get(translate);

View File

@ -225,6 +225,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
}
});
//TODO translatables
mergePacket(ClientboundPackets1_17.TITLE_TEXT, ClientboundPackets1_16_2.TITLE, 0);
mergePacket(ClientboundPackets1_17.TITLE_SUBTITLE, ClientboundPackets1_16_2.TITLE, 1);
mergePacket(ClientboundPackets1_17.ACTIONBAR, ClientboundPackets1_16_2.TITLE, 2);

View File

@ -146,6 +146,7 @@ public final class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17
}
});
// TODO translatables
protocol.mergePacket(ClientboundPackets1_17.COMBAT_ENTER, ClientboundPackets1_16_2.COMBAT_EVENT, 0);
protocol.mergePacket(ClientboundPackets1_17.COMBAT_END, ClientboundPackets1_16_2.COMBAT_EVENT, 1);
protocol.mergePacket(ClientboundPackets1_17.COMBAT_KILL, ClientboundPackets1_16_2.COMBAT_EVENT, 2);

View File

@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_17_1to1_18;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.data.BackwardsMappings;
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.packets.BlockItemPackets1_18;
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.packets.EntityPackets1_18;
@ -38,7 +39,8 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
private static final BackwardsMappings MAPPINGS = new BackwardsMappings();
private final EntityPackets1_18 entityRewriter = new EntityPackets1_18(this);
private final BlockItemPackets1_18 itemRewriter = new BlockItemPackets1_18(this, null); //TODO translatablerewriter
private TranslatableRewriter translatableRewriter;
private BlockItemPackets1_18 itemRewriter;
public Protocol1_17_1To1_18() {
super(ClientboundPackets1_18.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
@ -48,6 +50,19 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_18To1_17_1.class, MAPPINGS::load);
translatableRewriter = new TranslatableRewriter(this);
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.CHAT_MESSAGE);
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.ACTIONBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_18.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_18.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_18.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_18.OPEN_WINDOW);
translatableRewriter.registerCombatKill(ClientboundPackets1_18.COMBAT_KILL);
translatableRewriter.registerPing();
itemRewriter = new BlockItemPackets1_18(this, translatableRewriter);
entityRewriter.register();
itemRewriter.register();
@ -95,4 +110,9 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
public BlockItemPackets1_18 getItemRewriter() {
return itemRewriter;
}
@Override
public TranslatableRewriter getTranslatableRewriter() {
return translatableRewriter;
}
}

View File

@ -121,8 +121,7 @@ public final class EntityPackets1_18 extends EntityRewriter<Protocol1_17_1To1_18
});
// Particles have already been handled
//registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, null);
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, null);
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, Types1_17.META_TYPES.optionalComponentType);
}
@Override

View File

@ -1,4 +1,65 @@
{
"1.18": {
"selectWorld.conversion.tooltip": "This world must be opened in an older version (like 1.6.4) to be safely converted",
"selectWorld.incompatible_series": "Created by an incompatible version",
"options.gamma.default": "Default",
"options.simulationDistance": "Simulation Distance",
"options.prioritizeChunkUpdates": "Chunk Builder",
"options.prioritizeChunkUpdates.none": "Threaded",
"options.prioritizeChunkUpdates.byPlayer": "Semi Blocking",
"options.prioritizeChunkUpdates.nearby": "Fully Blocking",
"options.prioritizeChunkUpdates.none.tooltip": "Nearby chunks are compiled in parallel threads. This may result in brief visual holes when blocks are destroyed.",
"options.prioritizeChunkUpdates.byPlayer.tooltip": "Some actions within a chunk will recompile the chunk immediately. This includes block placing & destroying.",
"options.prioritizeChunkUpdates.nearby.tooltip": "Nearby chunks are always compiled immediately. This may impact game performance when blocks are placed or destroyed.",
"options.difficulty.online": "Server Difficulty",
"options.audioDevice": "Device",
"options.audioDevice.default": "System Default",
"options.online": "Online...",
"options.online.title": "Online Options",
"options.allowServerListing": "Allow Server Listings",
"options.allowServerListing.tooltip": "Servers may list online players as part of their public status.\nWith this option off your name will not show up in such lists.",
"options.autosaveIndicator": "Autosave Indicator",
"options.hideLightningFlashes": "Hide Lightning Flashes",
"options.hideLightningFlashes.tooltip": "Prevents lightning bolts from making the sky flash. The bolts themselves will still be visible.",
"controls.keybinds": "Key Binds...",
"controls.keybinds.title": "Key Binds",
"item.minecraft.music_disc_otherside": "Music Disc",
"item.minecraft.music_disc_otherside.desc": "Lena Raine - otherside",
"subtitles.block.growing_plant.crop": "Plant cropped",
"subtitles.item.bundle.drop_contents": "Bundle empties",
"subtitles.item.bundle.insert": "Item packed",
"subtitles.item.bundle.remove_one": "Item unpacked",
"advancements.adventure.fall_from_world_height.title": "Caves & Cliffs",
"advancements.adventure.fall_from_world_height.description": "Free fall from the top of the world (build limit) to the bottom of the world and survive",
"advancements.adventure.play_jukebox_in_meadows.title": "Sound of Music",
"advancements.adventure.play_jukebox_in_meadows.description": "Make the Meadows come alive with the sound of music from a jukebox",
"advancements.adventure.trade_at_world_height.title": "Star Trader",
"advancements.adventure.trade_at_world_height.description": "Trade with a villager at the build height limit",
"advancements.nether.ride_strider_in_overworld_lava.title": "Feels like home",
"advancements.nether.ride_strider_in_overworld_lava.description": "Take a Strider for a loooong ride on a lava lake in the Overworld",
"commands.jfr.started": "JFR profiling started",
"commands.jfr.start.failed": "Failed to start JFR profiling",
"commands.jfr.stopped": "JFR profiling stopped and dumped to %s",
"commands.jfr.dump.failed": "Failed to dump JFR recording: %s",
"commands.worldborder.set.failed.far": "World border cannot be further out than %s blocks",
"biome.minecraft.old_growth_birch_forest": "Old Growth Birch Forest",
"biome.minecraft.old_growth_pine_taiga": "Old Growth Pine Taiga",
"biome.minecraft.old_growth_spruce_taiga": "Old Growth Spruce Taiga",
"biome.minecraft.frozen_peaks": "Frozen Peaks",
"biome.minecraft.grove": "Grove",
"biome.minecraft.jagged_peaks": "Jagged Peaks",
"biome.minecraft.meadow": "Meadow",
"biome.minecraft.snowy_plains": "Snowy Plains",
"biome.minecraft.snowy_slopes": "Snowy Slopes",
"biome.minecraft.sparse_jungle": "Sparse Jungle",
"biome.minecraft.stony_peaks": "Stony Peaks",
"biome.minecraft.stony_shore": "Stony Shore",
"biome.minecraft.windswept_forest": "Windswept Forest",
"biome.minecraft.windswept_gravelly_hills": "Windswept Gravelly Hills",
"biome.minecraft.windswept_hills": "Windswept Hills",
"biome.minecraft.windswept_savanna": "Windswept Savanna",
"biome.minecraft.wooded_badlands": "Wooded Badlands"
},
"1.17": {
"gui.socialInteractions.title": "Social Interactions",
"gui.socialInteractions.tab_all": "All",