mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-24 02:55:50 +01:00
Trim override materials are string to string
This commit is contained in:
parent
deab6a0cac
commit
e878d77959
@ -27,11 +27,11 @@ import com.viaversion.viaversion.api.type.Types;
|
|||||||
import com.viaversion.viaversion.api.type.types.misc.HolderType;
|
import com.viaversion.viaversion.api.type.types.misc.HolderType;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import java.util.Map;
|
||||||
|
|
||||||
public record ArmorTrimMaterial(String assetName, int itemId, float itemModelIndex,
|
public record ArmorTrimMaterial(String assetName, int itemId, float itemModelIndex,
|
||||||
Int2ObjectMap<String> overrideArmorMaterials, Tag description) {
|
Map<String, String> overrideArmorMaterials, Tag description) {
|
||||||
|
|
||||||
public static final HolderType<ArmorTrimMaterial> TYPE = new HolderType<>() {
|
public static final HolderType<ArmorTrimMaterial> TYPE = new HolderType<>() {
|
||||||
@Override
|
@Override
|
||||||
@ -41,9 +41,9 @@ public record ArmorTrimMaterial(String assetName, int itemId, float itemModelInd
|
|||||||
final float itemModelIndex = buffer.readFloat();
|
final float itemModelIndex = buffer.readFloat();
|
||||||
|
|
||||||
final int overrideArmorMaterialsSize = Types.VAR_INT.readPrimitive(buffer);
|
final int overrideArmorMaterialsSize = Types.VAR_INT.readPrimitive(buffer);
|
||||||
final Int2ObjectMap<String> overrideArmorMaterials = new Int2ObjectOpenHashMap<>(overrideArmorMaterialsSize);
|
final Map<String, String> overrideArmorMaterials = new Object2ObjectArrayMap<>(overrideArmorMaterialsSize);
|
||||||
for (int i = 0; i < overrideArmorMaterialsSize; i++) {
|
for (int i = 0; i < overrideArmorMaterialsSize; i++) {
|
||||||
final int key = Types.VAR_INT.readPrimitive(buffer);
|
final String key = Types.STRING.read(buffer);
|
||||||
final String value = Types.STRING.read(buffer);
|
final String value = Types.STRING.read(buffer);
|
||||||
overrideArmorMaterials.put(key, value);
|
overrideArmorMaterials.put(key, value);
|
||||||
}
|
}
|
||||||
@ -59,8 +59,8 @@ public record ArmorTrimMaterial(String assetName, int itemId, float itemModelInd
|
|||||||
buffer.writeFloat(value.itemModelIndex());
|
buffer.writeFloat(value.itemModelIndex());
|
||||||
|
|
||||||
Types.VAR_INT.writePrimitive(buffer, value.overrideArmorMaterials().size());
|
Types.VAR_INT.writePrimitive(buffer, value.overrideArmorMaterials().size());
|
||||||
for (final Int2ObjectMap.Entry<String> entry : value.overrideArmorMaterials().int2ObjectEntrySet()) {
|
for (final Map.Entry<String, String> entry : value.overrideArmorMaterials().entrySet()) {
|
||||||
Types.VAR_INT.writePrimitive(buffer, entry.getIntKey());
|
Types.STRING.write(buffer, entry.getKey());
|
||||||
Types.STRING.write(buffer, entry.getValue());
|
Types.STRING.write(buffer, entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,8 +105,7 @@ import com.viaversion.viaversion.util.Key;
|
|||||||
import com.viaversion.viaversion.util.SerializerVersion;
|
import com.viaversion.viaversion.util.SerializerVersion;
|
||||||
import com.viaversion.viaversion.util.UUIDUtil;
|
import com.viaversion.viaversion.util.UUIDUtil;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -1000,17 +999,14 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
final CompoundTag overrideArmorMaterialsTag = materialCompoundTag.getCompoundTag("override_armor_materials");
|
final CompoundTag overrideArmorMaterialsTag = materialCompoundTag.getCompoundTag("override_armor_materials");
|
||||||
final Tag descriptionTag = materialCompoundTag.get("description");
|
final Tag descriptionTag = materialCompoundTag.get("description");
|
||||||
|
|
||||||
final Int2ObjectMap<String> overrideArmorMaterials = new Int2ObjectOpenHashMap<>();
|
final Map<String, String> overrideArmorMaterials = new Object2ObjectArrayMap<>();
|
||||||
if (overrideArmorMaterialsTag != null) {
|
if (overrideArmorMaterialsTag != null) {
|
||||||
for (final Map.Entry<String, Tag> entry : overrideArmorMaterialsTag.entrySet()) {
|
for (final Map.Entry<String, Tag> entry : overrideArmorMaterialsTag.entrySet()) {
|
||||||
if (!(entry.getValue() instanceof StringTag valueTag)) {
|
if (!(entry.getValue() instanceof StringTag valueTag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
final int id = Integer.parseInt(entry.getKey());
|
overrideArmorMaterials.put(entry.getKey(), valueTag.getValue());
|
||||||
overrideArmorMaterials.put(id, valueTag.getValue());
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,6 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
|||||||
import com.viaversion.viaversion.api.type.types.UnsignedByteType;
|
import com.viaversion.viaversion.api.type.types.UnsignedByteType;
|
||||||
import com.viaversion.viaversion.api.type.types.item.StructuredDataType;
|
import com.viaversion.viaversion.api.type.types.item.StructuredDataType;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.ArmorMaterials1_20_5;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.Attributes1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.Attributes1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.BannerPatterns1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.BannerPatterns1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.DyeColors;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.DyeColors;
|
||||||
@ -92,7 +91,6 @@ import com.viaversion.viaversion.util.SerializerVersion;
|
|||||||
import com.viaversion.viaversion.util.UUIDUtil;
|
import com.viaversion.viaversion.util.UUIDUtil;
|
||||||
import com.viaversion.viaversion.util.Unit;
|
import com.viaversion.viaversion.util.Unit;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -693,11 +691,8 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag overrideArmorMaterialsTag = new CompoundTag();
|
final CompoundTag overrideArmorMaterialsTag = new CompoundTag();
|
||||||
for (final Int2ObjectMap.Entry<String> entry : armorTrimMaterial.overrideArmorMaterials().int2ObjectEntrySet()) {
|
for (final Map.Entry<String, String> entry : armorTrimMaterial.overrideArmorMaterials().entrySet()) {
|
||||||
final String materialKey = ArmorMaterials1_20_5.idToKey(entry.getIntKey());
|
overrideArmorMaterialsTag.putString(entry.getKey(), entry.getValue());
|
||||||
if (materialKey != null) {
|
|
||||||
overrideArmorMaterialsTag.putString(materialKey, entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
materialTag.putString("asset_name", armorTrimMaterial.assetName());
|
materialTag.putString("asset_name", armorTrimMaterial.assetName());
|
||||||
|
@ -65,7 +65,6 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.storage.BannerPattern
|
|||||||
import com.viaversion.viaversion.util.ComponentUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import com.viaversion.viaversion.util.UUIDUtil;
|
import com.viaversion.viaversion.util.UUIDUtil;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -530,8 +529,8 @@ public final class StructuredDataConverter {
|
|||||||
|
|
||||||
final CompoundTag overrideArmorMaterials = new CompoundTag();
|
final CompoundTag overrideArmorMaterials = new CompoundTag();
|
||||||
if (!material.overrideArmorMaterials().isEmpty()) {
|
if (!material.overrideArmorMaterials().isEmpty()) {
|
||||||
for (final Int2ObjectMap.Entry<String> entry : material.overrideArmorMaterials().int2ObjectEntrySet()) {
|
for (final Map.Entry<String, String> entry : material.overrideArmorMaterials().entrySet()) {
|
||||||
overrideArmorMaterials.put(Integer.toString(entry.getIntKey()), new StringTag(entry.getValue()));
|
overrideArmorMaterials.put(entry.getKey(), new StringTag(entry.getValue()));
|
||||||
}
|
}
|
||||||
materialTag.put("override_armor_materials", overrideArmorMaterials);
|
materialTag.put("override_armor_materials", overrideArmorMaterials);
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
|||||||
|
|
||||||
// Remove old entity
|
// Remove old entity
|
||||||
final PacketWrapper removeEntityPacket = PacketWrapper.create(ClientboundPackets1_21_2.REMOVE_ENTITIES, event.user());
|
final PacketWrapper removeEntityPacket = PacketWrapper.create(ClientboundPackets1_21_2.REMOVE_ENTITIES, event.user());
|
||||||
removeEntityPacket.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[] { event.entityId() });
|
removeEntityPacket.write(Types.VAR_INT_ARRAY_PRIMITIVE, new int[]{event.entityId()});
|
||||||
removeEntityPacket.send(Protocol1_21To1_21_2.class);
|
removeEntityPacket.send(Protocol1_21To1_21_2.class);
|
||||||
|
|
||||||
// Detect correct boat entity type from entity data
|
// Detect correct boat entity type from entity data
|
||||||
|
Loading…
Reference in New Issue
Block a user