mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 03:25:11 +01:00
Cleanup enchantment conversion in 1.12->1.13 to match vanilla (#4147)
Closes https://github.com/ViaVersion/ViaFabricPlus/issues/560
This commit is contained in:
parent
fcb472347e
commit
7235485802
@ -304,23 +304,15 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
|
|||||||
if (ench != null) {
|
if (ench != null) {
|
||||||
ListTag<CompoundTag> enchantments = new ListTag<>(CompoundTag.class);
|
ListTag<CompoundTag> enchantments = new ListTag<>(CompoundTag.class);
|
||||||
for (CompoundTag enchEntry : ench) {
|
for (CompoundTag enchEntry : ench) {
|
||||||
NumberTag idTag = enchEntry.getNumberTag("id");
|
short oldId = enchEntry.getShort("id", (short) 0);
|
||||||
if (idTag == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompoundTag enchantmentEntry = new CompoundTag();
|
CompoundTag enchantmentEntry = new CompoundTag();
|
||||||
short oldId = idTag.asShort();
|
|
||||||
String newId = Protocol1_12_2To1_13.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
String newId = Protocol1_12_2To1_13.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||||
if (newId == null) {
|
if (newId == null) {
|
||||||
newId = "viaversion:legacy/" + oldId;
|
newId = "viaversion:legacy/" + oldId;
|
||||||
}
|
}
|
||||||
enchantmentEntry.putString("id", newId);
|
enchantmentEntry.putString("id", newId);
|
||||||
|
enchantmentEntry.putShort("lvl", enchEntry.getShort("lvl", (short) 0));
|
||||||
NumberTag levelTag = enchEntry.getNumberTag("lvl");
|
|
||||||
if (levelTag != null) {
|
|
||||||
enchantmentEntry.putShort("lvl", levelTag.asShort());
|
|
||||||
}
|
|
||||||
|
|
||||||
enchantments.add(enchantmentEntry);
|
enchantments.add(enchantmentEntry);
|
||||||
}
|
}
|
||||||
@ -589,10 +581,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
|
|||||||
}
|
}
|
||||||
if (oldId != null) {
|
if (oldId != null) {
|
||||||
enchEntry.putShort("id", oldId);
|
enchEntry.putShort("id", oldId);
|
||||||
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
enchEntry.putShort("lvl", enchantmentEntry.getShort("lvl", (short) 0));
|
||||||
if (levelTag != null) {
|
|
||||||
enchEntry.putShort("lvl", levelTag.asShort());
|
|
||||||
}
|
|
||||||
ench.add(enchEntry);
|
ench.add(enchEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user