From f91b26057e918d262bec0cccc2dd71afe5d56570 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Thu, 2 Jun 2022 11:17:04 -0400 Subject: [PATCH] advanced/regular tooltips --- .../recipe/ingredient/VillagerIngredient.java | 56 +++++++++---------- .../patchouli/BrainsweepProcessor.java | 3 +- .../assets/hexcasting/lang/en_us.json | 9 +-- .../fabric/interop/emi/VillagerEmiStack.java | 3 +- .../fabric/interop/rei/VillagerWidget.java | 3 +- .../interop/jei/BrainsweepRecipeCategory.java | 3 +- 6 files changed, 35 insertions(+), 42 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/VillagerIngredient.java b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/VillagerIngredient.java index 27c24bd1..dc6ce889 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/VillagerIngredient.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/VillagerIngredient.java @@ -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 getTooltip() { + public List getTooltip(boolean advanced) { List 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; diff --git a/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java b/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java index 1672a7c1..92739090 100644 --- a/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java +++ b/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java @@ -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; diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.json b/Common/src/main/resources/assets/hexcasting/lang/en_us.json index 1714548d..555dbd5f 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.json +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.json @@ -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", diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/VillagerEmiStack.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/VillagerEmiStack.java index cd90ecb9..c8b13a07 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/VillagerEmiStack.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/VillagerEmiStack.java @@ -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 diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/rei/VillagerWidget.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/rei/VillagerWidget.java index f342812a..9d0d0dbd 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/rei/VillagerWidget.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/rei/VillagerWidget.java @@ -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 diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java b/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java index 9fb0085a..f44bb4e3 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java @@ -71,7 +71,8 @@ public class BrainsweepRecipeCategory implements IRecipeCategory 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();