Skip to content

Commit

Permalink
fix: Fix cooldown showing twice on inventory button tooltip #906
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Sep 16, 2024
1 parent 3719357 commit c95776d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface WarpRequirement {

void rollback(Player player);


void appendHoverText(Player player, List<Component> tooltip);

default boolean isEmpty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,16 @@ public static void initialize() {
final var waystone = PlayerWaystoneManager.getInventoryButtonTarget(player).orElse(InvalidWaystone.INSTANCE);
final var context = WaystonesAPI.createUnboundTeleportContext(player, waystone).addFlag(TeleportFlags.INVENTORY_BUTTON);
final var requirements = WaystonesAPI.resolveRequirements(context);
int secondsLeft = (int) (millisLeft / 1000);
if (inventoryButtonMode.hasNamedTarget()) {
tooltip.add(Component.translatable("gui.waystones.inventory.return_to_waystone").withStyle(ChatFormatting.YELLOW));
final var targetComponent = Component.literal(inventoryButtonMode.getNamedTarget()).withStyle(ChatFormatting.DARK_AQUA);
tooltip.add(Component.translatable("tooltip.waystones.bound_to", targetComponent).withStyle(ChatFormatting.GRAY));
if (secondsLeft > 0) {
tooltip.add(Component.empty());
}
} else if (inventoryButtonMode.isReturnToNearest()) {
tooltip.add(Component.translatable("gui.waystones.inventory.return_to_nearest_waystone").withStyle(ChatFormatting.YELLOW));
final var nearestWaystone = PlayerWaystoneManager.getNearestWaystone(player);
tooltip.add(nearestWaystone.map(it -> it.getName().copy().withStyle(ChatFormatting.DARK_AQUA))
.map(it -> Component.translatable("tooltip.waystones.bound_to", it).withStyle(ChatFormatting.GRAY))
.orElseGet(() -> Component.translatable("gui.waystones.inventory.no_waystones_activated").withStyle(ChatFormatting.RED)));
if (secondsLeft > 0) {
tooltip.add(Component.empty());
}
} else if (inventoryButtonMode.isReturnToAny()) {
tooltip.add(Component.translatable("gui.waystones.inventory.return_to_waystone").withStyle(ChatFormatting.YELLOW));
if (PlayerWaystoneManager.getActivatedWaystones(player).isEmpty()) {
Expand All @@ -131,10 +124,6 @@ public static void initialize() {
requirements.appendHoverText(player, tooltip);
}

if (secondsLeft > 0) {
tooltip.add(Component.translatable("tooltip.waystones.cooldown_left", secondsLeft).withStyle(ChatFormatting.GOLD));
}

guiGraphics.renderTooltip(Minecraft.getInstance().font, tooltip, Optional.empty(), mouseX, mouseY);
}
});
Expand Down

0 comments on commit c95776d

Please sign in to comment.