advanced/regular tooltips

This commit is contained in:
yrsegal@gmail.com 2022-06-02 11:17:04 -04:00
parent d188a20366
commit f91b26057e
6 changed files with 35 additions and 42 deletions

View file

@ -42,8 +42,11 @@ public record VillagerIngredient(
boolean addedAny = false;
if (profession != null) {
component.append(new TranslatableComponent("entity.minecraft.villager." + profession.getPath()));
if (minLevel >= 5) {
component.append(new TranslatableComponent("merchant.level.5"));
addedAny = true;
} else if (minLevel > 1) {
component.append(new TranslatableComponent("merchant.level." + minLevel));
addedAny = true;
}
@ -54,48 +57,39 @@ public record VillagerIngredient(
addedAny = true;
}
if (minLevel >= 5) {
if (profession != null) {
if (addedAny)
component.append(" ");
component.append(new TranslatableComponent("merchant.level.5"));
addedAny = true;
} else if (minLevel > 1) {
component.append(new TranslatableComponent("entity.minecraft.villager." + profession.getPath()));
} else {
if (addedAny)
component.append(" ");
component.append(new TranslatableComponent("merchant.level." + minLevel));
addedAny = true;
component.append(EntityType.VILLAGER.getDescription());
}
if (addedAny)
component.append(" ");
component.append(EntityType.VILLAGER.getDescription());
return component;
}
public List<Component> getTooltip() {
public List<Component> getTooltip(boolean advanced) {
List<Component> tooltip = new ArrayList<>();
tooltip.add(EntityType.VILLAGER.getDescription());
tooltip.add(name());
if (profession != null) {
var professionKey = "entity.minecraft.villager." + profession.getPath();
tooltip.add(new TranslatableComponent("hexcasting.tooltip.brainsweep.profession",
new TranslatableComponent(professionKey)));
if (advanced) {
if (minLevel >= 5) {
tooltip.add(new TranslatableComponent("hexcasting.tooltip.brainsweep.level", 5).withStyle(ChatFormatting.DARK_GRAY));
} else if (minLevel > 1) {
tooltip.add(new TranslatableComponent("hexcasting.tooltip.brainsweep.min_level", minLevel).withStyle(ChatFormatting.DARK_GRAY));
}
if (biome != null) {
tooltip.add(new TextComponent(biome.toString()).withStyle(ChatFormatting.DARK_GRAY));
}
if (profession != null) {
tooltip.add(new TextComponent(profession.toString()).withStyle(ChatFormatting.DARK_GRAY));
}
}
if (biome != null) {
var biomeKey = "biome.minecraft." + biome.getPath();
tooltip.add(new TranslatableComponent("hexcasting.tooltip.brainsweep.biome",
new TranslatableComponent(biomeKey)));
}
if (minLevel >= 5)
tooltip.add(new TranslatableComponent("hexcasting.tooltip.brainsweep.level",
new TranslatableComponent("merchant.level.5")));
else if (minLevel > 1)
tooltip.add(new TranslatableComponent("hexcasting.tooltip.brainsweep.min_level",
new TranslatableComponent("merchant.level." + minLevel)));
tooltip.add(getModNameComponent());
return tooltip;

View file

@ -58,7 +58,8 @@ public class BrainsweepProcessor implements IComponentProcessor {
return IVariable.wrap(iHatePatchouli);
}
case "entityTooltip" -> {
return IVariable.wrapList(this.recipe.villagerIn().getTooltip().stream().map(IVariable::from).toList());
Minecraft mc = Minecraft.getInstance();
return IVariable.wrapList(this.recipe.villagerIn().getTooltip(mc.options.advancedItemTooltips).stream().map(IVariable::from).toList());
}
default -> {
return null;

View file

@ -130,13 +130,8 @@
"hexcasting.tooltip.lens.akashic.bookshelf.location": "Record at %s",
"hexcasting.tooltip.lens.akashic.record.count": "%s iotas stored",
"hexcasting.tooltip.lens.akashic.record.count.single": "%s iota stored",
"hexcasting.tooltip.brainsweep.profession": "Profession: %s",
"hexcasting.tooltip.brainsweep.profession.any": "Profession: Any",
"hexcasting.tooltip.brainsweep.biome": "Biome: %s",
"hexcasting.tooltip.brainsweep.biome.any": "Biome: Any",
"hexcasting.tooltip.brainsweep.min_level": "Rank: %s or higher",
"hexcasting.tooltip.brainsweep.level": "Rank: %s",
"hexcasting.tooltip.brainsweep.level.any": "Rank: Any",
"hexcasting.tooltip.brainsweep.min_level": "Level %s or higher",
"hexcasting.tooltip.brainsweep.level": "Level %s",
"hexcasting.tooltip.brainsweep.product": "Mindless Body",
"hexcasting.spelldata.onitem": "Contains: %s",
"hexcasting.spelldata.anything": "Anything",

View file

@ -92,7 +92,8 @@ public class VillagerEmiStack extends EmiStack {
if (mindless)
return List.of(new TranslatableComponent("hexcasting.tooltip.brainsweep.product"), ingredient.getModNameComponent());
return ingredient.getTooltip();
Minecraft mc = Minecraft.getInstance();
return ingredient.getTooltip(mc.options.advancedItemTooltips);
}
@Override

View file

@ -72,7 +72,8 @@ public class VillagerWidget extends Widget {
@NotNull
@Override
public Tooltip getTooltip(Point mouse) {
return Tooltip.create(mouse, villager.getTooltip());
Minecraft mc = Minecraft.getInstance();
return Tooltip.create(mouse, villager.getTooltip(mc.options.advancedItemTooltips));
}
@Override

View file

@ -71,7 +71,8 @@ public class BrainsweepRecipeCategory implements IRecipeCategory<BrainsweepRecip
public @NotNull List<Component> getTooltipStrings(@NotNull BrainsweepRecipe recipe,
@NotNull IRecipeSlotsView recipeSlotsView, double mouseX, double mouseY) {
if (37 <= mouseX && mouseX <= 37 + 26 && 19 <= mouseY && mouseY <= 19 + 48) {
return recipe.villagerIn().getTooltip();
Minecraft mc = Minecraft.getInstance();
return recipe.villagerIn().getTooltip(mc.options.advancedItemTooltips);
}
return Collections.emptyList();