Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 08:30:10 +01:00
Fix 1.14 dummy enchant being lost 1.13 conversion
Dieser Commit ist enthalten in:
Ursprung
d6a1f06b35
Commit
e9ffe66131
@ -762,6 +762,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
|||||||
ListTag noMapped = new ListTag(NBT_TAG_NAME + "|" + key, CompoundTag.class);
|
ListTag noMapped = new ListTag(NBT_TAG_NAME + "|" + key, CompoundTag.class);
|
||||||
ListTag newEnchantments = new ListTag(storedEnch ? key : "ench", CompoundTag.class);
|
ListTag newEnchantments = new ListTag(storedEnch ? key : "ench", CompoundTag.class);
|
||||||
List<Tag> lore = new ArrayList<>();
|
List<Tag> lore = new ArrayList<>();
|
||||||
|
boolean hasValidEnchants = false;
|
||||||
for (Tag enchantmentEntry : enchantments.clone()) {
|
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||||
CompoundTag enchEntry = new CompoundTag("");
|
CompoundTag enchEntry = new CompoundTag("");
|
||||||
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
||||||
@ -774,31 +775,37 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
|||||||
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
if (oldId == null && newId.startsWith("viaversion:legacy/")) {
|
||||||
oldId = Short.valueOf(newId.substring(18));
|
oldId = Short.valueOf(newId.substring(18));
|
||||||
}
|
}
|
||||||
|
Short level = (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue();
|
||||||
|
if (level != 0)
|
||||||
|
hasValidEnchants = true;
|
||||||
enchEntry.put(new ShortTag("id", oldId));
|
enchEntry.put(new ShortTag("id", oldId));
|
||||||
enchEntry.put(new ShortTag("lvl", (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue()));
|
enchEntry.put(new ShortTag("lvl", level));
|
||||||
newEnchantments.add(enchEntry);
|
newEnchantments.add(enchEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lore.isEmpty()) {
|
// Put here to hide empty enchantment from 1.14 rewrites
|
||||||
if (!storedEnch && newEnchantments.size() == 0) {
|
if (!storedEnch && !hasValidEnchants) {
|
||||||
IntTag hideFlags = tag.get("HideFlags");
|
IntTag hideFlags = tag.get("HideFlags");
|
||||||
if (hideFlags == null) {
|
if (hideFlags == null) {
|
||||||
hideFlags = new IntTag("HideFlags");
|
hideFlags = new IntTag("HideFlags");
|
||||||
} else {
|
} else {
|
||||||
tag.put(new IntTag(NBT_TAG_NAME + "|OldHideFlags", hideFlags.getValue()));
|
tag.put(new IntTag(NBT_TAG_NAME + "|OldHideFlags", hideFlags.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newEnchantments.size() == 0) {
|
||||||
CompoundTag enchEntry = new CompoundTag("");
|
CompoundTag enchEntry = new CompoundTag("");
|
||||||
enchEntry.put(new ShortTag("id", (short) 0));
|
enchEntry.put(new ShortTag("id", (short) 0));
|
||||||
enchEntry.put(new ShortTag("lvl", (short) 1));
|
enchEntry.put(new ShortTag("lvl", (short) 0));
|
||||||
|
|
||||||
hideFlags.setValue(hideFlags.getValue() | 1);
|
|
||||||
tag.put(hideFlags);
|
|
||||||
|
|
||||||
newEnchantments.add(enchEntry);
|
newEnchantments.add(enchEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int value = hideFlags.getValue() | 1;
|
||||||
|
hideFlags.setValue(value);
|
||||||
|
tag.put(hideFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lore.isEmpty()) {
|
||||||
tag.put(noMapped);
|
tag.put(noMapped);
|
||||||
|
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.get("display");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren