Skip to content

Commit 4dd4b2f

Browse files
Fix advancement menu background keys (#984)
Co-authored-by: FlorianMichael <[email protected]>
1 parent 8a9cc8b commit 4dd4b2f

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_5to1_21_4/rewriter/BlockItemPacketRewriter1_21_5.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import com.viaversion.viaversion.api.minecraft.item.data.TooltipDisplay;
6262
import com.viaversion.viaversion.api.minecraft.item.data.Weapon;
6363
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
64+
import com.viaversion.viaversion.api.rewriter.ComponentRewriter;
6465
import com.viaversion.viaversion.api.type.Type;
6566
import com.viaversion.viaversion.api.type.Types;
6667
import com.viaversion.viaversion.api.type.types.chunk.ChunkBiomesType1_19_4;
@@ -78,6 +79,7 @@
7879
import com.viaversion.viaversion.rewriter.BlockRewriter;
7980
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
8081
import com.viaversion.viaversion.util.Either;
82+
import com.viaversion.viaversion.util.Key;
8183
import com.viaversion.viaversion.util.Limit;
8284
import java.util.ArrayList;
8385
import java.util.HashMap;
@@ -195,8 +197,41 @@ public void registerPackets() {
195197
} while (value < 0);
196198
});
197199

198-
registerAdvancements1_20_3(ClientboundPackets1_21_5.UPDATE_ADVANCEMENTS);
199-
protocol.appendClientbound(ClientboundPackets1_21_5.UPDATE_ADVANCEMENTS, wrapper -> {
200+
protocol.registerClientbound(ClientboundPackets1_21_5.UPDATE_ADVANCEMENTS, wrapper -> {
201+
wrapper.passthrough(Types.BOOLEAN); // Reset/clear
202+
int size = wrapper.passthrough(Types.VAR_INT); // Mapping size
203+
for (int i = 0; i < size; i++) {
204+
wrapper.passthrough(Types.STRING); // Identifier
205+
wrapper.passthrough(Types.OPTIONAL_STRING); // Parent
206+
207+
// Display data
208+
if (wrapper.passthrough(Types.BOOLEAN)) {
209+
final Tag title = wrapper.passthrough(Types.TAG);
210+
final Tag description = wrapper.passthrough(Types.TAG);
211+
final ComponentRewriter componentRewriter = protocol.getComponentRewriter();
212+
if (componentRewriter != null) {
213+
componentRewriter.processTag(wrapper.user(), title);
214+
componentRewriter.processTag(wrapper.user(), description);
215+
}
216+
217+
passthroughClientboundItem(wrapper); // Icon
218+
wrapper.passthrough(Types.VAR_INT); // Frame type
219+
int flags = wrapper.passthrough(Types.INT); // Flags
220+
if ((flags & 1) != 0) {
221+
convertClientAsset(wrapper);
222+
}
223+
wrapper.passthrough(Types.FLOAT); // X
224+
wrapper.passthrough(Types.FLOAT); // Y
225+
}
226+
227+
int requirements = wrapper.passthrough(Types.VAR_INT);
228+
for (int array = 0; array < requirements; array++) {
229+
wrapper.passthrough(Types.STRING_ARRAY);
230+
}
231+
232+
wrapper.passthrough(Types.BOOLEAN); // Send telemetry
233+
}
234+
200235
wrapper.passthrough(Types.STRING_ARRAY); // Removed
201236
final int progressSize = wrapper.passthrough(Types.VAR_INT);
202237
for (int i = 0; i < progressSize; i++) {
@@ -227,6 +262,13 @@ protected void handleSmithingTrimSlotDisplay(final PacketWrapper wrapper) {
227262
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_5.PLACE_GHOST_RECIPE);
228263
}
229264

265+
private void convertClientAsset(final PacketWrapper wrapper) {
266+
final String background = wrapper.read(Types.STRING);
267+
final String namespace = Key.namespace(background);
268+
final String path = Key.stripNamespace(background);
269+
wrapper.write(Types.STRING, namespace + ":textures/" + path + ".png");
270+
}
271+
230272
private void sendSaddledEntityData(final UserConnection connection, final TrackedEntity trackedEntity, final int entityId) {
231273
byte data = 0;
232274
if (trackedEntity.hasData()) {

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ metadata.format.version = "1.1"
33
[versions]
44

55
# ViaVersion
6-
viaver = "5.3.1-SNAPSHOT"
6+
viaver = "5.3.2-SNAPSHOT"
77

88
# Common provided
99
netty = "4.0.20.Final"

0 commit comments

Comments
 (0)