Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-17 13:30:14 +01:00
Ursprung
4797914556
Commit
94210e92f1
@ -18,15 +18,22 @@
|
||||
package com.viaversion.viabackwards.api.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class MappedItem {
|
||||
|
||||
private final int id;
|
||||
private final String jsonName;
|
||||
private final Integer customModelData;
|
||||
|
||||
public MappedItem(int id, String name) {
|
||||
public MappedItem(final int id, final String name) {
|
||||
this(id, name, null);
|
||||
}
|
||||
|
||||
public MappedItem(final int id, final String name, @Nullable final Integer customModelData) {
|
||||
this.id = id;
|
||||
this.jsonName = ChatRewriter.legacyTextToJsonString("§f" + name);
|
||||
this.jsonName = ChatRewriter.legacyTextToJsonString("§f" + name, true);
|
||||
this.customModelData = customModelData;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -36,4 +43,8 @@ public class MappedItem {
|
||||
public String getJsonName() {
|
||||
return jsonName;
|
||||
}
|
||||
|
||||
public @Nullable Integer customModelData() {
|
||||
return customModelData;
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,8 @@ public final class VBMappingDataLoader {
|
||||
}
|
||||
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
itemMapping.put(oldId, new MappedItem(mappedId, name));
|
||||
JsonPrimitive customModelData = object.getAsJsonPrimitive("custom_model_data");
|
||||
itemMapping.put(oldId, new MappedItem(mappedId, name, customModelData != null ? customModelData.getAsInt() : null));
|
||||
}
|
||||
|
||||
// Look for missing keys
|
||||
|
@ -88,6 +88,11 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
item.tag().put(nbtTagName + "|id", new IntTag(item.identifier()));
|
||||
item.setIdentifier(data.getId());
|
||||
|
||||
// Add custom model data
|
||||
if (data.customModelData() != null && !item.tag().contains("CustomModelData")) {
|
||||
item.tag().put("CustomModelData", new IntTag(data.customModelData()));
|
||||
}
|
||||
|
||||
// Set custom name - only done if there is no original one
|
||||
if (display == null) {
|
||||
item.tag().put("display", display = new CompoundTag());
|
||||
|
@ -20,10 +20,8 @@ package com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.data;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.NBTIO;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren