Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Commit

Permalink
Improve tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Mar 29, 2020
1 parent 88a79ad commit cae378d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.2
- Added fluid pipes (raoulvdberge)
- Improved tooltips (raoulvdberge)

## 0.1.4
- Added hitboxes for the attachments on pipes (raoulvdberge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import com.raoulvdberge.refinedpipes.network.pipe.fluid.FluidPipeType;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.*;
import net.minecraft.world.World;

import javax.annotation.Nullable;
Expand All @@ -26,6 +23,13 @@ public FluidPipeBlockItem(FluidPipeBlock block) {
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);

tooltip.add(new TranslationTextComponent("misc.refinedpipes.tier", new TranslationTextComponent("enchantment.level." + type.getTier())).setStyle(new Style().setColor(TextFormatting.GRAY)));
tooltip.add(new TranslationTextComponent("misc.refinedpipes.tier", new TranslationTextComponent("enchantment.level." + type.getTier())).setStyle(new Style().setColor(TextFormatting.YELLOW)));

tooltip.add(new TranslationTextComponent(
"tooltip.refinedpipes.fluid_pipe.capacity",
new StringTextComponent("" + type.getCapacity()).setStyle(new Style().setColor(TextFormatting.WHITE))
).setStyle(new Style().setColor(TextFormatting.GRAY)));

tooltip.add(new TranslationTextComponent("tooltip.refinedpipes.fluid_pipe.speed").setStyle(new Style().setColor(TextFormatting.GRAY)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import com.raoulvdberge.refinedpipes.network.pipe.item.ItemPipeType;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.*;
import net.minecraft.world.World;

import javax.annotation.Nullable;
Expand All @@ -26,6 +23,11 @@ public ItemPipeBlockItem(ItemPipeBlock block) {
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);

tooltip.add(new TranslationTextComponent("misc.refinedpipes.tier", new TranslationTextComponent("enchantment.level." + type.getTier())).setStyle(new Style().setColor(TextFormatting.GRAY)));
tooltip.add(new TranslationTextComponent("misc.refinedpipes.tier", new TranslationTextComponent("enchantment.level." + type.getTier())).setStyle(new Style().setColor(TextFormatting.YELLOW)));

tooltip.add(new TranslationTextComponent(
"tooltip.refinedpipes.item_pipe.speed",
new StringTextComponent("" + type.getSpeedComparedToBasicTier()).setStyle(new Style().setColor(TextFormatting.WHITE))
).setStyle(new Style().setColor(TextFormatting.GRAY)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.*;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
Expand Down Expand Up @@ -83,7 +80,19 @@ public void update(World world, Network network, Pipe pipe, Attachment attachmen

@Override
public void addInformation(List<ITextComponent> tooltip) {
tooltip.add(new TranslationTextComponent("misc.refinedpipes.tier", new TranslationTextComponent("enchantment.level." + type.tier)).setStyle(new Style().setColor(TextFormatting.GRAY)));
tooltip.add(new TranslationTextComponent("misc.refinedpipes.tier", new TranslationTextComponent("enchantment.level." + type.tier)).setStyle(new Style().setColor(TextFormatting.YELLOW)));

tooltip.add(new TranslationTextComponent(
"tooltip.refinedpipes.extractor_attachment.item_extraction_rate",
new StringTextComponent("" + type.getItemsToExtract()).setStyle(new Style().setColor(TextFormatting.WHITE)),
new StringTextComponent("" + (float) type.getItemTickInterval() / 20F).setStyle(new Style().setColor(TextFormatting.WHITE))
).setStyle(new Style().setColor(TextFormatting.GRAY)));

tooltip.add(new TranslationTextComponent(
"tooltip.refinedpipes.extractor_attachment.fluid_extraction_rate",
new StringTextComponent("" + type.getFluidsToExtract()).setStyle(new Style().setColor(TextFormatting.WHITE)),
new StringTextComponent("" + (float) type.getFluidTickInterval() / 20F).setStyle(new Style().setColor(TextFormatting.WHITE))
).setStyle(new Style().setColor(TextFormatting.GRAY)));
}

private void update(Network network, Pipe pipe, Attachment attachment, BlockPos sourcePos, IItemHandler source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ public int getMaxTicksInPipe() {
}
}

public int getSpeedComparedToBasicTier() {
int mySpeed = this == BASIC ? getMaxTicksInPipe() :
(this == IMPROVED ? BASIC.getMaxTicksInPipe() + getMaxTicksInPipe() :
(this == ADVANCED ? BASIC.getMaxTicksInPipe() + IMPROVED.getMaxTicksInPipe() + getMaxTicksInPipe() :
0));

int speedOfBasicTier = BASIC.getMaxTicksInPipe();

return (int) ((float) mySpeed / (float) speedOfBasicTier * 100F);
}

public TileEntityType<ItemPipeTileEntity> getTileType() {
switch (this) {
case BASIC:
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/assets/refinedpipes/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
"item.refinedpipes.advanced_extractor_attachment": "Advanced Extractor Attachment",
"item.refinedpipes.elite_extractor_attachment": "Elite Extractor Attachment",
"item.refinedpipes.ultimate_extractor_attachment": "Ultimate Extractor Attachment",
"misc.refinedpipes.tier": "Tier %s"
"misc.refinedpipes.tier": "Tier %s",
"tooltip.refinedpipes.fluid_pipe.capacity": "Capacity: %d mB",
"tooltip.refinedpipes.item_pipe.speed": "Speed: %d%%",
"tooltip.refinedpipes.fluid_pipe.speed": "Speed varies by fluid.",
"tooltip.refinedpipes.extractor_attachment.item_extraction_rate": "Extracts %d item(s) every %d second(s).",
"tooltip.refinedpipes.extractor_attachment.fluid_extraction_rate": "Extracts %d mB every %d second(s)."
}

0 comments on commit cae378d

Please sign in to comment.