Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-16 04:50:08 +01:00
Cleanup enchantment conversion in 1.12->1.13 to match vanilla (#4147)
Closes https://github.com/ViaVersion/ViaFabricPlus/issues/560
Dieser Commit ist enthalten in:
Ursprung
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren