Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-16 04:50:10 +01:00
Fix 1.21->1.20.5 enchantment lore format and add show_in_tooltip check
Fixes #877
Dieser Commit ist enthalten in:
Ursprung
47b1508f66
Commit
db47040543
@ -84,7 +84,8 @@ public class StructuredEnchantmentRewriter {
|
|||||||
|
|
||||||
final Enchantments enchantments = enchantmentsData.value();
|
final Enchantments enchantments = enchantmentsData.value();
|
||||||
final List<Tag> loreToAdd = new ArrayList<>();
|
final List<Tag> loreToAdd = new ArrayList<>();
|
||||||
boolean changed = false;
|
boolean updatedLore = false;
|
||||||
|
boolean removedEnchantments = false;
|
||||||
|
|
||||||
final ObjectIterator<Int2IntMap.Entry> iterator = enchantments.enchantments().int2IntEntrySet().iterator();
|
final ObjectIterator<Int2IntMap.Entry> iterator = enchantments.enchantments().int2IntEntrySet().iterator();
|
||||||
final List<PendingIdChange> updatedIds = new ArrayList<>();
|
final List<PendingIdChange> updatedIds = new ArrayList<>();
|
||||||
@ -101,13 +102,15 @@ public class StructuredEnchantmentRewriter {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removedEnchantments = true;
|
||||||
|
|
||||||
final Tag description = descriptionSupplier.get(id, level);
|
final Tag description = descriptionSupplier.get(id, level);
|
||||||
if (description != null) {
|
if (description != null && enchantments.showInTooltip()) {
|
||||||
if (!changed) {
|
if (!updatedLore) {
|
||||||
// Backup original before doing modifications
|
// Backup original before doing modifications
|
||||||
final CompoundTag customData = data.computeIfAbsent(StructuredDataKey.CUSTOM_DATA, $ -> new CompoundTag()).value();
|
final CompoundTag customData = data.computeIfAbsent(StructuredDataKey.CUSTOM_DATA, $ -> new CompoundTag()).value();
|
||||||
itemRewriter.saveListTag(customData, asTag(enchantments), key.identifier());
|
itemRewriter.saveListTag(customData, asTag(enchantments), key.identifier());
|
||||||
changed = true;
|
updatedLore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loreToAdd.add(description);
|
loreToAdd.add(description);
|
||||||
@ -123,8 +126,7 @@ public class StructuredEnchantmentRewriter {
|
|||||||
enchantments.add(change.mappedId(), change.level());
|
enchantments.add(change.mappedId(), change.level());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loreToAdd.isEmpty()) {
|
if (!removedEnchantments) {
|
||||||
// No removed enchantments
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
|||||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||||
|
import com.viaversion.viaversion.libs.mcstructs.core.TextFormatting;
|
||||||
import com.viaversion.viaversion.libs.mcstructs.text.components.StringComponent;
|
import com.viaversion.viaversion.libs.mcstructs.text.components.StringComponent;
|
||||||
import com.viaversion.viaversion.libs.mcstructs.text.components.TranslationComponent;
|
import com.viaversion.viaversion.libs.mcstructs.text.components.TranslationComponent;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3;
|
||||||
@ -177,6 +178,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
final var component = SerializerVersion.V1_20_5.toComponent(description);
|
final var component = SerializerVersion.V1_20_5.toComponent(description);
|
||||||
|
component.getStyle().setItalic(false);
|
||||||
|
component.getStyle().setFormatting(TextFormatting.GRAY);
|
||||||
component.getSiblings().add(new StringComponent(" "));
|
component.getSiblings().add(new StringComponent(" "));
|
||||||
component.getSiblings().add(new TranslationComponent(EnchantmentRewriter.ENCHANTMENT_LEVEL_TRANSLATION.formatted(level)));
|
component.getSiblings().add(new TranslationComponent(EnchantmentRewriter.ENCHANTMENT_LEVEL_TRANSLATION.formatted(level)));
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren