Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed item tooltip #3

Open
wants to merge 1 commit into
base: 1.15.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
mod_version=2.0
mod_version=2.1
modid=simply_trophies
mc_version=1.15.2
forge_version=31.1.0
forge_version=31.2.37
mapping=20200202
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static class ClientConfig {
public static ForgeConfigSpec.BooleanValue NO_TEISR;
public static ForgeConfigSpec.BooleanValue NO_TESR;
public static ForgeConfigSpec.BooleanValue TOOLTIP_CREDITS;
public static ForgeConfigSpec.BooleanValue SHOW_ITEMNAME;
public static ForgeConfigSpec.BooleanValue SHOW_ITEMTOOLTIP;
public static ForgeConfigSpec.BooleanValue SHOW_EARNEDAT;
public static ForgeConfigSpec.DoubleValue SCALE;

Expand Down Expand Up @@ -50,6 +52,12 @@ public static class ClientConfig {
SHOW_EARNEDAT = builder
.comment("Show the date and time you earned the trophy on the tooltip and on hover.")
.define("show earnedat",true);
SHOW_ITEMNAME = builder
.comment("Show name of the displayed item.")
.define("show itemname", true);
SHOW_ITEMTOOLTIP = builder
.comment("Show tooltip of the displayed item.")
.define("show tooltip", false);
SCALE = builder
.comment("Scale of items on trophies")
.defineInRange("scale",1.5,0,Double.MAX_VALUE);
Expand Down
40 changes: 22 additions & 18 deletions src/main/java/tfar/simpletrophies/common/item/ItemSimpleTrophy.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.ArrayList;
import java.util.List;

import static tfar.simpletrophies.common.config.TrophyConfig.ClientConfig.SHOW_EARNEDAT;
import static tfar.simpletrophies.common.config.TrophyConfig.ClientConfig.*;

public class ItemSimpleTrophy extends BlockItem {
public ItemSimpleTrophy(Block block, Properties properties) {
Expand Down Expand Up @@ -82,32 +82,36 @@ public void addInformation(ItemStack stack, @Nullable World world, List<ITextCom
ItemStack displayedStack = TrophyHelpers.getDisplayedStack(stack);
if(!displayedStack.isEmpty()) {
//add the "Displayed" tooltip
tooltip.add(new TranslationTextComponent("simple_trophies.misc.tooltip.displaying",displayedStack.getDisplayName()).applyTextStyles(displayedStack.getRarity().color));

//add additional debugging information
if(mistake.isAdvanced()) {
StringBuilder bob = new StringBuilder();
bob.append(" ");
bob.append(TextFormatting.DARK_GRAY);
bob.append(displayedStack.getItem().getRegistryName());
bob.append(" (#");
bob.append(Item.getIdFromItem(displayedStack.getItem()));
bob.append('/');
if(SHOW_ITEMNAME.get()) {
tooltip.add(new TranslationTextComponent("simple_trophies.misc.tooltip.displaying",displayedStack.getDisplayName()).applyTextStyles(displayedStack.getRarity().color));

//add additional debugging information
if(mistake.isAdvanced()) {
StringBuilder bob = new StringBuilder();
bob.append(" ");
bob.append(TextFormatting.DARK_GRAY);
bob.append(displayedStack.getItem().getRegistryName());
bob.append(" (#");
bob.append(Item.getIdFromItem(displayedStack.getItem()));
bob.append('/');
// bob.append(displayedStack.getItemDamage());
bob.append(')');
tooltip.add(new StringTextComponent(bob.toString()));
bob.append(')');
tooltip.add(new StringTextComponent(bob.toString()));
}
}

//add the item itself's tooltip. Why not?
List<ITextComponent> displayedTooltip = new ArrayList<>();
displayedStack.getItem().addInformation(displayedStack, world, displayedTooltip, mistake);
displayedTooltip.forEach(s -> tooltip.add(new StringTextComponent(" " + s)));
if(SHOW_ITEMTOOLTIP.get()) {
List<ITextComponent> displayedTooltip = new ArrayList<>();
displayedStack.getItem().addInformation(displayedStack, world, displayedTooltip, mistake);
displayedTooltip.forEach(s -> tooltip.add(new StringTextComponent(" ").appendSibling(s)));
}
}


long time = TrophyHelpers.getEarnTime(stack);
if(SHOW_EARNEDAT.get() && time != 0) {
tooltip.add(new TranslationTextComponent("simple_trophies.misc.earnedAt", DateHelpers.epochToString(time)));
tooltip.add(new TranslationTextComponent("simple_trophies.misc.earnedAt", DateHelpers.epochToString(time)).applyTextStyle(TextFormatting.GRAY));
}

super.addInformation(stack, world, tooltip, mistake);
Expand Down