Skip to content

Commit

Permalink
Display a tooltip for chemicals that are immune to decay in waste bar…
Browse files Browse the repository at this point in the history
…rels, and also display the chemical's registry name if advanced item tooltips are turned on
  • Loading branch information
pupnewfster committed Dec 20, 2021
1 parent 6347a88 commit 491adcc
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/datagen/generated/mekanism/.cache/cache
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ f5e3eb6799a15d0b72969547614dfc51dac53419 assets/mekanism/blockstates/tin_ore.jso
8b4570f0148089999c54bb9695f9c94346455c7a assets/mekanism/blockstates/uranium_hexafluoride.json
246c1904e7699b01a3a20f2a2b79b35b5d99aec9 assets/mekanism/blockstates/uranium_ore.json
40c623e2db3159e7355b25f422c719294eca4b64 assets/mekanism/blockstates/uranium_oxide.json
565b289ef4403db1e5fedc86400cbd13be1141d2 assets/mekanism/lang/en_ud.json
9b1ea7c7d7a7507cf24ada23852844e70aa2af70 assets/mekanism/lang/en_us.json
9edb928604258824c3b67a00639b7ad2b054660f assets/mekanism/lang/en_ud.json
cf1b2bcfaacbe6db87356fdf72381e9aad483041 assets/mekanism/lang/en_us.json
beea3be5a8af802be66d456a7a648678bede0f02 assets/mekanism/models/block/brine.json
beea3be5a8af802be66d456a7a648678bede0f02 assets/mekanism/models/block/chlorine.json
beea3be5a8af802be66d456a7a648678bede0f02 assets/mekanism/models/block/ethene.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@
"temperature.mekanism.rankine.short": "\u1D1A",
"temperature.mekanism.short": "%s :d\u026F\u01DD\u27D8",
"tooltip.mekanism.bucket_mode": "%s :\u01DDpoW \u0287\u01DD\u029E\u0254n\u15FA",
"tooltip.mekanism.decay_immune": "\uA781\u01DD\u0279\u0279\u0250\u15FA \u01DD\u0287s\u0250M \u01DD\u028C\u1D09\u0287\u0254\u0250o\u1D09p\u0250\u1D1A \u0250 \u01DDp\u1D09su\u1D09 \u028E\u0250\u0254\u01DDp \u0287ou \uA781\uA781\u1D09M",
"tooltip.mekanism.fire_mode": "%s :\u01DDpoW \u01DD\u0279\u1D09\u2132",
"tooltip.mekanism.flowing": "%s :\u1D77u\u1D09\u028Do\uA781\u2132",
"tooltip.mekanism.hold_for_description": "\u02D9uo\u1D09\u0287d\u1D09\u0279\u0254s\u01DDp \u0250 \u0279o\u025F %s p\uA781oH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@
"temperature.mekanism.rankine.short": "R",
"temperature.mekanism.short": "Temp: %s",
"tooltip.mekanism.bucket_mode": "Bucket Mode: %s",
"tooltip.mekanism.decay_immune": "Will not decay inside a Radioactive Waste Barrel",
"tooltip.mekanism.fire_mode": "Fire Mode: %s",
"tooltip.mekanism.flowing": "Flowing: %s",
"tooltip.mekanism.hold_for_description": "Hold %s for a description.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ private void addMisc() {
add(MekanismLang.PROCESS_RATE, "Process Rate: %s");
add(MekanismLang.PROCESS_RATE_MB, "Process Rate: %s mB/t");
add(MekanismLang.TICKS_REQUIRED, "Ticks Required: %s");
add(MekanismLang.DECAY_IMMUNE, "Will not decay inside a Radioactive Waste Barrel");
//Gui stuff
add(MekanismLang.WIDTH, "Width");
add(MekanismLang.HEIGHT, "Height");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import mekanism.common.network.to_server.PacketDropperUse.TankType;
import mekanism.common.util.ChemicalUtil;
import mekanism.common.util.text.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.text.ITextComponent;

