3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Remove more unnecessary map lookups

Dieser Commit ist enthalten in:
KennyTV 2020-06-03 18:36:22 +02:00
Ursprung 5988ab4c19
Commit cf5e5590ad
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 8 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -111,9 +111,7 @@ public class EnchantmentRewriter {
enchantments = new ListTag(key, CompoundTag.class);
}
if (!storedEnchant && tag.contains(nbtTagName + "|dummyEnchant")) {
tag.remove(nbtTagName + "|dummyEnchant");
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
for (Tag enchantment : enchantments.clone()) {
String id = (String) ((CompoundTag) enchantment).get("id").getValue();
if (id.isEmpty()) {

Datei anzeigen

@ -91,10 +91,9 @@ public class LegacyEnchantmentRewriter {
}
}
IntTag hideFlags = tag.get(nbtTagName + "|oldHideFlags");
IntTag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
if (hideFlags != null) {
tag.put(new IntTag("HideFlags", hideFlags.getValue()));
tag.remove(nbtTagName + "|oldHideFlags");
} else {
tag.remove("HideFlags");
}

Datei anzeigen

@ -547,14 +547,10 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
CompoundTag tag = item.getTag();
// Use tag to get original ID and data
if (tag != null) {
// Check for valid tag
if (tag.get(extraNbtTag) instanceof IntTag) {
rawId = (Integer) tag.get(extraNbtTag).getValue();
// Remove the tag
tag.remove(extraNbtTag);
gotRawIdFromTag = true;
}
Tag originalIdTag;
if (tag != null && (originalIdTag = tag.remove(extraNbtTag)) != null) {
rawId = (Integer) originalIdTag.getValue();
gotRawIdFromTag = true;
}
if (rawId == null) {
@ -947,12 +943,11 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
newEnchantments.add(enchantmentEntry);
}
ListTag noMapped = tag.get(extraNbtTag + "|Enchantments");
ListTag noMapped = tag.remove(extraNbtTag + "|Enchantments");
if (noMapped != null) {
for (Tag value : noMapped) {
newEnchantments.add(value);
}
tag.remove(extraNbtTag + "|Enchantments");
}
CompoundTag display = tag.get("display");
@ -960,7 +955,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
tag.put(display = new CompoundTag("display"));
}
ListTag oldLore = tag.get(extraNbtTag + "|OldLore");
ListTag oldLore = tag.remove(extraNbtTag + "|OldLore");
if (oldLore != null) {
ListTag lore = display.get("Lore");
if (lore == null) {
@ -968,7 +963,6 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
}
lore.setValue(oldLore.getValue());
tag.remove(extraNbtTag + "|OldLore");
} else if (tag.remove(extraNbtTag + "|DummyLore") != null) {
display.remove("Lore");
if (display.isEmpty()) {