Skip to content

Commit

Permalink
fix: only show tooltip for smart filter item in inventory screen
Browse files Browse the repository at this point in the history
Avoid spurious tooltips when used a filter item in FTB Quests
  • Loading branch information
desht committed Nov 28, 2023
1 parent 7cc89cd commit 4a22255
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import dev.architectury.event.events.client.ClientLifecycleEvent;
import dev.ftb.mods.ftbfiltersystem.api.FTBFilterSystemAPI;
import dev.ftb.mods.ftbfiltersystem.api.client.gui.AbstractFilterConfigScreen;
import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter;
import dev.ftb.mods.ftbfiltersystem.api.client.FTBFilterSystemClientAPI;
import dev.ftb.mods.ftbfiltersystem.api.client.FilterScreenFactory;
import dev.ftb.mods.ftbfiltersystem.api.client.gui.AbstractFilterConfigScreen;
import dev.ftb.mods.ftbfiltersystem.api.event.client.ClientFilterRegistrationEvent;
import dev.ftb.mods.ftbfiltersystem.api.filter.SmartFilter;
import dev.ftb.mods.ftbfiltersystem.client.gui.*;
import dev.ftb.mods.ftbfiltersystem.filter.*;
import dev.ftb.mods.ftbfiltersystem.registry.FilterRegistry;
import dev.ftb.mods.ftbfiltersystem.registry.item.SmartFilterItem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -72,6 +73,10 @@ public <T extends SmartFilter> void openFilterConfigScreen(T filter, FilterScree
}
}

public static boolean shouldShowItemTooltip() {
return Minecraft.getInstance().screen instanceof EffectRenderingInventoryScreen<?>;
}

//------------------------------------------------------------
// API implementation below here

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera

@Override
public void appendHoverText(ItemStack itemStack, @Nullable Level level, List<Component> list, TooltipFlag tooltipFlag) {
if (level == null || level.isClientSide && !FTBFilterSystemClient.shouldShowItemTooltip()) {
return; // avoids spurious tooltips in places like FTB Quests where a filter could be a matching display item
}
list.add(Component.translatable("item.ftbfiltersystem.smart_filter.tooltip.1").withStyle(ChatFormatting.GRAY));
list.add(Component.translatable("item.ftbfiltersystem.smart_filter.tooltip.2").withStyle(ChatFormatting.GRAY));
}
Expand Down

0 comments on commit 4a22255

Please sign in to comment.