Skip to content

Commit

Permalink
Fixed tips
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Mar 15, 2024
1 parent f828835 commit dd40e9e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2024-03-14T17:09:54.502574 Languages: en_us
2a7be2a6f83f65e72d345ab39530a7d72aab8d3e assets/railcraft/lang/en_us.json
// 1.20.1 2024-03-15T11:22:03.38324 Languages: en_us
153278f01cd809c49d4c04d4a8256d2f86c68fa5 assets/railcraft/lang/en_us.json
8 changes: 4 additions & 4 deletions src/generated/resources/assets/railcraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,6 @@
"tips.railcraft.cart_dispenser": "Dispenses carts onto tracks",
"tips.railcraft.charge_network_battery": "Charge Network Battery",
"tips.railcraft.charge_network_empty_battery": "Charge Network Empty Battery",
"tips.railcraft.clear": "Clear",
"tips.railcraft.click_to_craft": "- Click to craft -",
"tips.railcraft.coal_coke_block": "%s Fuel Units",
"tips.railcraft.coke_oven": "Multi-Block: 3x3x3 (Hollow)",
Expand Down Expand Up @@ -899,7 +898,6 @@
"tips.railcraft.fueled_boiler_firebox": "Multi-Block: Variable Size, Bottom Layer",
"tips.railcraft.gated_track": "Track with built-in gate",
"tips.railcraft.googles.aura": "Current Aura:",
"tips.railcraft.googles.aura.none": "None",
"tips.railcraft.googles.aura.shunting": "Shunting",
"tips.railcraft.googles.aura.signalling": "Signalling",
"tips.railcraft.googles.aura.surveying": "Surveying",
Expand Down Expand Up @@ -931,10 +929,11 @@
"tips.railcraft.locking_track.train_boarding_reversed": "Train Boarding Reversed",
"tips.railcraft.locking_track.train_holding": "Train Holding",
"tips.railcraft.locking_track.train_lockdown": "Train Lockdown",
"tips.railcraft.locomotive.item.owner": "Owner: %s",
"tips.railcraft.locomotive.item.no_whistle": "There is currently no whistle installed",
"tips.railcraft.locomotive.item.owner": "Owner:",
"tips.railcraft.locomotive.item.primary": "Primary color:",
"tips.railcraft.locomotive.item.secondary": "Secondary color:",
"tips.railcraft.locomotive.item.whistle": "There is currently no whistle installed.",
"tips.railcraft.locomotive.item.whistle": "Whistle pitch:",
"tips.railcraft.locomotive.slot.ticket": "Insert Ticket",
"tips.railcraft.locomotive_track": "Starts/Stops locomotive",
"tips.railcraft.logbook": "Records visitors",
Expand All @@ -959,6 +958,7 @@
"tips.railcraft.max_draw": "Max Draw: %s FE/t",
"tips.railcraft.multiblock2x2x2": "Multi-Block: 2x2x2",
"tips.railcraft.multiblock3x2x2": "Multi-Block: 3x2x2",
"tips.railcraft.none": "None",
"tips.railcraft.one_way_track": "Carts can only pass in the direction of the arrow",
"tips.railcraft.overalls": "Protection against the dangers of track-working",
"tips.railcraft.pair_with_control_track": "- Pair with Control track -",
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/mods/railcraft/Translations.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public static class Tips {
makeKey("tips", "locomotive.item.primary");
public static final String LOCOMOTIVE_ITEM_SECONDARY =
makeKey("tips", "locomotive.item.secondary");
public static final String LOCOMOTIVE_ITEM_NO_WHISTLE =
makeKey("tips", "locomotive.item.no_whistle");
public static final String LOCOMOTIVE_ITEM_WHISTLE =
makeKey("tips", "locomotive.item.whistle");
public static final String TRACK_LAYER = makeKey("tips", "track_layer");
Expand All @@ -178,10 +180,9 @@ public static class Tips {
public static final String STEAM_TURBINE_DESC_3 = makeKey("tips", "steam_turbine_desc3");
public static final String SPIKE_MAUL = makeKey("tips", "spike_maul");
public static final String OVERALLS = makeKey("tips", "overalls");
public static final String CLEAR = makeKey("tips", "clear");
public static final String NONE = makeKey("tips", "none");
public static final String GOOGLES_DESC = makeKey("tips", "googles.desc");
public static final String GOOGLES_AURA = makeKey("tips", "googles.aura");
public static final String GOOGLES_AURA_NONE = makeKey("tips", "googles.aura.none");
public static final String GOOGLES_AURA_SHUNTING = makeKey("tips", "googles.aura.shunting");
public static final String GOOGLES_AURA_SIGNALLING =
makeKey("tips", "googles.aura.signalling");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,11 @@ private void tipsTranslations() {
this.add(Translations.Tips.ROUTING_TICKET_BLANK, "Blank Ticket");
this.add(Translations.Tips.ROUTING_TABLE_BOOK_LAST_EDIT, "Last edited by %s");
this.add(Translations.Tips.LOCOMOTIVE_SLOT_TICKET, "Insert Ticket");
this.add(Translations.Tips.LOCOMOTIVE_ITEM_OWNER, "Owner: %s");
this.add(Translations.Tips.LOCOMOTIVE_ITEM_OWNER, "Owner:");
this.add(Translations.Tips.LOCOMOTIVE_ITEM_PRIMARY, "Primary color:");
this.add(Translations.Tips.LOCOMOTIVE_ITEM_SECONDARY, "Secondary color:");
this.add(Translations.Tips.LOCOMOTIVE_ITEM_WHISTLE, "There is currently no whistle installed.");
this.add(Translations.Tips.LOCOMOTIVE_ITEM_NO_WHISTLE, "There is currently no whistle installed");
this.add(Translations.Tips.LOCOMOTIVE_ITEM_WHISTLE, "Whistle pitch:");
this.add(Translations.Tips.TRACK_LAYER, "Lays track as it moves");
this.add(Translations.Tips.TRACK_RELAYER, "Replaces one track with another");
this.add(Translations.Tips.TRACK_REMOVER, "Removes tracks it passes over");
Expand All @@ -421,10 +422,9 @@ private void tipsTranslations() {
this.add(Translations.Tips.STEAM_TURBINE_DESC_3, "Requires a Turbine Rotor");
this.add(Translations.Tips.SPIKE_MAUL, "Converts track to switches and junctions.");
this.add(Translations.Tips.OVERALLS, "Protection against the dangers of track-working");
this.add(Translations.Tips.CLEAR, "Clear");
this.add(Translations.Tips.NONE, "None");
this.add(Translations.Tips.GOOGLES_DESC, "Right-click to change aura.");
this.add(Translations.Tips.GOOGLES_AURA, "Current Aura:");
this.add(Translations.Tips.GOOGLES_AURA_NONE, "None");
this.add(Translations.Tips.GOOGLES_AURA_SHUNTING, "Shunting");
this.add(Translations.Tips.GOOGLES_AURA_SIGNALLING, "Signalling");
this.add(Translations.Tips.GOOGLES_AURA_SURVEYING, "Surveying");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public void setRenderYaw(float yaw) {
*/
public final void whistle() {
if (this.whistleDelay <= 0) {
this.level().playSound(null, this, this.getWhistleSound(), this.getSoundSource(), 1, 1);
this.level().playSound(null, this, this.getWhistleSound(), this.getSoundSource(), 1, this.whistlePitch);
this.whistleDelay = WHISTLE_DELAY;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mods/railcraft/world/item/GogglesItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void appendHoverText(ItemStack itemStack, @Nullable Level level,
public enum Aura {
// TODO: 1.20.4+ use CODECS

NONE(Translations.Tips.GOOGLES_AURA_NONE),
NONE(Translations.Tips.NONE),
TRACKING(Translations.Tips.GOOGLES_AURA_TRACKING),
TUNING(Translations.Tips.GOOGLES_AURA_TUNING),
SHUNTING(Translations.Tips.GOOGLES_AURA_SHUNTING),
Expand Down
31 changes: 21 additions & 10 deletions src/main/java/mods/railcraft/world/item/LocomotiveItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,36 @@ public boolean matches(ItemStack matcher, ItemStack target) {
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip,
TooltipFlag adv) {
var owner = getOwner(stack);
if (owner != null && !StringUtils.isBlank(owner.getName())) {
tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_OWNER, owner.getName())
.withStyle(ChatFormatting.GRAY));
if (owner != null && StringUtils.isNotBlank(owner.getName())) {
tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_OWNER)
.withStyle(ChatFormatting.AQUA)
.append(" ")
.append(Component.literal(owner.getName()).withStyle(ChatFormatting.GRAY)));
}

tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_PRIMARY)
.withStyle(ChatFormatting.AQUA)
.append(" ")
.append(Component.translatable("color.minecraft." + getPrimaryColor(stack).getName()))
.withStyle(ChatFormatting.GRAY));
.append(Component.translatable("color.minecraft." + getPrimaryColor(stack).getName())
.withStyle(ChatFormatting.GRAY)));

tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_SECONDARY)
.withStyle(ChatFormatting.AQUA)
.append(" ")
.append(Component.translatable("color.minecraft." + getSecondaryColor(stack).getName()))
.withStyle(ChatFormatting.GRAY));
.append(Component.translatable("color.minecraft." + getSecondaryColor(stack).getName())
.withStyle(ChatFormatting.GRAY)));

float whistle = getWhistlePitch(stack);
var whistleText = whistle < 0 ? "???" : String.format("%.2f", whistle);
tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_WHISTLE, whistleText)
.withStyle(ChatFormatting.GRAY));
if (whistle < 0) {
tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_NO_WHISTLE)
.withStyle(ChatFormatting.GRAY));
} else {
tooltip.add(Component.translatable(Translations.Tips.LOCOMOTIVE_ITEM_WHISTLE)
.withStyle(ChatFormatting.AQUA)
.append(" ")
.append(Component.literal(String.format("%.2f", whistle))
.withStyle(ChatFormatting.GRAY)));
}
}

