Skip to content

Commit e70f595

Browse files
committed
Handle translatable changes
1 parent 888441b commit e70f595

File tree

7 files changed

+97
-4
lines changed

7 files changed

+97
-4
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55

66
allprojects {
77
group = "com.viaversion"
8-
version = "4.1.0-1.18-pre2-SNAPSHOT"
8+
version = "4.1.0-1.18-pre5-SNAPSHOT"
99
description = "Allow older clients to join newer server versions."
1010
}
1111

common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ public void registerMap() {
123123
});
124124
}
125125

126+
public void registerCombatKill(ClientboundPacketType packetType) {
127+
protocol.registerClientbound(packetType, new PacketRemapper() {
128+
@Override
129+
public void registerMap() {
130+
map(Type.VAR_INT);
131+
map(Type.INT);
132+
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
133+
}
134+
});
135+
}
136+
126137
@Override
127138
protected void handleTranslate(JsonObject root, String translate) {
128139
String newTranslate = newTranslatables.get(translate);

common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public void registerMap() {
225225
}
226226
});
227227

228+
//TODO translatables
228229
mergePacket(ClientboundPackets1_17.TITLE_TEXT, ClientboundPackets1_16_2.TITLE, 0);
229230
mergePacket(ClientboundPackets1_17.TITLE_SUBTITLE, ClientboundPackets1_16_2.TITLE, 1);
230231
mergePacket(ClientboundPackets1_17.ACTIONBAR, ClientboundPackets1_16_2.TITLE, 2);

common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public void registerMap() {
146146
}
147147
});
148148

149+
// TODO translatables
149150
protocol.mergePacket(ClientboundPackets1_17.COMBAT_ENTER, ClientboundPackets1_16_2.COMBAT_EVENT, 0);
150151
protocol.mergePacket(ClientboundPackets1_17.COMBAT_END, ClientboundPackets1_16_2.COMBAT_EVENT, 1);
151152
protocol.mergePacket(ClientboundPackets1_17.COMBAT_KILL, ClientboundPackets1_16_2.COMBAT_EVENT, 2);

common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.viaversion.viabackwards.api.BackwardsProtocol;
2121
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
22+
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
2223
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.data.BackwardsMappings;
2324
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.packets.BlockItemPackets1_18;
2425
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
3839

3940
private static final BackwardsMappings MAPPINGS = new BackwardsMappings();
4041
private final EntityPackets1_18 entityRewriter = new EntityPackets1_18(this);
41-
private final BlockItemPackets1_18 itemRewriter = new BlockItemPackets1_18(this, null); //TODO translatablerewriter
42+
private TranslatableRewriter translatableRewriter;
43+
private BlockItemPackets1_18 itemRewriter;
4244

4345
public Protocol1_17_1To1_18() {
4446
super(ClientboundPackets1_18.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
@@ -48,6 +50,19 @@ public Protocol1_17_1To1_18() {
4850
protected void registerPackets() {
4951
executeAsyncAfterLoaded(Protocol1_18To1_17_1.class, MAPPINGS::load);
5052

53+
translatableRewriter = new TranslatableRewriter(this);
54+
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.CHAT_MESSAGE);
55+
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.ACTIONBAR);
56+
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_TEXT);
57+
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.TITLE_SUBTITLE);
58+
translatableRewriter.registerBossBar(ClientboundPackets1_18.BOSSBAR);
59+
translatableRewriter.registerDisconnect(ClientboundPackets1_18.DISCONNECT);
60+
translatableRewriter.registerTabList(ClientboundPackets1_18.TAB_LIST);
61+
translatableRewriter.registerOpenWindow(ClientboundPackets1_18.OPEN_WINDOW);
62+
translatableRewriter.registerCombatKill(ClientboundPackets1_18.COMBAT_KILL);
63+
translatableRewriter.registerPing();
64+
65+
itemRewriter = new BlockItemPackets1_18(this, translatableRewriter);
5166
entityRewriter.register();
5267
itemRewriter.register();
5368

@@ -95,4 +110,9 @@ public EntityPackets1_18 getEntityRewriter() {
95110
public BlockItemPackets1_18 getItemRewriter() {
96111
return itemRewriter;
97112
}
113+
114+
@Override
115+
public TranslatableRewriter getTranslatableRewriter() {
116+
return translatableRewriter;
117+
}
98118
}

common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ protected void registerRewrites() {
121121
});
122122

123123
// Particles have already been handled
124-
//registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, null);
125-
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, null);
124+
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, null, null, Types1_17.META_TYPES.optionalComponentType);
126125
}
127126

128127
@Override

