Skip to content

Commit

Permalink
fix: badges spacing
Browse files Browse the repository at this point in the history
* also, fix build errors
  • Loading branch information
UltimatChamp committed Jan 28, 2025
1 parent 96987ea commit b73541d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import dev.ultimatchamp.enhancedtooltips.TooltipHelper;
import dev.ultimatchamp.enhancedtooltips.config.EnhancedTooltipsConfig;
import dev.ultimatchamp.enhancedtooltips.util.BadgesUtils;
import dev.ultimatchamp.enhancedtooltips.util.ItemGroupsUtils;
import dev.ultimatchamp.enhancedtooltips.util.*;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.tooltip.TooltipComponent;
Expand Down Expand Up @@ -42,20 +41,13 @@ public int getWidth(TextRenderer textRenderer) {

//? if >1.20.6 {
if (EnhancedTooltipsConfig.load().itemBadges) {
for (var tab : ItemGroups.getGroups()) {
if (tab.equals(ItemGroups.getSearchGroup())) continue;
badgeWidth = textRenderer.getWidth(Text.translatable("gamerule.category.misc")) + SPACING * 2;

var identified = false;

for (var displayStack : tab.getDisplayStacks()) {
if (stack.isOf(displayStack.getItem())) {
badgeWidth = textRenderer.getWidth(tab.getDisplayName()) + SPACING * 2;
identified = true;
break;
}
for (Map.Entry<List<Item>, Pair<String, Integer>> entry : ItemGroupsUtils.getItemGroups().entrySet()) {
if (entry.getKey().contains(stack.getItem())) {
badgeWidth = textRenderer.getWidth(Text.translatable(entry.getValue().getLeft())) + SPACING * 2;
break;
}

if (identified) break;
}
}
//?}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static Screen createConfigScreen(Screen parent) {
.title(Text.translatable("enhancedtooltips.title"))
.category(ConfigCategory.createBuilder()
.name(Text.translatable("stat.generalButton"))
//? if >1.20.6 {
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("enhancedtooltips.config.itemBadges"))
.description(OptionDescription.createBuilder()
Expand All @@ -29,6 +30,7 @@ public static Screen createConfigScreen(Screen parent) {
)
.controller(TickBoxControllerBuilder::create)
.build())
//?}
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("enhancedtooltips.config.hungerTooltip"))
.description(OptionDescription.createBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ public class ItemGroupsUtils {
//?}
Items.WAXED_OXIDIZED_CUT_COPPER,
Items.WAXED_OXIDIZED_CUT_COPPER_STAIRS,
Items.WAXED_OXIDIZED_CUT_COPPER_SLAB,
Items.WAXED_OXIDIZED_CUT_COPPER_SLAB
//? if >1.21.1 {
Items.WAXED_OXIDIZED_COPPER_DOOR,
, Items.WAXED_OXIDIZED_COPPER_DOOR,
Items.WAXED_OXIDIZED_COPPER_TRAPDOOR,
Items.WAXED_OXIDIZED_COPPER_BULB
//?}
Expand Down Expand Up @@ -1250,6 +1250,7 @@ public class ItemGroupsUtils {
Items.NAME_TAG,
Items.LEAD,
Items.BUNDLE,
//? if >1.21.1 {
Items.WHITE_BUNDLE,
Items.LIGHT_GRAY_BUNDLE,
Items.GRAY_BUNDLE,
Expand All @@ -1266,6 +1267,7 @@ public class ItemGroupsUtils {
Items.PURPLE_BUNDLE,
Items.MAGENTA_BUNDLE,
Items.PINK_BUNDLE,
//?}
Items.COMPASS,
Items.RECOVERY_COMPASS,
Items.CLOCK,
Expand Down Expand Up @@ -1520,9 +1522,9 @@ public class ItemGroupsUtils {
Items.GHAST_TEAR,
Items.TURTLE_HELMET,
Items.PHANTOM_MEMBRANE,
Items.EXPERIENCE_BOTTLE,
Items.EXPERIENCE_BOTTLE
//? if >1.21.1 {
Items.TRIAL_KEY,
, Items.TRIAL_KEY,
Items.OMINOUS_TRIAL_KEY
//?}
);
Expand Down

0 comments on commit b73541d

Please sign in to comment.