mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 03:26:44 +01:00
Change how traits are obfuscated and obfuscate trait descriptions if you haven't discovered it yet
This commit is contained in:
parent
73159ececa
commit
c5349bd242
4 changed files with 44 additions and 24 deletions
|
@ -8,7 +8,6 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.minelittlepony.common.client.gui.Tooltip;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -65,10 +64,31 @@ public enum Trait {
|
|||
private final Identifier sprite;
|
||||
private final TraitGroup group;
|
||||
|
||||
private final Text tooltip;
|
||||
private final Text obfuscatedTooltip;
|
||||
|
||||
Trait(TraitGroup group) {
|
||||
this.id = Unicopia.id(name().toLowerCase());
|
||||
this.sprite = Unicopia.id("textures/gui/trait/" + name().toLowerCase() + ".png");
|
||||
this.group = group;
|
||||
|
||||
Formatting corruptionColor = getGroup().getCorruption() < -0.01F
|
||||
? Formatting.GREEN
|
||||
: getGroup().getCorruption() > 0.25F
|
||||
? Formatting.RED
|
||||
: Formatting.WHITE;
|
||||
|
||||
MutableText tooltipText = Text.translatable("gui.unicopia.trait.label",
|
||||
Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".name")
|
||||
).formatted(Formatting.YELLOW)
|
||||
.append(Text.translatable("gui.unicopia.trait.group", getGroup().name().toLowerCase()).formatted(Formatting.ITALIC, Formatting.GRAY))
|
||||
.append(Text.literal("\n\n").formatted(Formatting.WHITE)
|
||||
.append(Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".description").formatted(Formatting.GRAY))
|
||||
.append("\n")
|
||||
.append(Text.translatable("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor)));
|
||||
this.tooltip = tooltipText;
|
||||
this.obfuscatedTooltip = tooltipText.copy().formatted(Formatting.OBFUSCATED);
|
||||
|
||||
}
|
||||
|
||||
public Identifier getId() {
|
||||
|
@ -83,22 +103,12 @@ public enum Trait {
|
|||
return sprite;
|
||||
}
|
||||
|
||||
public Tooltip getTooltip() {
|
||||
Formatting corruptionColor = getGroup().getCorruption() < -0.01F
|
||||
? Formatting.GREEN
|
||||
: getGroup().getCorruption() > 0.25F
|
||||
? Formatting.RED
|
||||
: Formatting.WHITE;
|
||||
public Text getTooltip() {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
return Tooltip.of(
|
||||
Text.translatable("gui.unicopia.trait.label",
|
||||
Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".name")
|
||||
).formatted(Formatting.YELLOW)
|
||||
.append(Text.translatable("gui.unicopia.trait.group", getGroup().name().toLowerCase()).formatted(Formatting.ITALIC, Formatting.GRAY))
|
||||
.append(Text.literal("\n\n").formatted(Formatting.WHITE)
|
||||
.append(Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".description").formatted(Formatting.GRAY))
|
||||
.append("\n")
|
||||
.append(Text.translatable("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor))), 200);
|
||||
public Text getObfuscatedTooltip() {
|
||||
return obfuscatedTooltip;
|
||||
}
|
||||
|
||||
public static Collection<Trait> all() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.client.gui;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.*;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
@ -17,9 +18,11 @@ import net.minecraft.client.render.item.ItemRenderer;
|
|||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComponent {
|
||||
private static final Identifier UNKNOWN = Unicopia.id("textures/gui/trait/unknown.png");
|
||||
|
||||
private final SpellTraits traits;
|
||||
|
||||
|
@ -100,7 +103,7 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isKnown(Trait trait) {
|
||||
public static boolean isKnown(Trait trait) {
|
||||
return MinecraftClient.getInstance().player == null
|
||||
|| Pony.of(MinecraftClient.getInstance().player).getDiscoveries().isKnown(trait);
|
||||
}
|
||||
|
@ -111,11 +114,7 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp
|
|||
|
||||
int size = 12;
|
||||
|
||||
if (!isKnown(trait)) {
|
||||
trait = Trait.values()[MinecraftClient.getInstance().player.getRandom().nextInt(Trait.all().size())];
|
||||
}
|
||||
|
||||
RenderSystem.setShaderTexture(0, trait.getSprite());
|
||||
RenderSystem.setShaderTexture(0, isKnown(trait) ? trait.getSprite() : UNKNOWN);
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(xx, yy, itemRenderer.zOffset + 300.0F);
|
||||
|
|
|
@ -102,7 +102,18 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder {
|
|||
int left = x + column * colWidth + 3 + (addLabels && row > 0 ? colWidth : 0);
|
||||
int top = y + row * rowHeight + 3;
|
||||
|
||||
container.addButton(new IngredientButton(left, top, colWidth, rowHeight, entry, !addLabels || ii == 0 ? "" : "+", false));
|
||||
var button = container.addButton(new IngredientButton(left, top, colWidth, rowHeight, entry, !addLabels || ii == 0 ? "" : "+", false));
|
||||
|
||||
if (entry instanceof Traits traits) {
|
||||
final Trait trait = traits.trait;
|
||||
button.onClick(sender -> {
|
||||
if (MinecraftClient.getInstance().currentScreen instanceof SpellbookScreen spellbook) {
|
||||
spellbook.getState().setCurrentPageId(SpellbookChapterList.TRAIT_DEX_ID);
|
||||
spellbook.getTraitDex().pageTo(spellbook, trait);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
result.ifPresent(result -> {
|
||||
|
@ -263,7 +274,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder {
|
|||
|
||||
@Override
|
||||
public Tooltip getTooltip() {
|
||||
return trait.getTooltip();
|
||||
return Tooltip.of(ItemTraitsTooltipRenderer.isKnown(trait) ? trait.getTooltip() : trait.getObfuscatedTooltip(), 200);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in a new issue