Skip to content

Commit

Permalink
tooltip improvements and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 committed Sep 10, 2024
1 parent 3eb8276 commit 7f76d01
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 57 deletions.
29 changes: 8 additions & 21 deletions src/main/java/gregtech/api/capability/IPropertyFluidFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import gregtech.api.fluids.FluidState;
import gregtech.api.fluids.attribute.AttributedFluid;
import gregtech.api.fluids.attribute.FluidAttribute;
import gregtech.client.utils.TooltipHelper;

import net.minecraft.client.resources.I18n;
import net.minecraftforge.fluids.Fluid;
Expand Down Expand Up @@ -70,27 +69,15 @@ default int getPriority() {
/**
* Append tooltips about containment info
*
* @param tooltip the tooltip to append to
* @param showToolsInfo if the "hold shift" line should mention tool info
* @param showTemperatureInfo if the temperature information should be displayed
* @param tooltip the tooltip to append to
*/
default void appendTooltips(@NotNull List<String> tooltip, boolean showToolsInfo, boolean showTemperatureInfo) {
if (TooltipHelper.isShiftDown()) {
if (showTemperatureInfo) {
tooltip.add(I18n.format("gregtech.fluid_pipe.max_temperature", getMaxFluidTemperature()));
tooltip.add(I18n.format("gregtech.fluid_pipe.min_temperature", getMinFluidTemperature()));
}
if (isGasProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.gas_proof"));
else tooltip.add(I18n.format("gregtech.fluid_pipe.not_gas_proof"));
if (isPlasmaProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.plasma_proof"));
getContainedAttributes().forEach(a -> a.appendContainerTooltips(tooltip));
} else if (isGasProof() || isPlasmaProof() || !getContainedAttributes().isEmpty()) {
if (showToolsInfo) {
tooltip.add(I18n.format("gregtech.tooltip.tool_fluid_hold_shift"));
} else {
tooltip.add(I18n.format("gregtech.tooltip.fluid_pipe_hold_shift"));
}
}
default void appendTooltips(@NotNull List<String> tooltip) {
tooltip.add(I18n.format("gregtech.fluid_pipe.max_temperature", getMaxFluidTemperature()));
tooltip.add(I18n.format("gregtech.fluid_pipe.min_temperature", getMinFluidTemperature()));
if (isGasProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.gas_proof"));
else tooltip.add(I18n.format("gregtech.fluid_pipe.not_gas_proof"));
if (isPlasmaProof()) tooltip.add(I18n.format("gregtech.fluid_pipe.plasma_proof"));
getContainedAttributes().forEach(a -> a.appendContainerTooltips(tooltip));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ public static Collection<WorldPipeNetNode> getNodesForTile(PipeTileEntity tile)
@Override
public void addInformation(@NotNull ItemStack stack, World worldIn, @NotNull List<String> tooltip,
@NotNull ITooltipFlag flagIn) {
getHandler(stack).addInformation(stack, worldIn, tooltip, flagIn, getStructure());
if (getStructure() instanceof IPipeChanneledStructure channeledStructure) {
if (channeledStructure.getChannelCount() > 1)
tooltip.add(I18n.format("gregtech.pipe.channels", channeledStructure.getChannelCount()));
}
getHandler(stack).addInformation(stack, worldIn, tooltip, flagIn, getStructure());
if (TooltipHelper.isShiftDown()) {
tooltip.add(I18n.format(getConnectLangKey()));
tooltip.add(I18n.format("gregtech.tool_action.screwdriver.access_covers"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gregtech/api/items/metaitem/MetaItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ public void addInformation(@NotNull ItemStack itemStack, @Nullable World worldIn

if (fluidHandler instanceof IFilteredFluidContainer filtered &&
filtered.getFilter() instanceof IPropertyFluidFilter propertyFilter) {
propertyFilter.appendTooltips(lines, false, true);
propertyFilter.appendTooltips(lines);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ public static void register() {
.color(0xE1B454).iconSet(METALLIC)
.flags(DECOMPOSITION_BY_ELECTROLYZING)
.components(Manganese, 1, Phosphorus, 1)
.cableProperties(GTValues.V[GTValues.LV], 2, GTValues.V[GTValues.ULV], 500)
.cableProperties(GTValues.V[GTValues.LV], 2, GTValues.V[GTValues.ULV], Integer.MAX_VALUE)
.blast(1200, GasTier.LOW)
.build();

Expand All @@ -1351,7 +1351,7 @@ public static void register() {
.color(0x331900).iconSet(METALLIC)
.flags(DECOMPOSITION_BY_ELECTROLYZING)
.components(Magnesium, 1, Boron, 2)
.cableProperties(GTValues.V[GTValues.MV], 4, GTValues.V[GTValues.LV], 500)
.cableProperties(GTValues.V[GTValues.MV], 4, GTValues.V[GTValues.LV], Integer.MAX_VALUE)
.blast(b -> b
.temp(2500, GasTier.LOW)
.blastStats(VA[HV], 1000)
Expand All @@ -1364,7 +1364,7 @@ public static void register() {
.color(0x555555).iconSet(SHINY)
.flags(DECOMPOSITION_BY_ELECTROLYZING)
.components(Mercury, 1, Barium, 2, Calcium, 2, Copper, 3, Oxygen, 8)
.cableProperties(GTValues.V[GTValues.HV], 4, GTValues.V[GTValues.MV], 500)
.cableProperties(GTValues.V[GTValues.HV], 4, GTValues.V[GTValues.MV], Integer.MAX_VALUE)
.blast(b -> b
.temp(3300, GasTier.LOW)
.blastStats(VA[HV], 1500)
Expand All @@ -1377,7 +1377,7 @@ public static void register() {
.color(0x008700).iconSet(SHINY)
.flags(DECOMPOSITION_BY_CENTRIFUGING)
.components(Uranium, 1, Platinum, 3)
.cableProperties(GTValues.V[GTValues.EV], 6, GTValues.V[GTValues.HV], 500)
.cableProperties(GTValues.V[GTValues.EV], 6, GTValues.V[GTValues.HV], Integer.MAX_VALUE)
.blast(b -> b
.temp(4400, GasTier.MID)
.blastStats(VA[EV], 1000)
Expand All @@ -1390,7 +1390,7 @@ public static void register() {
.color(0x330033).iconSet(SHINY)
.flags(DECOMPOSITION_BY_CENTRIFUGING)
.components(Samarium, 1, Iron, 1, Arsenic, 1, Oxygen, 1)
.cableProperties(GTValues.V[GTValues.IV], 6, GTValues.V[GTValues.EV], 500)
.cableProperties(GTValues.V[GTValues.IV], 6, GTValues.V[GTValues.EV], Integer.MAX_VALUE)
.blast(b -> b
.temp(5200, GasTier.MID)
.blastStats(VA[EV], 1500)
Expand All @@ -1403,7 +1403,7 @@ public static void register() {
.color(0x994C00).iconSet(METALLIC)
.flags(DECOMPOSITION_BY_ELECTROLYZING, GENERATE_FINE_WIRE)
.components(Indium, 4, Tin, 2, Barium, 2, Titanium, 1, Copper, 7, Oxygen, 14)
.cableProperties(GTValues.V[GTValues.LuV], 8, GTValues.V[GTValues.IV], 500)
.cableProperties(GTValues.V[GTValues.LuV], 8, GTValues.V[GTValues.IV], Integer.MAX_VALUE)
.blast(b -> b
.temp(6000, GasTier.HIGH)
.blastStats(VA[IV], 1000)
Expand All @@ -1416,7 +1416,7 @@ public static void register() {
.color(0x0A0A0A)
.flags(DECOMPOSITION_BY_CENTRIFUGING, GENERATE_FINE_WIRE)
.components(Uranium, 1, Rhodium, 1, Naquadah, 2)
.cableProperties(GTValues.V[GTValues.ZPM], 8, GTValues.V[LuV], 500)
.cableProperties(GTValues.V[GTValues.ZPM], 8, GTValues.V[LuV], Integer.MAX_VALUE)
.blast(b -> b
.temp(9000, GasTier.HIGH)
.blastStats(VA[IV], 1500)
Expand All @@ -1430,7 +1430,7 @@ public static void register() {
.color(0x7D9673).iconSet(METALLIC)
.flags(DECOMPOSITION_BY_CENTRIFUGING, GENERATE_FINE_WIRE)
.components(NaquadahEnriched, 4, Trinium, 3, Europium, 2, Duranium, 1)
.cableProperties(GTValues.V[GTValues.UV], 16, GTValues.V[GTValues.ZPM], 500)
.cableProperties(GTValues.V[GTValues.UV], 16, GTValues.V[GTValues.ZPM], Integer.MAX_VALUE)
.blast(b -> b
.temp(9900, GasTier.HIGH)
.blastStats(VA[LuV], 1200)
Expand All @@ -1444,7 +1444,7 @@ public static void register() {
.color(0xFFFFFF).iconSet(BRIGHT)
.flags(DECOMPOSITION_BY_ELECTROLYZING)
.components(Ruthenium, 1, Trinium, 2, Americium, 1, Neutronium, 2, Oxygen, 8)
.cableProperties(GTValues.V[GTValues.UHV], 24, GTValues.V[GTValues.UV], 500)
.cableProperties(GTValues.V[GTValues.UHV], 24, GTValues.V[GTValues.UV], Integer.MAX_VALUE)
.blast(b -> b
.temp(10800, GasTier.HIGHER)
.blastStats(VA[ZPM], 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.util.GTUtility;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.utils.TooltipHelper;
import gregtech.common.pipelike.handlers.properties.MaterialFluidProperties;

import net.minecraft.client.renderer.texture.TextureAtlasSprite;
Expand Down Expand Up @@ -278,13 +277,7 @@ public int getDefaultPaintingColor() {
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
tooltip.add(I18n.format("gregtech.universal.tooltip.fluid_storage_capacity", tankSize));
this.fluidFilter.appendTooltips(tooltip, true, true);

if (TooltipHelper.isShiftDown()) {
tooltip.add(I18n.format("gregtech.tool_action.screwdriver.access_covers"));
tooltip.add(I18n.format("gregtech.tool_action.screwdriver.auto_output_down"));
tooltip.add(I18n.format("gregtech.tool_action.crowbar"));
}
this.fluidFilter.appendTooltips(tooltip);

NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound != null && tagCompound.hasKey("Fluid", Constants.NBT.TAG_COMPOUND)) {
Expand All @@ -295,10 +288,11 @@ public void addInformation(ItemStack stack, @Nullable World player, List<String>
}
}

// Override this so that we can control the "Hold SHIFT" tooltip manually
@Override
public boolean showToolUsages() {
return false;
public void addToolUsages(ItemStack stack, @Nullable World world, List<String> tooltip, boolean advanced) {
tooltip.add(I18n.format("gregtech.tool_action.screwdriver.access_covers"));
tooltip.add(I18n.format("gregtech.tool_action.screwdriver.auto_output_down"));
tooltip.add(I18n.format("gregtech.tool_action.crowbar"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ public void addInformation(@NotNull ItemStack stack, World worldIn, @NotNull Lis
tooltip.add(I18n.format("gregtech.cable.superconductor", GTValues.VN[tier]));
tooltip.add(I18n.format("gregtech.cable.voltage", voltageLimit, GTValues.VNF[tier]));
tooltip.add(I18n.format("gregtech.cable.amperage", getAmperage(structure)));
tooltip.add(I18n.format("gregtech.cable.loss_per_block", getLoss(structure)));
if (isSuperconductor())

long loss = isSuperconductor() && superconductorCriticalTemperature == Integer.MAX_VALUE ? 0 :
getLoss(structure);
tooltip.add(I18n.format("gregtech.cable.loss_per_block", loss));
if (isSuperconductor() && superconductorCriticalTemperature != Integer.MAX_VALUE) {
tooltip.add(I18n.format("gregtech.cable.superconductor_loss", superconductorCriticalTemperature));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,9 @@ public void addInformation(@NotNull ItemStack stack, World worldIn, @NotNull Lis
@NotNull ITooltipFlag flagIn, IPipeMaterialStructure structure) {
tooltip.add(I18n.format("gregtech.fluid_pipe"));
tooltip.add(I18n.format("gregtech.universal.tooltip.fluid_transfer_rate", getThroughput(structure)));
tooltip.add(I18n.format("gregtech.fluid_pipe.max_temperature", getMaxFluidTemperature()));
tooltip.add(I18n.format("gregtech.fluid_pipe.min_temperature", getMinFluidTemperature()));
tooltip.add(I18n.format("gregtech.fluid_pipe.priority",
tooltip.add(I18n.format("gregtech.pipe.priority",
TextFormattingUtil.formatNumbers(getFlowPriority(structure))));
appendTooltips(tooltip);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void addInformation(@NotNull ItemStack stack, World worldIn, @NotNull Lis
tooltip.add(I18n.format("gregtech.universal.tooltip.item_transfer_rate_stacks",
baseItemsPer5Ticks / 16));
}
tooltip.add(I18n.format("gregtech.item_pipe.priority",
tooltip.add(I18n.format("gregtech.pipe.priority",
TextFormattingUtil.formatNumbers(getFlowPriority(structure))));
}

Expand Down
9 changes: 4 additions & 5 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -5589,21 +5589,20 @@ gregtech.item_filter.footer=§eClick with item to override
gregtech.cable.voltage=§aMax Voltage: §f%,d §f(%s§f)
gregtech.cable.amperage=§eMax Amperage: §f%,d
gregtech.cable.loss_per_block=§cLoss/Meter/Ampere: §f%,d§f EU-Volt
gregtech.cable.superconductor_loss=§cLoss is set to §f0§c under critical temperature §f%,d§f K
gregtech.cable.superconductor_loss=§cLoss is §f0§c under critical temperature §f%,d§f K
gregtech.cable.superconductor=§d%s Superconductor

gregtech.fluid_pipe.max_temperature=§cTemperature Limit: §f%,d K
gregtech.fluid_pipe.min_temperature=§6Can handle fluids at or above §f%,d K
gregtech.fluid_pipe.max_temperature=§cMax Temperature: §f%,d K
gregtech.fluid_pipe.min_temperature=§bMin Temperature: §f%,d K
gregtech.pipe.channels=§eChannels: §f%d
gregtech.pipe.priority=§9Priority: §f%s
gregtech.fluid_pipe.gas_proof=§6Can handle Gases
gregtech.fluid_pipe.acid_proof=§6Can handle Acids
gregtech.fluid_pipe.plasma_proof=§6Can handle all Plasmas
gregtech.fluid_pipe.not_gas_proof=§4Gases may leak!

gregtech.fluid_pipe=§dFluid Pipe
gregtech.item_pipe=§dItem Pipe
gregtech.fluid_pipe.priority=§9Priority: §f%s
gregtech.item_pipe.priority=§9Priority: §f%s

gregtech.multiblock.work_paused=Work Paused.
gregtech.multiblock.running=Running perfectly.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/gregtech/lang/ja_jp.lang
Original file line number Diff line number Diff line change
Expand Up @@ -5505,7 +5505,7 @@ gregtech.fluid_pipe.cryo_proof=§6極低温の液体を運搬可能
gregtech.fluid_pipe.plasma_proof=§6全てのプラズマを運搬可能
gregtech.fluid_pipe.not_gas_proof=§4気体を密封できない!

gregtech.item_pipe.priority=§9優先度: %d
gregtech.pipe.priority=§9優先度: %d

gregtech.multiblock.work_paused=一時停止中
gregtech.multiblock.running=完璧に動作中
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/gregtech/lang/ru_ru.lang
Original file line number Diff line number Diff line change
Expand Up @@ -4910,7 +4910,7 @@ gregtech.fluid_pipe.gas_proof=§6Может хранить газы
gregtech.fluid_pipe.acid_proof=§6Может хранить кислоты
gregtech.fluid_pipe.cryo_proof=§6Может хранить криогенику
gregtech.fluid_pipe.not_gas_proof=§4Возможна утечка газов!
gregtech.item_pipe.priority=§9Приоритет: §f%,d
gregtech.pipe.priority=§9Приоритет: §f%,d
gregtech.multiblock.work_paused=Работа приостановлена.
gregtech.multiblock.running=Работает отлично.
gregtech.multiblock.idling=Холостой ход.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/gregtech/lang/zh_cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -5577,7 +5577,7 @@ gregtech.fluid_pipe.cryo_proof=§6可传输低温物质
gregtech.fluid_pipe.plasma_proof=§6可传输所有等离子体
gregtech.fluid_pipe.not_gas_proof=§4气体可能泄漏!

gregtech.item_pipe.priority=§9优先级:§f%,d
gregtech.pipe.priority=§9优先级:§f%,d

gregtech.multiblock.work_paused=暂停。
gregtech.multiblock.running=运行正常。
Expand Down

0 comments on commit 7f76d01

Please sign in to comment.