3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-08 09:10:10 +01:00

Fix number casting in 1.13 enchantments

Dieser Commit ist enthalten in:
KennyTV 2020-03-16 12:01:21 +01:00
Ursprung 5909103c56
Commit 6b73de2510
2 geänderte Dateien mit 13 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -31,7 +31,7 @@ public class EnchantmentRewriter {
if (enchantmentName != null) { if (enchantmentName != null) {
enchantments.remove(enchantmentEntry); enchantments.remove(enchantmentEntry);
Number level = (Number) ((CompoundTag) enchantmentEntry).get("lvl").getValue(); Number level = (Number) ((CompoundTag) enchantmentEntry).get("lvl").getValue();
lore.add(new StringTag("", enchantmentName + " " + getRomanNumber(level.shortValue()))); lore.add(new StringTag("", enchantmentName + " " + getRomanNumber(level.intValue())));
remappedEnchantments.add(enchantmentEntry); remappedEnchantments.add(enchantmentEntry);
} }
} }

Datei anzeigen

@ -646,14 +646,15 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
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; boolean hasValidEnchants = false;
for (Tag enchantmentEntry : enchantments.clone()) { for (Tag enchantmentEntryTag : enchantments.clone()) {
CompoundTag enchEntry = new CompoundTag(""); CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue(); String newId = (String) enchantmentEntry.get("id").getValue();
Number levelValue = (Number) enchantmentEntry.get("lvl").getValue();
short level = levelValue.shortValue();
String mappedEnchantmentId = enchantmentMappings.get(newId); String mappedEnchantmentId = enchantmentMappings.get(newId);
if (mappedEnchantmentId != null) { if (mappedEnchantmentId != null) {
lore.add(new StringTag("", mappedEnchantmentId + " " lore.add(new StringTag("", mappedEnchantmentId + " " + EnchantmentRewriter.getRomanNumber(level)));
+ EnchantmentRewriter.getRomanNumber((Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue())));
noMapped.add(enchantmentEntry); noMapped.add(enchantmentEntry);
} else if (!newId.isEmpty()) { } else if (!newId.isEmpty()) {
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId); Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
@ -670,8 +671,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
} }
name = "§7" + Character.toUpperCase(name.charAt(0)) + name.substring(1).toLowerCase(Locale.ENGLISH); name = "§7" + Character.toUpperCase(name.charAt(0)) + name.substring(1).toLowerCase(Locale.ENGLISH);
lore.add(new StringTag("", name + " " lore.add(new StringTag("", name + " " + EnchantmentRewriter.getRomanNumber(level)));
+ EnchantmentRewriter.getRomanNumber((Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue())));
} }
if (Via.getManager().isDebug()) { if (Via.getManager().isDebug()) {
@ -683,13 +683,14 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
} }
} }
Short level = (Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue();
if (level != 0) { if (level != 0) {
hasValidEnchants = true; hasValidEnchants = true;
} }
enchEntry.put(new ShortTag("id", oldId));
enchEntry.put(new ShortTag("lvl", level)); CompoundTag newEntry = new CompoundTag("");
newEnchantments.add(enchEntry); newEntry.put(new ShortTag("id", oldId));
newEntry.put(new ShortTag("lvl", level));
newEnchantments.add(newEntry);
} }
} }