diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java index d7be2e02d..95c40f39e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPatternLayer.java @@ -33,31 +33,31 @@ public final class BannerPatternLayer { @Override public BannerPatternLayer read(final ByteBuf buffer) throws Exception { final Holder pattern = BannerPattern.TYPE.read(buffer); - final DyedColor color = DyedColor.TYPE.read(buffer); + final int color = Type.VAR_INT.readPrimitive(buffer); return new BannerPatternLayer(pattern, color); } @Override public void write(final ByteBuf buffer, final BannerPatternLayer value) throws Exception { BannerPattern.TYPE.write(buffer, value.pattern); - DyedColor.TYPE.write(buffer, value.color); + Type.VAR_INT.writePrimitive(buffer, value.dyeColor); } }; public static final Type ARRAY_TYPE = new ArrayType<>(TYPE); private final Holder pattern; - private final DyedColor color; + private final int dyeColor; - public BannerPatternLayer(final Holder pattern, final DyedColor color) { + public BannerPatternLayer(final Holder pattern, final int dyeColor) { this.pattern = pattern; - this.color = color; + this.dyeColor = dyeColor; } public Holder pattern() { return pattern; } - public DyedColor color() { - return color; + public int dyeColor() { + return dyeColor; } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/BannerPatterns1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/BannerPatterns1_20_3.java new file mode 100644 index 000000000..0334e463a --- /dev/null +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/BannerPatterns1_20_3.java @@ -0,0 +1,131 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2023 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data; + +import com.viaversion.viaversion.util.KeyMappings; +import java.util.HashMap; +import java.util.Map; +import org.checkerframework.checker.nullness.qual.Nullable; + +public final class BannerPatterns1_20_3 { + + private static final KeyMappings PATTERNS = new KeyMappings( + "base", + "square_bottom_left", + "square_bottom_right", + "square_top_left", + "square_top_right", + "stripe_bottom", + "stripe_top", + "stripe_left", + "stripe_right", + "stripe_center", + "stripe_middle", + "stripe_downright", + "stripe_downleft", + "small_stripes", + "cross", + "straight_cross", + "triangle_bottom", + "triangle_top", + "triangles_bottom", + "triangles_top", + "diagonal_left", + "diagonal_up_right", + "diagonal_up_left", + "diagonal_right", + "circle", + "rhombus", + "half_vertical", + "half_horizontal", + "half_vertical_right", + "half_horizontal_bottom", + "border", + "curly_border", + "gradient", + "gradient_up", + "bricks", + "globe", + "creeper", + "skull", + "flower", + "mojang", + "piglin" + ); + private static final Map PATTERN_IDS = new HashMap<>(); + + static { + PATTERN_IDS.put("b", "base"); + PATTERN_IDS.put("bl", "square_bottom_left"); + PATTERN_IDS.put("br", "square_bottom_right"); + PATTERN_IDS.put("tl", "square_top_left"); + PATTERN_IDS.put("tr", "square_top_right"); + PATTERN_IDS.put("bs", "stripe_bottom"); + PATTERN_IDS.put("ts", "stripe_top"); + PATTERN_IDS.put("ls", "stripe_left"); + PATTERN_IDS.put("rs", "stripe_right"); + PATTERN_IDS.put("cs", "stripe_center"); + PATTERN_IDS.put("ms", "stripe_middle"); + PATTERN_IDS.put("drs", "stripe_downright"); + PATTERN_IDS.put("dls", "stripe_downleft"); + PATTERN_IDS.put("ss", "small_stripes"); + PATTERN_IDS.put("cr", "cross"); + PATTERN_IDS.put("sc", "straight_cross"); + PATTERN_IDS.put("bt", "triangle_bottom"); + PATTERN_IDS.put("tt", "triangle_top"); + PATTERN_IDS.put("bts", "triangles_bottom"); + PATTERN_IDS.put("tts", "triangles_top"); + PATTERN_IDS.put("ld", "diagonal_left"); + PATTERN_IDS.put("rd", "diagonal_up_right"); + PATTERN_IDS.put("lud", "diagonal_up_left"); + PATTERN_IDS.put("rud", "diagonal_right"); + PATTERN_IDS.put("mc", "circle"); + PATTERN_IDS.put("mr", "rhombus"); + PATTERN_IDS.put("vh", "half_vertical"); + PATTERN_IDS.put("hh", "half_horizontal"); + PATTERN_IDS.put("vhr", "half_vertical_right"); + PATTERN_IDS.put("hhb", "half_horizontal_bottom"); + PATTERN_IDS.put("bo", "border"); + PATTERN_IDS.put("cbo", "curly_border"); + PATTERN_IDS.put("gra", "gradient"); + PATTERN_IDS.put("gru", "gradient_up"); + PATTERN_IDS.put("bri", "bricks"); + PATTERN_IDS.put("glb", "globe"); + PATTERN_IDS.put("cre", "creeper"); + PATTERN_IDS.put("sku", "skull"); + PATTERN_IDS.put("flo", "flower"); + PATTERN_IDS.put("moj", "mojang"); + PATTERN_IDS.put("pig", "piglin"); + } + + public static @Nullable String idToKey(final int id) { + return PATTERNS.idToKey(id); + } + + public static int keyToId(final String pattern) { + return PATTERNS.keyToId(pattern); + } + + public static @Nullable String compactToFullId(final String compactId) { + return PATTERN_IDS.get(compactId); + } + + public static String[] keys() { + return PATTERNS.keys(); + } +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/DyeColors.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/DyeColors.java new file mode 100644 index 000000000..d8c7c58c6 --- /dev/null +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/DyeColors.java @@ -0,0 +1,58 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data; + +public final class DyeColors { + + public static String colorById(final int id) { + switch (id) { + case 1: + return "orange"; + case 2: + return "magenta"; + case 3: + return "light_blue"; + case 4: + return "yellow"; + case 5: + return "lime"; + case 6: + return "pink"; + case 7: + return "gray"; + case 8: + return "light_gray"; + case 9: + return "cyan"; + case 10: + return "purple"; + case 11: + return "blue"; + case 12: + return "brown"; + case 13: + return "green"; + case 14: + return "red"; + case 15: + return "black"; + default: + return "white"; + } + } +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Enchantments1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Enchantments1_20_3.java index a6db68bb5..3d7aedcf0 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Enchantments1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Enchantments1_20_3.java @@ -68,7 +68,7 @@ public final class Enchantments1_20_3 { return ENCHANTMENTS.idToKey(id); } - public static int id(final String attribute) { - return ENCHANTMENTS.keyToId(attribute); + public static int id(final String enchantment) { + return ENCHANTMENTS.keyToId(enchantment); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/MapDecorations1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/MapDecorations1_20_3.java index f9a2a8e56..f1010de5a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/MapDecorations1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/MapDecorations1_20_3.java @@ -58,7 +58,7 @@ public final class MapDecorations1_20_3 { "swamp_hut" ); - public static String mapDecoration(final int index) { + public static String idToKey(final int index) { return index < 0 || index >= MAP_DECORATIONS.size() ? "player" : MAP_DECORATIONS.idToKey(index); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Potions1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Potions1_20_3.java index 717943bed..16375b90f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Potions1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Potions1_20_3.java @@ -72,7 +72,7 @@ public final class Potions1_20_3 { return POTIONS.idToKey(id); } - public static int keyToId(final String attribute) { - return POTIONS.keyToId(attribute); + public static int keyToId(final String potion) { + return POTIONS.keyToId(potion); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimMaterials1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimMaterials1_20_3.java index 52e96f414..50451449b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimMaterials1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimMaterials1_20_3.java @@ -39,7 +39,7 @@ public final class TrimMaterials1_20_3 { return MATERIALS.idToKey(id); } - public static int keyToId(final String attribute) { - return MATERIALS.keyToId(attribute); + public static int keyToId(final String material) { + return MATERIALS.keyToId(material); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimPatterns1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimPatterns1_20_3.java index e34d6e449..36b1b2b31 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimPatterns1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/TrimPatterns1_20_3.java @@ -45,7 +45,7 @@ public final class TrimPatterns1_20_3 { return PATTERNS.idToKey(id); } - public static int keyToId(final String attribute) { - return PATTERNS.keyToId(attribute); + public static int keyToId(final String pattern) { + return PATTERNS.keyToId(pattern); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 9ea0e9cd8..426a67178 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -39,6 +39,7 @@ import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimMaterial; import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimPattern; import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifier; import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers; +import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer; import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties; import com.viaversion.viaversion.api.minecraft.item.data.DyedColor; import com.viaversion.viaversion.api.minecraft.item.data.Enchantments; @@ -64,6 +65,8 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.DyeColors; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Enchantments1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Instruments1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.MapDecorations1_20_3; @@ -79,6 +82,7 @@ import com.viaversion.viaversion.util.Key; import com.viaversion.viaversion.util.UUIDUtil; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -251,7 +255,6 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter effectsTag = tag.getListTag("effects", CompoundTag.class); @@ -339,9 +341,9 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter attributeModifiersTag, final boolean showInTooltip) { final AttributeModifier[] modifiers = attributeModifiersTag.stream().map(modifierTag -> { - final StringTag attributeNameTag = modifierTag.getStringTag("AttributeName"); - final StringTag nameTag = modifierTag.getStringTag("Name"); - final NumberTag operationTag = modifierTag.getNumberTag("Operation"); + final String attributeName = modifierTag.getString("AttributeName"); + final String name = modifierTag.getString("Name"); final NumberTag amountTag = modifierTag.getNumberTag("Amount"); final IntArrayTag uuidTag = modifierTag.getIntArrayTag("UUID"); final NumberTag slotTag = modifierTag.getNumberTag("Slot"); - if (nameTag == null || attributeNameTag == null || operationTag == null || amountTag == null || uuidTag == null || slotTag == null) { + if (name == null || attributeName == null || amountTag == null || uuidTag == null || slotTag == null) { return null; } - final int operationId = operationTag.asInt(); + final int operationId = modifierTag.getInt("Operation", -1); if (operationId < 0 || operationId > 2) { return null; } - final int attributeId = Attributes1_20_3.keyToId(attributeNameTag.getValue()); + final int attributeId = Attributes1_20_3.keyToId(attributeName); if (attributeId == -1) { return null; } @@ -434,7 +433,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter 0 ? id - 1 : null; // Empty potion type removed } @@ -457,27 +456,27 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter { - final StringTag idTag = effectTag.getStringTag("id"); - if (idTag == null) { + final String identifier = effectTag.getString("id"); + if (identifier == null) { return null; } - final int id = PotionEffects.keyToId(idTag.getValue()) - 1; + final int id = PotionEffects.keyToId(identifier) - 1; if (id < 0) { return null; } - final NumberTag amplifierTag = effectTag.getNumberTag("amplifier"); - final NumberTag durationTag = effectTag.getNumberTag("duration"); - final NumberTag ambientTag = effectTag.getNumberTag("ambient"); - final NumberTag showParticlesTag = effectTag.getNumberTag("show_particles"); - final NumberTag showIconTag = effectTag.getNumberTag("show_icon"); + final byte amplifier = effectTag.getByte("amplifier"); + final int duration = effectTag.getInt("duration"); + final boolean ambient = effectTag.getBoolean("ambient"); + final boolean showParticles = effectTag.getBoolean("show_particles"); + final boolean showIcon = effectTag.getBoolean("show_icon"); final PotionEffectData effectData = new PotionEffectData( - amplifierTag != null ? amplifierTag.asByte() : 0, - durationTag != null ? durationTag.asInt() : 0, - ambientTag != null && ambientTag.asBoolean(), - showParticlesTag != null && showParticlesTag.asBoolean(), - showIconTag != null && showIconTag.asBoolean(), + amplifier, + duration, + ambient, + showParticles, + showIcon, null //TODO ); return new PotionEffect(id, effectData); @@ -557,9 +556,9 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter explosionsTag) { - final NumberTag flightDuration = fireworksTag.getNumberTag("Flight"); + final int flightDuration = fireworksTag.getInt("Flight"); final Fireworks fireworks = new Fireworks( - flightDuration != null ? flightDuration.asInt() : 0, + flightDuration, explosionsTag.stream().map(this::readExplosion).toArray(FireworkExplosion[]::new) ); data.set(StructuredDataKey.FIREWORKS, fireworks); @@ -569,43 +568,38 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter decorationsTag) { final CompoundTag updatedDecorationsTag = new CompoundTag(); for (final CompoundTag decorationTag : decorationsTag) { - final StringTag idTag = decorationTag.getStringTag("id"); - final String id = idTag != null ? idTag.asRawString() : ""; - final NumberTag typeTag = decorationTag.getNumberTag("type"); - final int type = typeTag != null ? typeTag.asInt() : 0; - final NumberTag xTag = decorationTag.getNumberTag("x"); - final NumberTag zTag = decorationTag.getNumberTag("z"); - final NumberTag rotationTag = decorationTag.getNumberTag("rot"); + final String id = decorationTag.getString("id", ""); + final int type = decorationTag.getInt("type"); + final double x = decorationTag.getDouble("x"); + final double z = decorationTag.getDouble("z"); + final float rotation = decorationTag.getFloat("rot"); final CompoundTag updatedDecorationTag = new CompoundTag(); - updatedDecorationTag.putString("type", MapDecorations1_20_3.mapDecoration(type)); - updatedDecorationTag.putDouble("x", xTag != null ? xTag.asDouble() : 0); - updatedDecorationTag.putDouble("z", zTag != null ? zTag.asDouble() : 0); - updatedDecorationTag.putFloat("rotation", rotationTag != null ? rotationTag.asFloat() : 0); + updatedDecorationTag.putString("type", MapDecorations1_20_3.idToKey(type)); + updatedDecorationTag.putDouble("x", x); + updatedDecorationTag.putDouble("z", z); + updatedDecorationTag.putFloat("rotation", rotation); updatedDecorationsTag.put(id, updatedDecorationTag); } @@ -841,16 +828,42 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter patternsTag = tag.getListTag("Patterns", CompoundTag.class); + if (patternsTag != null) { + final BannerPatternLayer[] layers = patternsTag.stream().map(patternTag -> { + final String pattern = patternTag.getString("Pattern", ""); + final int color = patternTag.getInt("Color", -1); + final String fullPatternIdentifier = BannerPatterns1_20_3.compactToFullId(pattern); + if (fullPatternIdentifier == null || color == -1) { + return null; + } + + patternTag.remove("Pattern"); + patternTag.remove("Color"); + patternTag.putString("pattern", fullPatternIdentifier); + patternTag.putString("color", DyeColors.colorById(color)); + + final int id = BannerPatterns1_20_3.keyToId(fullPatternIdentifier); + return new BannerPatternLayer(Holder.of(id), color); + }).filter(Objects::nonNull).toArray(BannerPatternLayer[]::new); + tag.remove("Patterns"); + tag.put("patterns", patternsTag); + + if (data != null) { + data.set(StructuredDataKey.BANNER_PATTERNS, layers); + } + } + + // TODO Beehive needed? } private void updateSkullOwnerTag(final CompoundTag tag, final CompoundTag skullOwnerTag) { final CompoundTag profileTag = new CompoundTag(); tag.put("profile", profileTag); - final StringTag nameTag = skullOwnerTag.getStringTag("Name"); - if (nameTag != null) { - profileTag.putString("name", nameTag.getValue()); + final String name = skullOwnerTag.getString("Name"); + if (name != null) { + profileTag.putString("name", name); } final IntArrayTag idTag = skullOwnerTag.getIntArrayTag("Id"); @@ -869,20 +882,20 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter value = (ListTag) entry.getValue(); - for (final Tag propertyTag : value) { + final ListTag entryValue = (ListTag) entry.getValue(); + for (final Tag propertyTag : entryValue) { if (!(propertyTag instanceof CompoundTag)) { continue; } final CompoundTag updatedPropertyTag = new CompoundTag(); final CompoundTag propertyCompoundTag = (CompoundTag) propertyTag; - final StringTag valueTag = propertyCompoundTag.getStringTag("Value"); - final StringTag signatureTag = propertyCompoundTag.getStringTag("Signature"); + final String value = propertyCompoundTag.getString("Value", ""); + final String signature = propertyCompoundTag.getString("Signature"); updatedPropertyTag.putString("name", entry.getKey()); - updatedPropertyTag.putString("value", valueTag != null ? valueTag.getValue() : ""); - if (signatureTag != null) { - updatedPropertyTag.putString("signature", signatureTag.getValue()); + updatedPropertyTag.putString("value", value); + if (signature != null) { + updatedPropertyTag.putString("signature", signature); } propertiesListTag.add(updatedPropertyTag); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java index 5f52d6d52..d1d0be003 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java @@ -35,6 +35,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3; +import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5; import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.util.Key; @@ -98,6 +99,32 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter(StringTag.class)); + wolfVariantsPacket.write(Type.REGISTRY_ENTRY_ARRAY, new RegistryEntry[]{new RegistryEntry("minecraft:pale", paleWolf)}); + wolfVariantsPacket.send(Protocol1_20_5To1_20_3.class); + + final PacketWrapper bannerPatternsPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA); + bannerPatternsPacket.write(Type.STRING, "minecraft:banner_pattern"); + final RegistryEntry[] patternEntries = new RegistryEntry[BannerPatterns1_20_3.keys().length]; + final String[] keys = BannerPatterns1_20_3.keys(); + for (int i = 0; i < keys.length; i++) { + final CompoundTag pattern = new CompoundTag(); + final String key = keys[i]; + final String resourceLocation = "minecraft:" + key; + pattern.putString("asset_id", key); + pattern.putString("translation_key", "block.minecraft.banner." + key); + patternEntries[i] = new RegistryEntry(resourceLocation, pattern); + } + bannerPatternsPacket.write(Type.REGISTRY_ENTRY_ARRAY, patternEntries); + bannerPatternsPacket.send(Protocol1_20_5To1_20_3.class); }); protocol.registerClientbound(ClientboundPackets1_20_3.JOIN_GAME, new PacketHandlers() { @@ -202,10 +229,10 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter