diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/ArmorMaterials1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/ArmorMaterials1_20_5.java
new file mode 100644
index 000000000..37be7df54
--- /dev/null
+++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/ArmorMaterials1_20_5.java
@@ -0,0 +1,43 @@
+/*
+ * 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 org.checkerframework.checker.nullness.qual.Nullable;
+
+public final class ArmorMaterials1_20_5 {
+
+ private static final KeyMappings MATERIALS = new KeyMappings(
+ "leather",
+ "chainmail",
+ "iron",
+ "gold",
+ "diamond",
+ "turtle",
+ "netherite",
+ "armadillo"
+ );
+
+ public static @Nullable String idToKey(final int id) {
+ return MATERIALS.idToKey(id);
+ }
+
+ 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/Instruments1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Instruments1_20_3.java
index 4616ed7bb..87d793f4e 100644
--- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Instruments1_20_3.java
+++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/data/Instruments1_20_3.java
@@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data;
import com.viaversion.viaversion.util.KeyMappings;
import org.checkerframework.checker.nullness.qual.Nullable;
+// Same as 1.20.5
public final class Instruments1_20_3 {
private static final KeyMappings MAPPINGS = new KeyMappings(
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 fb0ded1aa..0f972f3a3 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
@@ -469,8 +469,11 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter attributeModifiersTag = tag.getListTag("AttributeModifiers", CompoundTag.class);
+ final boolean showAttributes = (hideFlagsValue & StructuredDataConverter.HIDE_ATTRIBUTES) == 0;
if (attributeModifiersTag != null) {
- updateAttributes(data, attributeModifiersTag, (hideFlagsValue & StructuredDataConverter.HIDE_ATTRIBUTES) == 0);
+ updateAttributes(data, attributeModifiersTag, showAttributes);
+ } else if (!showAttributes) {
+ data.set(StructuredDataKey.ATTRIBUTE_MODIFIERS, new AttributeModifiers(new AttributeModifier[0], false));
}
final CompoundTag fireworksTag = tag.getCompoundTag("Fireworks");
diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java
index 563ea50b0..f78baadcf 100644
--- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java
+++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java
@@ -73,12 +73,17 @@ import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPacket1_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.ArmorMaterials1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_5;
+import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
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_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.EquipmentSlots1_20_5;
+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.PotionEffects1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Potions1_20_5;
+import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMaterials1_20_3;
+import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimPatterns1_20_3;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.Either;
@@ -413,6 +418,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter material = value.material();
if (material.hasId()) {
- tag.putInt("material", material.id());
+ final String trimMaterial = TrimMaterials1_20_3.idToKey(material.id());
+ tag.putString("material", trimMaterial);
} else {
final ArmorTrimMaterial armorTrimMaterial = material.value();
final CompoundTag materialTag = new CompoundTag();
- materialTag.putString("asset_name", armorTrimMaterial.assetName());
final String ingredient = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().identifier(armorTrimMaterial.itemId());
if (ingredient == null) {
throw new IllegalArgumentException("Unknown item: " + armorTrimMaterial.itemId());
}
- materialTag.putString("ingredient", ingredient);
- materialTag.putFloat("item_model_index", armorTrimMaterial.itemModelIndex());
+
final CompoundTag overrideArmorMaterialsTag = new CompoundTag();
for (final Int2ObjectMap.Entry entry : armorTrimMaterial.overrideArmorMaterials().int2ObjectEntrySet()) {
- overrideArmorMaterialsTag.putString(String.valueOf(entry.getIntKey()), entry.getValue());
+ final String materialKey = ArmorMaterials1_20_5.idToKey(entry.getIntKey());
+ if (materialKey != null) {
+ overrideArmorMaterialsTag.putString(materialKey, entry.getValue());
+ }
}
+
+ materialTag.putString("asset_name", armorTrimMaterial.assetName());
+ materialTag.putString("ingredient", ingredient);
+ materialTag.putFloat("item_model_index", armorTrimMaterial.itemModelIndex());
materialTag.put("override_armor_materials", overrideArmorMaterialsTag);
materialTag.put("description", armorTrimMaterial.description());
tag.put("material", materialTag);
@@ -640,21 +652,26 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter pattern = value.pattern();
if (pattern.hasId()) {
- tag.putInt("pattern", pattern.id());
+ tag.putString("pattern", TrimPatterns1_20_3.idToKey(pattern.id()));
} else {
final ArmorTrimPattern armorTrimPattern = pattern.value();
final CompoundTag patternTag = new CompoundTag();
- patternTag.put("asset_id", convertIdentifier(armorTrimPattern.assetName()));
final String templateItem = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().identifier(armorTrimPattern.itemId());
if (templateItem == null) {
throw new IllegalArgumentException("Unknown item: " + armorTrimPattern.itemId());
}
+
+ patternTag.put("asset_id", convertIdentifier(armorTrimPattern.assetName()));
patternTag.putString("template_item", templateItem);
patternTag.put("description", armorTrimPattern.description());
+ tag.put("pattern", patternTag);
if (armorTrimPattern.decal()) {
patternTag.putBoolean("decal", true);
}
- tag.put("pattern", patternTag);
+ }
+
+ if (!value.showInTooltip()) {
+ tag.putBoolean("show_in_tooltip", false);
}
return tag;
}
@@ -677,13 +694,14 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter value) {
if (value.hasId()) {
- return new IntTag(value.id());
+ return new StringTag(Instruments1_20_3.idToKey(value.id()));
}
+
final Instrument instrument = value.value();
final CompoundTag tag = new CompoundTag();
final Holder sound = instrument.soundEvent();
if (sound.hasId()) {
- tag.putInt("sound_event", sound.id());
+ tag.putString("sound_event", Protocol1_20_5To1_20_3.MAPPINGS.soundName(sound.id()));
} else {
final SoundEvent soundEvent = sound.value();
final CompoundTag soundEventTag = new CompoundTag();
@@ -692,6 +710,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter pattern) {
if (pattern.hasId()) {
- tag.putInt(name, pattern.id());
+ tag.putString(name, BannerPatterns1_20_5.idToKey(pattern.id()));
return;
}
+
final BannerPattern bannerPattern = pattern.value();
final CompoundTag patternTag = new CompoundTag();
patternTag.put("asset_id", convertIdentifier(bannerPattern.assetId()));