|
61 | 61 | import com.viaversion.viaversion.api.minecraft.item.data.TooltipDisplay; |
62 | 62 | import com.viaversion.viaversion.api.minecraft.item.data.Weapon; |
63 | 63 | import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; |
| 64 | +import com.viaversion.viaversion.api.rewriter.ComponentRewriter; |
64 | 65 | import com.viaversion.viaversion.api.type.Type; |
65 | 66 | import com.viaversion.viaversion.api.type.Types; |
66 | 67 | import com.viaversion.viaversion.api.type.types.chunk.ChunkBiomesType1_19_4; |
|
78 | 79 | import com.viaversion.viaversion.rewriter.BlockRewriter; |
79 | 80 | import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter; |
80 | 81 | import com.viaversion.viaversion.util.Either; |
| 82 | +import com.viaversion.viaversion.util.Key; |
81 | 83 | import com.viaversion.viaversion.util.Limit; |
82 | 84 | import java.util.ArrayList; |
83 | 85 | import java.util.HashMap; |
@@ -195,8 +197,41 @@ public void registerPackets() { |
195 | 197 | } while (value < 0); |
196 | 198 | }); |
197 | 199 |
|
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 | + |
200 | 235 | wrapper.passthrough(Types.STRING_ARRAY); // Removed |
201 | 236 | final int progressSize = wrapper.passthrough(Types.VAR_INT); |
202 | 237 | for (int i = 0; i < progressSize; i++) { |
@@ -227,6 +262,13 @@ protected void handleSmithingTrimSlotDisplay(final PacketWrapper wrapper) { |
227 | 262 | recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_5.PLACE_GHOST_RECIPE); |
228 | 263 | } |
229 | 264 |
|
| 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 | + |
230 | 272 | private void sendSaddledEntityData(final UserConnection connection, final TrackedEntity trackedEntity, final int entityId) { |
231 | 273 | byte data = 0; |
232 | 274 | if (trackedEntity.hasData()) { |
|
0 commit comments