public static void setItemColorData(ItemStack stack, DyeColor primaryColor,
Expand Down
33 changes: 18 additions & 15 deletions src/main/java/mods/railcraft/world/item/TicketItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ public Component getName(ItemStack stack) {
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> list,
TooltipFlag flag) {
if (stack.hasTag()) {
GameProfile owner = getOwner(stack);
if (owner != null) {
list.add(Component.translatable(Translations.Tips.ROUTING_TICKET_ISSUER));
list.add(PlayerUtil.getUsername(level, owner).copy().withStyle(ChatFormatting.GRAY));
}

String dest = getDestination(stack);
list.add(Component.translatable(Translations.Tips.ROUTING_TICKET_DEST));
if (dest.isEmpty()) {
list.add(Component.translatable(Translations.Tips.CLEAR).withStyle(ChatFormatting.GRAY));
} else {
list.add(Component.literal(dest).withStyle(ChatFormatting.GRAY));
}
} else
if (!stack.hasTag()) {
list.add(Component.translatable(Translations.Tips.ROUTING_TICKET_BLANK)
.withStyle(ChatFormatting.GRAY));
return;
}
var owner = getOwner(stack);
if (owner != null) {
list.add(Component.translatable(Translations.Tips.ROUTING_TICKET_ISSUER)
.withStyle(ChatFormatting.AQUA)
.append(" ")
.append(PlayerUtil.getUsername(level, owner).copy().withStyle(ChatFormatting.GRAY)));
}

String dest = getDestination(stack);
list.add(Component.translatable(Translations.Tips.ROUTING_TICKET_DEST)
.withStyle(ChatFormatting.AQUA)
.append(" ")
.append((dest.isEmpty()
? Component.translatable(Translations.Tips.NONE)
: Component.literal(dest)).withStyle(ChatFormatting.GRAY)));
}

@Override
Expand Down

0 comments on commit dd40e9e

Please sign in to comment.