Skip to content

Commit

Permalink
Improve modifier tooltips
Browse files Browse the repository at this point in the history
Bookmark renderer and crystal both show modifier descriptions now (#5222)
Modifier crystal now shows modifier ID in advanced tooltips
  • Loading branch information
KnightMiner committed May 13, 2024
1 parent 3dc3b23 commit d75a16e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public List<Component> getTooltip(ModifierEntry entry, TooltipFlag flag) {
List<Component> list = new ArrayList<>();
// not using the main method as that applies color
list.add(Component.translatable(WRAPPER_KEY, Component.translatable(entry.getModifier().getTranslationKey())));
list.addAll(entry.getModifier().getDescriptionList());
if (flag.isAdvanced()) {
list.add((Component.literal(entry.getId().toString())).withStyle(ChatFormatting.DARK_GRAY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.world.level.Level;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.library.modifiers.ModifierId;
import slimeknights.tconstruct.library.modifiers.ModifierManager;
import slimeknights.tconstruct.library.recipe.modifiers.ModifierRecipeLookup;
import slimeknights.tconstruct.library.utils.Util;
import slimeknights.tconstruct.tools.TinkerModifiers;
Expand All @@ -22,6 +23,7 @@
public class ModifierCrystalItem extends Item {
private static final Component TOOLTIP_MISSING = TConstruct.makeTranslation("item", "modifier_crystal.missing").withStyle(ChatFormatting.GRAY);
private static final Component TOOLTIP_APPLY = TConstruct.makeTranslation("item", "modifier_crystal.tooltip").withStyle(ChatFormatting.GRAY);
private static final String MODIFIER_KEY = TConstruct.makeTranslationKey("item", "modifier_crystal.modifier_id");
private static final String TAG_MODIFIER = "modifier";
public ModifierCrystalItem(Properties props) {
super(props);
Expand All @@ -43,10 +45,16 @@ public Component getName(ItemStack stack) {

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag advanced) {
if (getModifier(stack) != null) {
ModifierId id = getModifier(stack);
if (id != null) {
if (ModifierManager.INSTANCE.contains(id)) {
tooltip.addAll(ModifierManager.INSTANCE.get(id).getDescriptionList());
}
tooltip.add(TOOLTIP_APPLY);
}
else {
if (advanced.isAdvanced()) {
tooltip.add((Component.translatable(MODIFIER_KEY, id.toString())).withStyle(ChatFormatting.DARK_GRAY));
}
} else {
tooltip.add(TOOLTIP_MISSING);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/tconstruct/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
"item.tconstruct.modifier_crystal.format": "%s Crystal",
"item.tconstruct.modifier_crystal.missing": "Missing or invalid NBT defining the modifier type",
"item.tconstruct.modifier_crystal.tooltip": "Apply to a tool to gain 1 level of the modifier, consuming the appropriate slots.",
"item.tconstruct.modifier_crystal.modifier_id": "Modifier ID: %s",

"item.tconstruct.creative_slot": "Creative Slot",
"item.tconstruct.creative_slot.upgrades": "Creative Upgrade",
Expand Down

0 comments on commit d75a16e

Please sign in to comment.