Expand Down Expand Up @@ -49,7 +50,7 @@ protected TankType getType(STACK stack) {
@Override
protected List<ITextComponent> getTooltip(STACK stack) {
List<ITextComponent> tooltips = super.getTooltip(stack);
tooltips.addAll(ChemicalUtil.getAttributeTooltips(stack.getType()));
ChemicalUtil.addChemicalDataToTooltip(tooltips, stack.getType(), Minecraft.getInstance().options.advancedItemTooltips);
return tooltips;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import mekanism.common.network.to_server.PacketDropperUse.TankType;
import mekanism.common.util.ChemicalUtil;
import mekanism.common.util.text.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.text.ITextComponent;

Expand Down Expand Up @@ -96,7 +97,7 @@ public List<ITextComponent> getTooltipText() {
} else {
list.add(MekanismLang.GENERIC_STORED_MB.translate(tank.getType(), TextUtils.format(amount)));
}
list.addAll(ChemicalUtil.getAttributeTooltips(tank.getType()));
ChemicalUtil.addChemicalDataToTooltip(list, tank.getType(), Minecraft.getInstance().options.advancedItemTooltips);
return list;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/mekanism/client/jei/ChemicalStackRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ public List<ITextComponent> getTooltip(@Nonnull STACK stack, ITooltipFlag toolti
if (chemical.isEmptyType()) {
return Collections.emptyList();
}
List<ITextComponent> tooltip = new ArrayList<>();
tooltip.add(TextComponentUtil.build(chemical));
List<ITextComponent> tooltips = new ArrayList<>();
tooltips.add(TextComponentUtil.build(chemical));
if (tooltipMode == TooltipMode.SHOW_AMOUNT_AND_CAPACITY) {
tooltip.add(MekanismLang.JEI_AMOUNT_WITH_CAPACITY.translateColored(EnumColor.GRAY, TextUtils.format(stack.getAmount()), TextUtils.format(capacityMb)));
tooltips.add(MekanismLang.JEI_AMOUNT_WITH_CAPACITY.translateColored(EnumColor.GRAY, TextUtils.format(stack.getAmount()), TextUtils.format(capacityMb)));
} else if (tooltipMode == TooltipMode.SHOW_AMOUNT) {
tooltip.add(MekanismLang.GENERIC_MB.translateColored(EnumColor.GRAY, TextUtils.format(stack.getAmount())));
tooltips.add(MekanismLang.GENERIC_MB.translateColored(EnumColor.GRAY, TextUtils.format(stack.getAmount())));
}
tooltip.addAll(ChemicalUtil.getAttributeTooltips(stack.getType()));
return tooltip;
ChemicalUtil.addChemicalDataToTooltip(tooltips, stack.getType(), tooltipFlag.isAdvanced());
return tooltips;
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mekanism/common/MekanismLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public enum MekanismLang implements ILangEntry {
FREE_RUNNERS_STORED("tooltip", "stored.free_runners"),
FLAMETHROWER_STORED("tooltip", "stored.flamethrower"),
JETPACK_STORED("tooltip", "stored.jetpack"),
DECAY_IMMUNE("tooltip", "decay_immune"),
//Gui stuff
HEIGHT("gui", "height"),
WIDTH("gui", "width"),
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/mekanism/common/tags/MekanismTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ private Gases() {
}

public static final INamedTag<Gas> WATER_VAPOR = tag("water_vapor");
//TODO - 10.1: Think of some way via tooltips or something to portray easier which gases won't decay
// rather than forcing people to know or use a dictionary
public static final INamedTag<Gas> WASTE_BARREL_DECAY_BLACKLIST = tag("waste_barrel_decay_blacklist");

private static INamedTag<Gas> tag(String name) {
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/mekanism/common/util/ChemicalUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mekanism.common.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
Expand Down Expand Up @@ -34,14 +33,19 @@
import mekanism.api.providers.IInfuseTypeProvider;
import mekanism.api.providers.IPigmentProvider;
import mekanism.api.providers.ISlurryProvider;
import mekanism.api.text.EnumColor;
import mekanism.api.text.TextComponentUtil;
import mekanism.common.MekanismLang;
import mekanism.common.capabilities.Capabilities;
import mekanism.common.content.network.distribution.ChemicalHandlerTarget;
import mekanism.common.registries.MekanismBlocks;
import mekanism.common.tags.MekanismTags;
import mekanism.common.tier.ChemicalTankTier;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.capabilities.Capability;

/**
Expand Down Expand Up @@ -248,10 +252,21 @@ public static <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<
return false;
}

public static List<ITextComponent> getAttributeTooltips(Chemical<?> chemical) {
List<ITextComponent> list = new ArrayList<>();
chemical.getAttributes().forEach(attr -> attr.addTooltipText(list));
return list;
public static void addAttributeTooltips(List<ITextComponent> tooltips, Chemical<?> chemical) {
chemical.getAttributes().forEach(attr -> attr.addTooltipText(tooltips));
}

public static void addChemicalDataToTooltip(List<ITextComponent> tooltips, Chemical<?> chemical, boolean advanced) {
if (!chemical.isEmptyType()) {
addAttributeTooltips(tooltips, chemical);
if (chemical instanceof Gas && ((Gas) chemical).isIn(MekanismTags.Gases.WASTE_BARREL_DECAY_BLACKLIST)) {
tooltips.add(MekanismLang.DECAY_IMMUNE.translateColored(EnumColor.AQUA));
}
if (advanced) {
//If advanced tooltips are on, display the registry name
tooltips.add(TextComponentUtil.build(TextFormatting.DARK_GRAY, chemical.getRegistryName()));
}
}
}

public static void emit(IChemicalTank<?, ?> tank, TileEntity from) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mekanism/common/util/StorageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void addStoredChemical(@Nonnull ItemStack stack, @Nonnull List<ITextComponent> t
STACK chemicalInTank = handler.getChemicalInTank(tank);
tooltip.add(storedFunction.apply(chemicalInTank));
if (showAttributes) {
tooltip.addAll(ChemicalUtil.getAttributeTooltips(chemicalInTank.getType()));
ChemicalUtil.addAttributeTooltips(tooltip, chemicalInTank.getType());
}
}
} else if (showMissingCap) {
Expand Down

0 comments on commit 491adcc

Please sign in to comment.