common/src/main/resources/assets/viabackwards/data/translation-mappings.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,65 @@
11
{
2+
"1.18": {
3+
"selectWorld.conversion.tooltip": "This world must be opened in an older version (like 1.6.4) to be safely converted",
4+
"selectWorld.incompatible_series": "Created by an incompatible version",
5+
"options.gamma.default": "Default",
6+
"options.simulationDistance": "Simulation Distance",
7+
"options.prioritizeChunkUpdates": "Chunk Builder",
8+
"options.prioritizeChunkUpdates.none": "Threaded",
9+
"options.prioritizeChunkUpdates.byPlayer": "Semi Blocking",
10+
"options.prioritizeChunkUpdates.nearby": "Fully Blocking",
11+
"options.prioritizeChunkUpdates.none.tooltip": "Nearby chunks are compiled in parallel threads. This may result in brief visual holes when blocks are destroyed.",
12+
"options.prioritizeChunkUpdates.byPlayer.tooltip": "Some actions within a chunk will recompile the chunk immediately. This includes block placing & destroying.",
13+
"options.prioritizeChunkUpdates.nearby.tooltip": "Nearby chunks are always compiled immediately. This may impact game performance when blocks are placed or destroyed.",
14+
"options.difficulty.online": "Server Difficulty",
15+
"options.audioDevice": "Device",
16+
"options.audioDevice.default": "System Default",
17+
"options.online": "Online...",
18+
"options.online.title": "Online Options",
19+
"options.allowServerListing": "Allow Server Listings",
20+
"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.",
21+
"options.autosaveIndicator": "Autosave Indicator",
22+
"options.hideLightningFlashes": "Hide Lightning Flashes",
23+
"options.hideLightningFlashes.tooltip": "Prevents lightning bolts from making the sky flash. The bolts themselves will still be visible.",
24+
"controls.keybinds": "Key Binds...",
25+
"controls.keybinds.title": "Key Binds",
26+
"item.minecraft.music_disc_otherside": "Music Disc",
27+
"item.minecraft.music_disc_otherside.desc": "Lena Raine - otherside",
28+
"subtitles.block.growing_plant.crop": "Plant cropped",
29+
"subtitles.item.bundle.drop_contents": "Bundle empties",
30+
"subtitles.item.bundle.insert": "Item packed",
31+
"subtitles.item.bundle.remove_one": "Item unpacked",
32+
"advancements.adventure.fall_from_world_height.title": "Caves & Cliffs",
33+
"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",
34+
"advancements.adventure.play_jukebox_in_meadows.title": "Sound of Music",
35+
"advancements.adventure.play_jukebox_in_meadows.description": "Make the Meadows come alive with the sound of music from a jukebox",
36+
"advancements.adventure.trade_at_world_height.title": "Star Trader",
37+
"advancements.adventure.trade_at_world_height.description": "Trade with a villager at the build height limit",
38+
"advancements.nether.ride_strider_in_overworld_lava.title": "Feels like home",
39+
"advancements.nether.ride_strider_in_overworld_lava.description": "Take a Strider for a loooong ride on a lava lake in the Overworld",
40+
"commands.jfr.started": "JFR profiling started",
41+
"commands.jfr.start.failed": "Failed to start JFR profiling",
42+
"commands.jfr.stopped": "JFR profiling stopped and dumped to %s",
43+
"commands.jfr.dump.failed": "Failed to dump JFR recording: %s",
44+
"commands.worldborder.set.failed.far": "World border cannot be further out than %s blocks",
45+
"biome.minecraft.old_growth_birch_forest": "Old Growth Birch Forest",
46+
"biome.minecraft.old_growth_pine_taiga": "Old Growth Pine Taiga",
47+
"biome.minecraft.old_growth_spruce_taiga": "Old Growth Spruce Taiga",
48+
"biome.minecraft.frozen_peaks": "Frozen Peaks",
49+
"biome.minecraft.grove": "Grove",
50+
"biome.minecraft.jagged_peaks": "Jagged Peaks",
51+
"biome.minecraft.meadow": "Meadow",
52+
"biome.minecraft.snowy_plains": "Snowy Plains",
53+
"biome.minecraft.snowy_slopes": "Snowy Slopes",
54+
"biome.minecraft.sparse_jungle": "Sparse Jungle",
55+
"biome.minecraft.stony_peaks": "Stony Peaks",
56+
"biome.minecraft.stony_shore": "Stony Shore",
57+
"biome.minecraft.windswept_forest": "Windswept Forest",
58+
"biome.minecraft.windswept_gravelly_hills": "Windswept Gravelly Hills",
59+
"biome.minecraft.windswept_hills": "Windswept Hills",
60+
"biome.minecraft.windswept_savanna": "Windswept Savanna",
61+
"biome.minecraft.wooded_badlands": "Wooded Badlands"
62+
},
263
"1.17": {
364
"gui.socialInteractions.title": "Social Interactions",
465
"gui.socialInteractions.tab_all": "All",

0 commit comments

Comments
 (0)