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) {
|
||||
ListTag<CompoundTag> enchantments = new ListTag<>(CompoundTag.class);
|
||||
for (CompoundTag enchEntry : ench) {
|
||||
NumberTag idTag = enchEntry.getNumberTag("id");
|
||||
if (idTag == null) {
|
||||
continue;
|
||||
}
|
||||
short oldId = enchEntry.getShort("id", (short) 0);
|
||||
|
||||
CompoundTag enchantmentEntry = new CompoundTag();
|
||||
short oldId = idTag.asShort();
|
||||
String newId = Protocol1_12_2To1_13.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||
if (newId == null) {
|
||||
newId = "viaversion:legacy/" + oldId;
|
||||
}
|
||||
enchantmentEntry.putString("id", newId);
|
||||
|
||||
NumberTag levelTag = enchEntry.getNumberTag("lvl");
|
||||
if (levelTag != null) {
|
||||
enchantmentEntry.putShort("lvl", levelTag.asShort());
|
||||
}
|
||||
enchantmentEntry.putShort("lvl", enchEntry.getShort("lvl", (short) 0));
|
||||
|
||||
enchantments.add(enchantmentEntry);
|
||||
}
|
||||
@ -589,10 +581,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
|
||||
}
|
||||
if (oldId != null) {
|
||||
enchEntry.putShort("id", oldId);
|
||||
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
||||
if (levelTag != null) {
|
||||
enchEntry.putShort("lvl", levelTag.asShort());
|
||||
}
|
||||
enchEntry.putShort("lvl", enchantmentEntry.getShort("lvl", (short) 0));
|
||||
ench.add(enchEntry);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user