Added tooltips for unobtainable ores. (#2663)
This commit is contained in:
parent
a813368c5e
commit
c4625762d1
3 changed files with 24 additions and 7 deletions
|
@ -24,6 +24,7 @@
|
|||
|
||||
package techreborn.events;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -56,12 +57,18 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
|
||||
public static final Map<Item, Boolean> ITEM_ID = Maps.newHashMap();
|
||||
private static final Map<Block, OreDistribution> ORE_DISTRIBUTION_MAP = Maps.newHashMap();
|
||||
private static final List<Block> UNOBTAINABLE_ORES = Lists.newLinkedList();
|
||||
|
||||
public static void setup() {
|
||||
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
|
||||
|
||||
for (TRContent.Ores ore : TRContent.Ores.values()) {
|
||||
if (ore.isDeepslate()) continue;
|
||||
if (ore.isDeepslate()) {
|
||||
TRContent.Ores normal = ore.getUnDeepslate();
|
||||
if (normal.distribution != null && normal.distribution.dimension != TargetDimension.OVERWORLD)
|
||||
UNOBTAINABLE_ORES.add(ore.block);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ore.distribution != null) {
|
||||
ORE_DISTRIBUTION_MAP.put(ore.block, ore.distribution);
|
||||
|
@ -103,18 +110,19 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
tooltipLines.addAll(ToolTipAssistUtils.getUpgradeStats(TRContent.Upgrades.valueOf(upgrade.name.toUpperCase()), stack.getCount(), Screen.hasShiftDown()));
|
||||
}
|
||||
|
||||
Text text = null;
|
||||
if (UNOBTAINABLE_ORES.contains(block))
|
||||
text = new TranslatableText("techreborn.tooltip.unobtainable");
|
||||
OreDistribution oreDistribution = ORE_DISTRIBUTION_MAP.get(block);
|
||||
|
||||
if (oreDistribution != null) {
|
||||
Text text = switch (oreDistribution.dimension) {
|
||||
if (oreDistribution != null && text == null) {
|
||||
text = switch (oreDistribution.dimension) {
|
||||
case OVERWORLD -> getOverworldOreText(oreDistribution);
|
||||
case END -> new TranslatableText("techreborn.tooltip.ores.end");
|
||||
case NETHER -> new TranslatableText("techreborn.tooltip.ores.nether");
|
||||
};
|
||||
|
||||
if (text != null)
|
||||
tooltipLines.add(text.copy().formatted(Formatting.AQUA));
|
||||
}
|
||||
if (text != null)
|
||||
tooltipLines.add(text.copy().formatted(Formatting.AQUA));
|
||||
}
|
||||
|
||||
private static boolean isTRItem(Item item) {
|
||||
|
|
|
@ -381,6 +381,8 @@ public class TRContent {
|
|||
|
||||
private final static Map<Ores, Ores> deepslateMap = new HashMap<>();
|
||||
|
||||
private final static Map<Ores, Ores> unDeepslateMap = new HashMap<>();
|
||||
|
||||
public enum Ores implements ItemConvertible {
|
||||
// when changing ores also change data/techreborn/tags/items/ores.json for correct root advancement display
|
||||
// as well as data/minecraft/tags/blocks for correct mining level
|
||||
|
@ -432,6 +434,7 @@ public class TRContent {
|
|||
Ores(TRContent.Ores stoneOre) {
|
||||
this((OreDistribution) null);
|
||||
deepslateMap.put(stoneOre, this);
|
||||
unDeepslateMap.put(this, stoneOre);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -444,6 +447,11 @@ public class TRContent {
|
|||
return deepslateMap.get(this);
|
||||
}
|
||||
|
||||
public TRContent.Ores getUnDeepslate() {
|
||||
Preconditions.checkArgument(isDeepslate());
|
||||
return unDeepslateMap.get(this);
|
||||
}
|
||||
|
||||
public boolean isDeepslate() {
|
||||
return name.startsWith("deepslate_");
|
||||
}
|
||||
|
|
|
@ -875,6 +875,7 @@
|
|||
"techreborn.tooltip.ores.overworld" : "Can be found at y levels %s < %s",
|
||||
"techreborn.tooltip.ores.nether" : "Can be found in the nether",
|
||||
"techreborn.tooltip.ores.end" : "Can be found in the end",
|
||||
"techreborn.tooltip.unobtainable": "Unobtainable in Survival Mode",
|
||||
|
||||
"_comment23": "ManualUI",
|
||||
"techreborn.manual.wiki": "Online wiki",
|
||||
|
|
Loading…
Add table
Reference in a new issue