From e1ceed73b69cf11f3e2806db21461b2c0ad4adc1 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:22:10 +0100 Subject: the whitespace commit --- .../config/categories/MiningCategory.java | 41 --- .../config/configs/UIAndVisualsConfig.java | 8 - .../skyblock/dwarven/CrystalsHudWidget.java | 207 ++++++------ .../skyblocker/skyblock/end/EndHudWidget.java | 99 +++--- .../skyblock/garden/FarmingHudWidget.java | 176 +++++----- .../hysky/skyblocker/skyblock/tabhud/TabHud.java | 61 ++-- .../tabhud/config/DungeonsTabPlaceholder.java | 181 +++++----- .../tabhud/config/WidgetsConfigurationScreen.java | 369 +++++++++++---------- .../skyblock/tabhud/config/WidgetsElementList.java | 172 +++++----- .../skyblock/tabhud/config/WidgetsListTab.java | 188 ++++++----- .../tabhud/config/entries/WidgetEntry.java | 1 - .../tabhud/config/entries/WidgetsListEntry.java | 3 +- .../config/entries/slot/BooleanSlotEntry.java | 61 ++-- .../config/entries/slot/DefaultSlotEntry.java | 69 ++-- .../config/entries/slot/EditableSlotEntry.java | 73 ++-- .../config/entries/slot/WidgetSlotEntry.java | 104 +++--- .../config/entries/slot/WidgetsListSlotEntry.java | 16 +- .../skyblock/tabhud/config/preview/PreviewTab.java | 2 - .../tabhud/config/preview/PreviewWidget.java | 2 - .../tabhud/screenbuilder/ScreenBuilder.java | 302 ++++++++--------- .../tabhud/screenbuilder/ScreenMaster.java | 297 +++++++++-------- .../pipeline/CenteredWidgetPositioner.java | 111 +++---- .../screenbuilder/pipeline/PositionRule.java | 103 +++--- .../pipeline/TopAlignedWidgetPositioner.java | 54 +-- .../screenbuilder/pipeline/WidgetPositioner.java | 111 +++---- .../hysky/skyblocker/skyblock/tabhud/util/Ico.java | 152 ++++----- .../skyblock/tabhud/util/PlayerListMgr.java | 6 +- .../skyblock/tabhud/util/ScreenConst.java | 12 +- .../skyblock/tabhud/widget/CommsWidget.java | 100 +++--- .../tabhud/widget/ComponentBasedWidget.java | 336 +++++++++---------- .../skyblock/tabhud/widget/ComposterWidget.java | 40 +-- .../skyblock/tabhud/widget/DungeonBuffWidget.java | 80 ++--- .../skyblock/tabhud/widget/DungeonDeathWidget.java | 66 ++-- .../tabhud/widget/DungeonDownedWidget.java | 58 ++-- .../tabhud/widget/DungeonPlayerWidget.java | 183 +++++----- .../tabhud/widget/DungeonPuzzleWidget.java | 86 ++--- .../tabhud/widget/DungeonSecretWidget.java | 36 +- .../tabhud/widget/DungeonServerWidget.java | 68 ++-- .../skyblock/tabhud/widget/EffectWidget.java | 154 +++++---- .../skyblock/tabhud/widget/ElectionWidget.java | 167 +++++----- .../skyblock/tabhud/widget/EssenceWidget.java | 43 ++- .../skyblock/tabhud/widget/EventWidget.java | 18 +- .../skyblock/tabhud/widget/FireSaleWidget.java | 68 ++-- .../skyblock/tabhud/widget/ForgeWidget.java | 92 +++-- .../skyblock/tabhud/widget/HudWidget.java | 86 ++--- .../tabhud/widget/JacobsContestWidget.java | 77 +++-- .../skyblock/tabhud/widget/MinionWidget.java | 215 ++++++------ .../skyblock/tabhud/widget/PetWidget.java | 67 ++-- .../skyblock/tabhud/widget/PowderWidget.java | 39 ++- .../skyblock/tabhud/widget/ProfileWidget.java | 42 +-- .../skyblock/tabhud/widget/ServerWidget.java | 53 ++- .../skyblock/tabhud/widget/SkillsWidget.java | 85 ++--- .../skyblock/tabhud/widget/TabHudWidget.java | 72 ++-- .../skyblock/tabhud/widget/VisitorsWidget.java | 35 +- .../tabhud/widget/component/Component.java | 26 +- .../widget/component/IcoFatTextComponent.java | 60 ++-- .../tabhud/widget/component/IcoTextComponent.java | 50 +-- .../widget/component/PlainTextComponent.java | 26 +- .../tabhud/widget/component/PlayerComponent.java | 35 +- .../tabhud/widget/component/ProgressComponent.java | 90 ++--- .../tabhud/widget/component/TableComponent.java | 86 ++--- 61 files changed, 2832 insertions(+), 2888 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java index eaaab35b..3ed0b335 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/MiningCategory.java @@ -57,47 +57,6 @@ public class MiningCategory { .build()) .build()) - //Dwarven HUD - // TODO remove - .group(OptionGroup.createBuilder() - .name(Text.translatable("skyblocker.config.mining.dwarvenHud")) - .collapsed(false) - .option(LabelOption.create(Text.literal("Use the hypixel widget."))) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.mining.dwarvenHud.enabledCommissions")) - .binding(defaults.mining.dwarvenHud.enabledCommissions, - () -> config.mining.dwarvenHud.enabledCommissions, - newValue -> config.mining.dwarvenHud.enabledCommissions = newValue) - .controller(ConfigUtils::createBooleanController) - .available(false) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.mining.dwarvenHud.enabledPowder")) - .binding(defaults.mining.dwarvenHud.enabledPowder, - () -> config.mining.dwarvenHud.enabledPowder, - newValue -> config.mining.dwarvenHud.enabledPowder = newValue) - .controller(ConfigUtils::createBooleanController) - .available(false) - .build()) - .option(Option.createBuilder() - .name(Text.translatable("skyblocker.config.mining.dwarvenHud.style")) - .description(OptionDescription.of(Text.translatable("skyblocker.config.mining.dwarvenHud.style.@Tooltip[0]"), - Text.translatable("skyblocker.config.mining.dwarvenHud.style.@Tooltip[1]"), - Text.translatable("skyblocker.config.mining.dwarvenHud.style.@Tooltip[2]"))) - .binding(defaults.mining.dwarvenHud.style, - () -> config.mining.dwarvenHud.style, - newValue -> config.mining.dwarvenHud.style = newValue) - .controller(ConfigUtils::createEnumCyclingListController) - .available(false) - .build()) - .option(ButtonOption.createBuilder() - .name(Text.translatable("skyblocker.config.mining.dwarvenHud.screen")) - .text(Text.translatable("text.skyblocker.open")) - .action((screen, opt) -> screen.tick()) - .available(false) - .build()) - .build()) - //Crystal Hollows .group(OptionGroup.createBuilder() .name(Text.translatable("skyblocker.config.mining.crystalHollows")) diff --git a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java index 142fb8f4..21b58a33 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/UIAndVisualsConfig.java @@ -165,16 +165,8 @@ public class UIAndVisualsConfig { @SerialEntry public boolean effectsFromFooter = false; - @Deprecated - @SerialEntry - public boolean plainPlayerNames = false; - @SerialEntry public ScreenBuilder.DefaultPositioner defaultPositioning = ScreenBuilder.DefaultPositioner.CENTERED; - - @Deprecated - @SerialEntry - public NameSorting nameSorting = NameSorting.DEFAULT; } public enum NameSorting { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudWidget.java index 122f6c6e..78cc2c1f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudWidget.java @@ -21,52 +21,52 @@ import java.util.Set; @RegisterWidget public class CrystalsHudWidget extends HudWidget { - private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - protected static final Identifier MAP_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); - private static final Identifier MAP_ICON = Identifier.ofVanilla("textures/map/decorations/player.png"); - private static final List SMALL_LOCATIONS = List.of("Fairy Grotto", "King Yolkar", "Corleone", "Odawa", "Key Guardian", "Unknown"); + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + protected static final Identifier MAP_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); + private static final Identifier MAP_ICON = Identifier.ofVanilla("textures/map/decorations/player.png"); + private static final List SMALL_LOCATIONS = List.of("Fairy Grotto", "King Yolkar", "Corleone", "Odawa", "Key Guardian", "Unknown"); - private static CrystalsHudWidget instance = null; + private static CrystalsHudWidget instance = null; public static CrystalsHudWidget getInstance() { if (instance == null) new CrystalsHudWidget(); return instance; } - public CrystalsHudWidget() { - super("hud_crystals"); + public CrystalsHudWidget() { + super("hud_crystals"); instance = this; - } - - /** - * Converts an X and Z coordinate in the crystal hollow to an X and Y coordinate on the map. - * - * @param x the world X coordinate - * @param z the world Z coordinate - * @return a vector representing the x and y values - */ - protected static Vector2ic transformLocation(double x, double z) { - //converts an x and z to a location on the map - int transformedX = (int) ((x - 202) / 621 * 62); - int transformedY = (int) ((z - 202) / 621 * 62); - transformedX = Math.clamp(transformedX, 0, 62); - transformedY = Math.clamp(transformedY, 0, 62); - - return new Vector2i(transformedX, transformedY); - } - - /** - * Converts yaw to the cardinal directions that a player marker can be rotated towards on a map. - * The rotations of a marker follow this order: N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW. - *

- * Based off code from {@link net.minecraft.client.render.MapRenderer} - */ - private static float yaw2Cardinal(float yaw) { - yaw += 180; //flip direction - byte clipped = (byte) ((yaw + (yaw < 0.0 ? -8.0 : 8.0)) * 16.0 / 360.0); - - return (clipped * 360f) / 16f; - } + } + + /** + * Converts an X and Z coordinate in the crystal hollow to an X and Y coordinate on the map. + * + * @param x the world X coordinate + * @param z the world Z coordinate + * @return a vector representing the x and y values + */ + protected static Vector2ic transformLocation(double x, double z) { + //converts an x and z to a location on the map + int transformedX = (int) ((x - 202) / 621 * 62); + int transformedY = (int) ((z - 202) / 621 * 62); + transformedX = Math.clamp(transformedX, 0, 62); + transformedY = Math.clamp(transformedY, 0, 62); + + return new Vector2i(transformedX, transformedY); + } + + /** + * Converts yaw to the cardinal directions that a player marker can be rotated towards on a map. + * The rotations of a marker follow this order: N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW. + *

+ * Based off code from {@link net.minecraft.client.render.MapRenderer} + */ + private static float yaw2Cardinal(float yaw) { + yaw += 180; //flip direction + byte clipped = (byte) ((yaw + (yaw < 0.0 ? -8.0 : 8.0)) * 16.0 / 360.0); + + return (clipped * 360f) / 16f; + } @Override public Set availableLocations() { @@ -74,9 +74,9 @@ public class CrystalsHudWidget extends HudWidget { } @Override - public boolean isEnabledIn(Location location) { - return location.equals(Location.CRYSTAL_HOLLOWS) && SkyblockerConfigManager.get().mining.crystalsHud.enabled; - } + public boolean isEnabledIn(Location location) { + return location.equals(Location.CRYSTAL_HOLLOWS) && SkyblockerConfigManager.get().mining.crystalsHud.enabled; + } @Override public void setEnabledIn(Location location, boolean enabled) { @@ -85,68 +85,69 @@ public class CrystalsHudWidget extends HudWidget { } public void update() { - if (CLIENT.player == null || CLIENT.getNetworkHandler() == null || !SkyblockerConfigManager.get().mining.crystalsHud.enabled) return; - - - //get if the player is in the crystals - float scale = SkyblockerConfigManager.get().mining.crystalsHud.mapScaling; - w = h = (int) (62 * scale); - } - - @Override - public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { - float scale = SkyblockerConfigManager.get().mining.crystalsHud.mapScaling; - - //make sure the map renders infront of some stuff - improve this in the future with better layering (1.20.5?) - //and set position and scale - MatrixStack matrices = context.getMatrices(); - matrices.push(); - matrices.translate(x, y, 0f); - matrices.scale(scale, scale, 0f); - w = h = (int) (62 * scale); - - //draw map texture - context.drawTexture(RenderLayer::getGuiTextured, MAP_TEXTURE, 0, 0, 0, 0, 62, 62, 62, 62); - - //if enabled add waypoint locations to map - if (SkyblockerConfigManager.get().mining.crystalsHud.showLocations) { - for (MiningLocationLabel waypoint : CrystalsLocationsManager.activeWaypoints.values()) { - MiningLocationLabel.Category category = waypoint.category(); - Vector2ic renderPos = transformLocation(waypoint.centerPos.getX(), waypoint.centerPos.getZ()); - int locationSize = SkyblockerConfigManager.get().mining.crystalsHud.locationSize; - - if (SMALL_LOCATIONS.contains(category.getName())) {//if small location half the location size - locationSize /= 2; - } - - //fill square of size locationSize around the coordinates of the location - context.fill(renderPos.x() - locationSize / 2, renderPos.y() - locationSize / 2, renderPos.x() + locationSize / 2, renderPos.y() + locationSize / 2, category.getColor()); - } - } - - //draw player on map - if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) { - matrices.pop(); - return; - } - //get player location - double playerX = CLIENT.player.getX(); - double playerZ = CLIENT.player.getZ(); - float playerRotation = CLIENT.player.getYaw(); //TODO make the transitions more rough? - Vector2ic renderPos = transformLocation(playerX, playerZ); - - int renderX = renderPos.x() - 2; - int renderY = renderPos.y() - 3; - - //position, scale and rotate the player marker - matrices.translate(renderX, renderY, 0f); - matrices.scale(0.75f, 0.75f, 0f); - matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(yaw2Cardinal(playerRotation)), 2.5f, 3.5f, 0); - - //draw marker on map - context.drawTexture(RenderLayer::getGuiTextured, MAP_ICON, 0, 0, 2, 0, 5, 7, 8, 8); - matrices.pop(); - } + if (CLIENT.player == null || CLIENT.getNetworkHandler() == null || !SkyblockerConfigManager.get().mining.crystalsHud.enabled) return; + + + //get if the player is in the crystals + float scale = SkyblockerConfigManager.get().mining.crystalsHud.mapScaling; + w = h = (int) (62 * scale); + } + + @Override + public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + float scale = SkyblockerConfigManager.get().mining.crystalsHud.mapScaling; + + //make sure the map renders infront of some stuff - improve this in the future with better layering (1.20.5?) + //and set position and scale + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.translate(x, y, 0f); + matrices.scale(scale, scale, 0f); + w = h = (int) (62 * scale); + + //draw map texture + context.drawTexture(RenderLayer::getGuiTextured, MAP_TEXTURE, 0, 0, 0, 0, 62, 62, 62, 62); + + //if enabled add waypoint locations to map + if (SkyblockerConfigManager.get().mining.crystalsHud.showLocations) { + for (MiningLocationLabel waypoint : CrystalsLocationsManager.activeWaypoints.values()) { + + MiningLocationLabel.Category category = waypoint.category(); + Vector2ic renderPos = transformLocation(waypoint.centerPos.getX(), waypoint.centerPos.getZ()); + int locationSize = SkyblockerConfigManager.get().mining.crystalsHud.locationSize; + + if (SMALL_LOCATIONS.contains(category.getName())) {//if small location half the location size + locationSize /= 2; + } + + //fill square of size locationSize around the coordinates of the location + context.fill(renderPos.x() - locationSize / 2, renderPos.y() - locationSize / 2, renderPos.x() + locationSize / 2, renderPos.y() + locationSize / 2, category.getColor()); + } + } + + //draw player on map + if (CLIENT.player == null || CLIENT.getNetworkHandler() == null) { + matrices.pop(); + return; + } + //get player location + double playerX = CLIENT.player.getX(); + double playerZ = CLIENT.player.getZ(); + float playerRotation = CLIENT.player.getYaw(); //TODO make the transitions more rough? + Vector2ic renderPos = transformLocation(playerX, playerZ); + + int renderX = renderPos.x() - 2; + int renderY = renderPos.y() - 3; + + //position, scale and rotate the player marker + matrices.translate(renderX, renderY, 0f); + matrices.scale(0.75f, 0.75f, 0f); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(yaw2Cardinal(playerRotation)), 2.5f, 3.5f, 0); + + //draw marker on map + context.drawTexture(RenderLayer::getGuiTextured, MAP_ICON, 0, 0, 2, 0, 5, 7, 8, 8); + matrices.pop(); + } @Override public Text getDisplayName() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java index fdf5b785..1e0ddc00 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/end/EndHudWidget.java @@ -22,36 +22,37 @@ import java.util.Set; @RegisterWidget public class EndHudWidget extends ComponentBasedWidget { - private static final MutableText TITLE = Text.literal("The End").formatted(Formatting.LIGHT_PURPLE, Formatting.BOLD); + private static final MutableText TITLE = Text.literal("The End").formatted(Formatting.LIGHT_PURPLE, Formatting.BOLD); - private static EndHudWidget instance = null; + private static EndHudWidget instance = null; public static EndHudWidget getInstance() { if (instance == null) instance = new EndHudWidget(); return instance; } - private static final NumberFormat DECIMAL_FORMAT = NumberFormat.getInstance(Locale.US); - private static final ItemStack ENDERMAN_HEAD = new ItemStack(Items.PLAYER_HEAD); - private static final ItemStack POPPY = new ItemStack(Items.POPPY); + private static final NumberFormat DECIMAL_FORMAT = NumberFormat.getInstance(Locale.US); + private static final ItemStack ENDERMAN_HEAD = new ItemStack(Items.PLAYER_HEAD); + private static final ItemStack POPPY = new ItemStack(Items.POPPY); - static { - DECIMAL_FORMAT.setMinimumFractionDigits(0); - DECIMAL_FORMAT.setMaximumFractionDigits(2); + static { + DECIMAL_FORMAT.setMinimumFractionDigits(0); + DECIMAL_FORMAT.setMaximumFractionDigits(2); - ENDERMAN_HEAD.set(DataComponentTypes.PROFILE, new ProfileComponent(Optional.of("MHF_Enderman"), Optional.empty(), new PropertyMap())); - POPPY.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true); - } + ENDERMAN_HEAD.set(DataComponentTypes.PROFILE, new ProfileComponent(Optional.of("MHF_Enderman"), Optional.empty(), new PropertyMap())); + POPPY.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true); + } - public EndHudWidget() { - super(TITLE, Formatting.DARK_PURPLE.getColorValue(), "hud_end"); + public EndHudWidget() { + super(TITLE, Formatting.DARK_PURPLE.getColorValue(), "hud_end"); instance = this; - this.update(); - } - @Override - public boolean isEnabledIn(Location location) { - return location.equals(Location.THE_END) && SkyblockerConfigManager.get().otherLocations.end.hudEnabled; - } + this.update(); + } + + @Override + public boolean isEnabledIn(Location location) { + return location.equals(Location.THE_END) && SkyblockerConfigManager.get().otherLocations.end.hudEnabled; + } @Override public void setEnabledIn(Location location, boolean enabled) { @@ -65,35 +66,35 @@ public class EndHudWidget extends ComponentBasedWidget { } @Override - public void updateContent() { - // Zealots - if (SkyblockerConfigManager.get().otherLocations.end.zealotKillsEnabled) { - addComponent(new IcoTextComponent(ENDERMAN_HEAD, Text.literal("Zealots").formatted(Formatting.BOLD))); - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsSinceLastEye", TheEnd.zealotsSinceLastEye))); - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsTotalKills", TheEnd.zealotsKilled))); - String avg = TheEnd.eyes == 0 ? "???" : DECIMAL_FORMAT.format((float) TheEnd.zealotsKilled / TheEnd.eyes); - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.avgKillsPerEye", avg))); - } - - // Endstone protector - if (SkyblockerConfigManager.get().otherLocations.end.protectorLocationEnabled) { - addComponent(new IcoTextComponent(POPPY, Text.literal("Endstone Protector").formatted(Formatting.BOLD))); - if (TheEnd.stage == 5) { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", "IMMINENT"))); - } else { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", String.valueOf(TheEnd.stage)))); - } - if (TheEnd.currentProtectorLocation == null) { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", "?"))); - } else { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", TheEnd.currentProtectorLocation.name()))); - } - } - } - - @Override - public Text getDisplayName() { - return Text.literal("End Hud"); - } + public void updateContent() { + // Zealots + if (SkyblockerConfigManager.get().otherLocations.end.zealotKillsEnabled) { + addComponent(new IcoTextComponent(ENDERMAN_HEAD, Text.literal("Zealots").formatted(Formatting.BOLD))); + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsSinceLastEye", TheEnd.zealotsSinceLastEye))); + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.zealotsTotalKills", TheEnd.zealotsKilled))); + String avg = TheEnd.eyes == 0 ? "???" : DECIMAL_FORMAT.format((float) TheEnd.zealotsKilled / TheEnd.eyes); + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.avgKillsPerEye", avg))); + } + + // Endstone protector + if (SkyblockerConfigManager.get().otherLocations.end.protectorLocationEnabled) { + addComponent(new IcoTextComponent(POPPY, Text.literal("Endstone Protector").formatted(Formatting.BOLD))); + if (TheEnd.stage == 5) { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", "IMMINENT"))); + } else { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.stage", String.valueOf(TheEnd.stage)))); + } + if (TheEnd.currentProtectorLocation == null) { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", "?"))); + } else { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.end.hud.location", TheEnd.currentProtectorLocation.name()))); + } + } + } + + @Override + public Text getDisplayName() { + return Text.literal("End Hud"); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java index 47b28fcc..777a7671 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/FarmingHudWidget.java @@ -9,8 +9,8 @@ import de.hysky.skyblocker.skyblock.tabhud.widget.ComponentBasedWidget; import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent; import de.hysky.skyblocker.skyblock.tabhud.widget.component.ProgressComponent; import de.hysky.skyblocker.utils.ItemUtils; -import it.unimi.dsi.fastutil.doubles.DoubleBooleanPair; import de.hysky.skyblocker.utils.Location; +import it.unimi.dsi.fastutil.doubles.DoubleBooleanPair; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; @@ -24,47 +24,47 @@ import java.util.Set; @RegisterWidget public class FarmingHudWidget extends ComponentBasedWidget { - private static final MutableText TITLE = Text.literal("Farming").formatted(Formatting.YELLOW, Formatting.BOLD); - public static final Map FARMING_TOOLS = Map.ofEntries( - Map.entry("THEORETICAL_HOE_WHEAT_1", "WHEAT"), - Map.entry("THEORETICAL_HOE_WHEAT_2", "WHEAT"), - Map.entry("THEORETICAL_HOE_WHEAT_3", "WHEAT"), - Map.entry("THEORETICAL_HOE_CARROT_1", "CARROT_ITEM"), - Map.entry("THEORETICAL_HOE_CARROT_2", "CARROT_ITEM"), - Map.entry("THEORETICAL_HOE_CARROT_3", "CARROT_ITEM"), - Map.entry("THEORETICAL_HOE_POTATO_1", "POTATO_ITEM"), - Map.entry("THEORETICAL_HOE_POTATO_2", "POTATO_ITEM"), - Map.entry("THEORETICAL_HOE_POTATO_3", "POTATO_ITEM"), - Map.entry("THEORETICAL_HOE_CANE_1", "SUGAR_CANE"), - Map.entry("THEORETICAL_HOE_CANE_2", "SUGAR_CANE"), - Map.entry("THEORETICAL_HOE_CANE_3", "SUGAR_CANE"), - Map.entry("THEORETICAL_HOE_WARTS_1", "NETHER_STALK"), - Map.entry("THEORETICAL_HOE_WARTS_2", "NETHER_STALK"), - Map.entry("THEORETICAL_HOE_WARTS_3", "NETHER_STALK"), - Map.entry("FUNGI_CUTTER", "RED_MUSHROOM"), - Map.entry("CACTUS_KNIFE", "CACTUS"), - Map.entry("MELON_DICER", "MELON"), - Map.entry("MELON_DICER_2", "MELON"), - Map.entry("MELON_DICER_3", "MELON"), - Map.entry("PUMPKIN_DICER", "PUMPKIN"), - Map.entry("PUMPKIN_DICER_2", "PUMPKIN"), - Map.entry("PUMPKIN_DICER_3", "PUMPKIN"), - Map.entry("COCO_CHOPPER", "INK_SACK:3") - ); - private static FarmingHudWidget instance = null; + private static final MutableText TITLE = Text.literal("Farming").formatted(Formatting.YELLOW, Formatting.BOLD); + public static final Map FARMING_TOOLS = Map.ofEntries( + Map.entry("THEORETICAL_HOE_WHEAT_1", "WHEAT"), + Map.entry("THEORETICAL_HOE_WHEAT_2", "WHEAT"), + Map.entry("THEORETICAL_HOE_WHEAT_3", "WHEAT"), + Map.entry("THEORETICAL_HOE_CARROT_1", "CARROT_ITEM"), + Map.entry("THEORETICAL_HOE_CARROT_2", "CARROT_ITEM"), + Map.entry("THEORETICAL_HOE_CARROT_3", "CARROT_ITEM"), + Map.entry("THEORETICAL_HOE_POTATO_1", "POTATO_ITEM"), + Map.entry("THEORETICAL_HOE_POTATO_2", "POTATO_ITEM"), + Map.entry("THEORETICAL_HOE_POTATO_3", "POTATO_ITEM"), + Map.entry("THEORETICAL_HOE_CANE_1", "SUGAR_CANE"), + Map.entry("THEORETICAL_HOE_CANE_2", "SUGAR_CANE"), + Map.entry("THEORETICAL_HOE_CANE_3", "SUGAR_CANE"), + Map.entry("THEORETICAL_HOE_WARTS_1", "NETHER_STALK"), + Map.entry("THEORETICAL_HOE_WARTS_2", "NETHER_STALK"), + Map.entry("THEORETICAL_HOE_WARTS_3", "NETHER_STALK"), + Map.entry("FUNGI_CUTTER", "RED_MUSHROOM"), + Map.entry("CACTUS_KNIFE", "CACTUS"), + Map.entry("MELON_DICER", "MELON"), + Map.entry("MELON_DICER_2", "MELON"), + Map.entry("MELON_DICER_3", "MELON"), + Map.entry("PUMPKIN_DICER", "PUMPKIN"), + Map.entry("PUMPKIN_DICER_2", "PUMPKIN"), + Map.entry("PUMPKIN_DICER_3", "PUMPKIN"), + Map.entry("COCO_CHOPPER", "INK_SACK:3") + ); + private static FarmingHudWidget instance = null; public static FarmingHudWidget getInstance() { if (instance == null) instance = new FarmingHudWidget(); return instance; } - private final MinecraftClient client = MinecraftClient.getInstance(); + private final MinecraftClient client = MinecraftClient.getInstance(); - public FarmingHudWidget() { - super(TITLE, Formatting.YELLOW.getColorValue(), "hud_farming"); + public FarmingHudWidget() { + super(TITLE, Formatting.YELLOW.getColorValue(), "hud_farming"); instance = this; - update(); - } + update(); + } @Override protected boolean shouldUpdateBeforeRendering() { @@ -72,57 +72,57 @@ public class FarmingHudWidget extends ComponentBasedWidget { } @Override - public void updateContent() { - if (client.player == null) { - addComponent(new PlainTextComponent(Text.literal("Nothing to show :p"))); - return; - } - ItemStack farmingToolStack = client.player.getMainHandStack(); - if (farmingToolStack == null) return; - String itemId = ItemUtils.getItemId(farmingToolStack); - String cropItemId = FARMING_TOOLS.getOrDefault(itemId, ""); - ItemStack cropStack = ItemRepository.getItemStack(cropItemId.replace(":", "-")); // Hacky conversion to neu id since ItemUtils.getNeuId requires an item stack. - - String counterText = FarmingHud.counterText(); - String counterNumber = FarmingHud.NUMBER_FORMAT.format(FarmingHud.counter()); - if (FarmingHud.CounterType.NONE.matchesText(counterText)) counterNumber = ""; - addSimpleIcoText(cropStack, counterText, Formatting.YELLOW, counterNumber); - float cropsPerMinute = FarmingHud.cropsPerMinute(); - addSimpleIcoText(cropStack, "Crops/min: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) cropsPerMinute / 10 * 10)); - addSimpleIcoText(Ico.GOLD, "Coins/h: ", Formatting.GOLD, getPriceText(cropItemId, cropsPerMinute)); - addSimpleIcoText(cropStack, "Blocks/s: ", Formatting.YELLOW, Integer.toString(FarmingHud.blockBreaks())); - //noinspection DataFlowIssue - addComponent(new ProgressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue())); - addSimpleIcoText(Ico.LIME_DYE, "Farming XP/h: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.farmingXpPerHour())); - - Entity cameraEntity = client.getCameraEntity(); - String yaw = cameraEntity == null ? "No Camera Entity" : String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getYaw())); - String pitch = cameraEntity == null ? "No Camera Entity" : String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getPitch())); - addComponent(new PlainTextComponent(Text.literal("Yaw: " + yaw).formatted(Formatting.GOLD))); - addComponent(new PlainTextComponent(Text.literal("Pitch: " + pitch).formatted(Formatting.GOLD))); - if (LowerSensitivity.isSensitivityLowered()) { - addComponent(new PlainTextComponent(Text.translatable("skyblocker.garden.hud.mouseLocked").formatted(Formatting.ITALIC))); - } - } - - /** - * Gets the price text of the given crop id, calculated with the given crops per minute and the npc price if it's higher than the bazaar sell price, or the bazaar sell price otherwise. - */ - private String getPriceText(String cropItemId, float cropsPerMinute) { - DoubleBooleanPair itemBazaarPrice = ItemUtils.getItemPrice(cropItemId); // Gets the bazaar sell price of the crop. - double itemNpcPrice = TooltipInfoType.NPC.hasOrNullWarning(cropItemId) ? TooltipInfoType.NPC.getData().getDouble(cropItemId) : Double.MIN_VALUE; // Gets the npc sell price of the crop or set to the min double value if it doesn't exist. - boolean shouldUseNpcPrice = itemNpcPrice > itemBazaarPrice.leftDouble(); // Use the npc price if it's more than the bazaar sell price. - double price = shouldUseNpcPrice ? itemNpcPrice : itemBazaarPrice.leftDouble(); // same as above - - // Return the formatted price if npc price is higher or bazaar price is present. - // Multiply by 60 to convert to hourly and divide by 100 for rounding is combined into multiplying by 0.6. - return shouldUseNpcPrice || itemBazaarPrice.rightBoolean() ? FarmingHud.NUMBER_FORMAT.format((int) (price * cropsPerMinute * 0.6) * 100) : "No Data"; - } - - @Override - public boolean isEnabledIn(Location location) { - return location.equals(Location.GARDEN) && SkyblockerConfigManager.get().farming.garden.farmingHud.enableHud; - } + public void updateContent() { + if (client.player == null) { + addComponent(new PlainTextComponent(Text.literal("Nothing to show :p"))); + return; + } + ItemStack farmingToolStack = client.player.getMainHandStack(); + if (farmingToolStack == null) return; + String itemId = ItemUtils.getItemId(farmingToolStack); + String cropItemId = FARMING_TOOLS.getOrDefault(itemId, ""); + ItemStack cropStack = ItemRepository.getItemStack(cropItemId.replace(":", "-")); // Hacky conversion to neu id since ItemUtils.getNeuId requires an item stack. + + String counterText = FarmingHud.counterText(); + String counterNumber = FarmingHud.NUMBER_FORMAT.format(FarmingHud.counter()); + if (FarmingHud.CounterType.NONE.matchesText(counterText)) counterNumber = ""; + addSimpleIcoText(cropStack, counterText, Formatting.YELLOW, counterNumber); + float cropsPerMinute = FarmingHud.cropsPerMinute(); + addSimpleIcoText(cropStack, "Crops/min: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) cropsPerMinute / 10 * 10)); + addSimpleIcoText(Ico.GOLD, "Coins/h: ", Formatting.GOLD, getPriceText(cropItemId, cropsPerMinute)); + addSimpleIcoText(cropStack, "Blocks/s: ", Formatting.YELLOW, Integer.toString(FarmingHud.blockBreaks())); + //noinspection DataFlowIssue + addComponent(new ProgressComponent(Ico.LANTERN, Text.literal("Farming Level: "), FarmingHud.farmingXpPercentProgress(), Formatting.GOLD.getColorValue())); + addSimpleIcoText(Ico.LIME_DYE, "Farming XP/h: ", Formatting.YELLOW, FarmingHud.NUMBER_FORMAT.format((int) FarmingHud.farmingXpPerHour())); + + Entity cameraEntity = client.getCameraEntity(); + String yaw = cameraEntity == null ? "No Camera Entity" : String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getYaw())); + String pitch = cameraEntity == null ? "No Camera Entity" : String.format("%.2f", MathHelper.wrapDegrees(cameraEntity.getPitch())); + addComponent(new PlainTextComponent(Text.literal("Yaw: " + yaw).formatted(Formatting.GOLD))); + addComponent(new PlainTextComponent(Text.literal("Pitch: " + pitch).formatted(Formatting.GOLD))); + if (LowerSensitivity.isSensitivityLowered()) { + addComponent(new PlainTextComponent(Text.translatable("skyblocker.garden.hud.mouseLocked").formatted(Formatting.ITALIC))); + } + } + + /** + * Gets the price text of the given crop id, calculated with the given crops per minute and the npc price if it's higher than the bazaar sell price, or the bazaar sell price otherwise. + */ + private String getPriceText(String cropItemId, float cropsPerMinute) { + DoubleBooleanPair itemBazaarPrice = ItemUtils.getItemPrice(cropItemId); // Gets the bazaar sell price of the crop. + double itemNpcPrice = TooltipInfoType.NPC.hasOrNullWarning(cropItemId) ? TooltipInfoType.NPC.getData().getDouble(cropItemId) : Double.MIN_VALUE; // Gets the npc sell price of the crop or set to the min double value if it doesn't exist. + boolean shouldUseNpcPrice = itemNpcPrice > itemBazaarPrice.leftDouble(); // Use the npc price if it's more than the bazaar sell price. + double price = shouldUseNpcPrice ? itemNpcPrice : itemBazaarPrice.leftDouble(); // same as above + + // Return the formatted price if npc price is higher or bazaar price is present. + // Multiply by 60 to convert to hourly and divide by 100 for rounding is combined into multiplying by 0.6. + return shouldUseNpcPrice || itemBazaarPrice.rightBoolean() ? FarmingHud.NUMBER_FORMAT.format((int) (price * cropsPerMinute * 0.6) * 100) : "No Data"; + } + + @Override + public boolean isEnabledIn(Location location) { + return location.equals(Location.GARDEN) && SkyblockerConfigManager.get().farming.garden.farmingHud.enableHud; + } @Override public void setEnabledIn(Location location, boolean enabled) { @@ -136,7 +136,7 @@ public class FarmingHudWidget extends ComponentBasedWidget { } @Override - public Text getDisplayName() { - return Text.literal("Farming HUD"); - } + public Text getDisplayName() { + return Text.literal("Farming HUD"); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java index bf10dc9e..7b41629e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/TabHud.java @@ -1,41 +1,40 @@ package de.hysky.skyblocker.skyblock.tabhud; import de.hysky.skyblocker.annotations.Init; -import org.lwjgl.glfw.GLFW; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; +import org.lwjgl.glfw.GLFW; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TabHud { - public static KeyBinding toggleB; - public static KeyBinding toggleSecondary; - // public static KeyBinding mapTgl; - public static KeyBinding defaultTgl; - - public static final Logger LOGGER = LoggerFactory.getLogger("Skyblocker Tab HUD"); - - @Init - public static void init() { - - toggleB = KeyBindingHelper.registerKeyBinding( - new KeyBinding("key.skyblocker.toggleB", - InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_B, - "key.categories.skyblocker")); - toggleSecondary = KeyBindingHelper.registerKeyBinding( - new KeyBinding("key.skyblocker.toggleA", - InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_Z, - "key.categories.skyblocker")); - defaultTgl = KeyBindingHelper.registerKeyBinding( - new KeyBinding("key.skyblocker.defaultTgl", - InputUtil.Type.KEYSYM, - GLFW.GLFW_KEY_M, - "key.categories.skyblocker")); - - } + public static KeyBinding toggleB; + public static KeyBinding toggleSecondary; + // public static KeyBinding mapTgl; + public static KeyBinding defaultTgl; + + public static final Logger LOGGER = LoggerFactory.getLogger("Skyblocker Tab HUD"); + + @Init + public static void init() { + + toggleB = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.skyblocker.toggleB", + InputUtil.Type.KEYSYM, + GLFW.GLFW_KEY_B, + "key.categories.skyblocker")); + toggleSecondary = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.skyblocker.toggleA", + InputUtil.Type.KEYSYM, + GLFW.GLFW_KEY_Z, + "key.categories.skyblocker")); + defaultTgl = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.skyblocker.defaultTgl", + InputUtil.Type.KEYSYM, + GLFW.GLFW_KEY_M, + "key.categories.skyblocker")); + + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/DungeonsTabPlaceholder.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/DungeonsTabPlaceholder.java index 8e264e52..a709dec6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/DungeonsTabPlaceholder.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/DungeonsTabPlaceholder.java @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList; import com.google.gson.JsonElement; import com.mojang.serialization.JsonOps; import de.hysky.skyblocker.SkyblockerMod; -import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.text.TextCodecs; @@ -13,97 +12,97 @@ import java.util.List; public final class DungeonsTabPlaceholder { - private static List placeholder = null; + private static List placeholder = null; - public static List get() { - if (placeholder != null) return placeholder; - List l = new ArrayList<>(); - List json = List.of( - "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Party \",\"color\":\"aqua\",\"bold\":true},{\"text\":\"(1)\",\"color\":\"white\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"[\",\"color\":\"dark_gray\"},{\"text\":\"303\",\"color\":\"blue\"},{\"text\":\"] \",\"color\":\"dark_gray\"},{\"text\":\"AzureAaron \",\"color\":\"aqua\"},{\"text\":\"⚡ \",\"color\":\"gold\",\"bold\":true},{\"text\":\"(\",\"color\":\"white\"},{\"text\":\"\",\"color\":\"light_purple\"},{\"text\":\"EMPTY\",\"color\":\"gray\"},{\"text\":\")\",\"color\":\"white\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Ultimate: \",{\"text\":\"\",\"color\":\"yellow\"},{\"text\":\"N/A\",\"color\":\"red\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Revive Stones: \",{\"text\":\"0\",\"color\":\"red\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Player Stats\",\"color\":\"dark_green\",\"bold\":true}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Downed: \",\"color\":\"green\",\"bold\":true},{\"text\":\"NONE\",\"color\":\"gray\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Time: \",{\"text\":\"N/A\",\"color\":\"yellow\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Revive: \",{\"text\":\"N/A\",\"color\":\"red\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Team Deaths: \",\"color\":\"green\",\"bold\":true},{\"text\":\"0\",\"color\":\"white\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Team Damage Dealt: \",{\"text\":\"0❤\",\"color\":\"red\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Team Healing Done: \",{\"text\":\"0❤\",\"color\":\"red\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Your Milestone: \",{\"text\":\"?\",\"color\":\"yellow\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Discoveries: \",\"color\":\"green\",\"bold\":true},{\"text\":\"0\",\"color\":\"white\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Secrets Found: \",{\"text\":\"0\",\"color\":\"aqua\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Crypts: \",{\"text\":\"0\",\"color\":\"gold\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Dungeon Stats\",\"color\":\"dark_aqua\",\"bold\":true}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Dungeon: \",\"color\":\"aqua\",\"bold\":true},{\"text\":\"Catacombs\",\"color\":\"gray\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Opened Rooms: \",{\"text\":\"0\",\"color\":\"dark_purple\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Completed Rooms: \",{\"text\":\"0\",\"color\":\"light_purple\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Secrets Found: \",{\"text\":\"0%\",\"color\":\"yellow\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Time: \",{\"text\":\"Soon!\",\"color\":\"gold\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Puzzles: \",\"color\":\"aqua\",\"bold\":true},{\"text\":\"(2)\",\"color\":\"white\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" ???: \",{\"text\":\"[\",\"color\":\"gray\"},{\"text\":\"✦\",\"color\":\"gold\",\"bold\":true},{\"text\":\"]\",\"color\":\"gray\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" ???: \",{\"text\":\"[\",\"color\":\"gray\"},{\"text\":\"✦\",\"color\":\"gold\",\"bold\":true},{\"text\":\"]\",\"color\":\"gray\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Account Info\",\"color\":\"gold\",\"bold\":true}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Profile: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Blueberry\",\"color\":\"green\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Pet Sitter: \",{\"text\":\"N/A\",\"color\":\"aqua\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Bank: \",{\"text\":\"1B\",\"color\":\"gold\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Interest: \",{\"text\":\"27 Hours\",\"color\":\"yellow\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Skills: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Foraging 23: \",\"color\":\"green\"},{\"text\":\"11.4%\",\"color\":\"dark_aqua\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Speed: \",{\"text\":\"✦319\",\"color\":\"white\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Strength: \",{\"text\":\"❁5222\",\"color\":\"red\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Crit Chance: \",{\"text\":\"☣168\",\"color\":\"blue\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Crit Damage: \",{\"text\":\"☠3588\",\"color\":\"blue\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Attack Speed: \",{\"text\":\"⚔100\",\"color\":\"yellow\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Event: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Election Booth Opens\",\"color\":\"aqua\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" Starts In: \",{\"text\":\"26h\",\"color\":\"yellow\"}],\"italic\":false}", - "{\"text\":\"\",\"italic\":false}", - "{\"text\":\"\",\"extra\":[{\"text\":\"Election: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Over!\",\"color\":\"red\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Winner: \",\"color\":\"white\"},{\"text\":\"Marina\",\"color\":\"green\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Participants: \",\"color\":\"white\"},{\"text\":\"84,448\",\"color\":\"aqua\"}],\"italic\":false}", - "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Year: \",\"color\":\"white\"},{\"text\":\"358\",\"color\":\"light_purple\"}],\"italic\":false}"); + public static List get() { + if (placeholder != null) return placeholder; + List l = new ArrayList<>(); + List json = List.of( + "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Party \",\"color\":\"aqua\",\"bold\":true},{\"text\":\"(1)\",\"color\":\"white\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"[\",\"color\":\"dark_gray\"},{\"text\":\"303\",\"color\":\"blue\"},{\"text\":\"] \",\"color\":\"dark_gray\"},{\"text\":\"AzureAaron \",\"color\":\"aqua\"},{\"text\":\"⚡ \",\"color\":\"gold\",\"bold\":true},{\"text\":\"(\",\"color\":\"white\"},{\"text\":\"\",\"color\":\"light_purple\"},{\"text\":\"EMPTY\",\"color\":\"gray\"},{\"text\":\")\",\"color\":\"white\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Ultimate: \",{\"text\":\"\",\"color\":\"yellow\"},{\"text\":\"N/A\",\"color\":\"red\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Revive Stones: \",{\"text\":\"0\",\"color\":\"red\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Player Stats\",\"color\":\"dark_green\",\"bold\":true}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Downed: \",\"color\":\"green\",\"bold\":true},{\"text\":\"NONE\",\"color\":\"gray\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Time: \",{\"text\":\"N/A\",\"color\":\"yellow\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Revive: \",{\"text\":\"N/A\",\"color\":\"red\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Team Deaths: \",\"color\":\"green\",\"bold\":true},{\"text\":\"0\",\"color\":\"white\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Team Damage Dealt: \",{\"text\":\"0❤\",\"color\":\"red\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Team Healing Done: \",{\"text\":\"0❤\",\"color\":\"red\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Your Milestone: \",{\"text\":\"?\",\"color\":\"yellow\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Discoveries: \",\"color\":\"green\",\"bold\":true},{\"text\":\"0\",\"color\":\"white\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Secrets Found: \",{\"text\":\"0\",\"color\":\"aqua\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Crypts: \",{\"text\":\"0\",\"color\":\"gold\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Dungeon Stats\",\"color\":\"dark_aqua\",\"bold\":true}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Dungeon: \",\"color\":\"aqua\",\"bold\":true},{\"text\":\"Catacombs\",\"color\":\"gray\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Opened Rooms: \",{\"text\":\"0\",\"color\":\"dark_purple\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Completed Rooms: \",{\"text\":\"0\",\"color\":\"light_purple\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Secrets Found: \",{\"text\":\"0%\",\"color\":\"yellow\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Time: \",{\"text\":\"Soon!\",\"color\":\"gold\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Puzzles: \",\"color\":\"aqua\",\"bold\":true},{\"text\":\"(2)\",\"color\":\"white\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" ???: \",{\"text\":\"[\",\"color\":\"gray\"},{\"text\":\"✦\",\"color\":\"gold\",\"bold\":true},{\"text\":\"]\",\"color\":\"gray\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" ???: \",{\"text\":\"[\",\"color\":\"gray\"},{\"text\":\"✦\",\"color\":\"gold\",\"bold\":true},{\"text\":\"]\",\"color\":\"gray\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Account Info\",\"color\":\"gold\",\"bold\":true}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Profile: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Blueberry\",\"color\":\"green\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Pet Sitter: \",{\"text\":\"N/A\",\"color\":\"aqua\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Bank: \",{\"text\":\"1B\",\"color\":\"gold\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Interest: \",{\"text\":\"27 Hours\",\"color\":\"yellow\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Skills: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Foraging 23: \",\"color\":\"green\"},{\"text\":\"11.4%\",\"color\":\"dark_aqua\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Speed: \",{\"text\":\"✦319\",\"color\":\"white\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Strength: \",{\"text\":\"❁5222\",\"color\":\"red\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Crit Chance: \",{\"text\":\"☣168\",\"color\":\"blue\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Crit Damage: \",{\"text\":\"☠3588\",\"color\":\"blue\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Attack Speed: \",{\"text\":\"⚔100\",\"color\":\"yellow\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Event: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Election Booth Opens\",\"color\":\"aqua\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" Starts In: \",{\"text\":\"26h\",\"color\":\"yellow\"}],\"italic\":false}", + "{\"text\":\"\",\"italic\":false}", + "{\"text\":\"\",\"extra\":[{\"text\":\"Election: \",\"color\":\"yellow\",\"bold\":true},{\"text\":\"Over!\",\"color\":\"red\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Winner: \",\"color\":\"white\"},{\"text\":\"Marina\",\"color\":\"green\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Participants: \",\"color\":\"white\"},{\"text\":\"84,448\",\"color\":\"aqua\"}],\"italic\":false}", + "{\"text\":\"\",\"extra\":[\" \",{\"text\":\"Year: \",\"color\":\"white\"},{\"text\":\"358\",\"color\":\"light_purple\"}],\"italic\":false}"); - for (String s : json) { - l.add(TextCodecs.CODEC.decode(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(s, JsonElement.class)).getOrThrow().getFirst()); - } + for (String s : json) { + l.add(TextCodecs.CODEC.decode(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(s, JsonElement.class)).getOrThrow().getFirst()); + } - return placeholder = ImmutableList.copyOf(l); - } + return placeholder = ImmutableList.copyOf(l); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java index a7b26da8..71c5b494 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java @@ -34,108 +34,113 @@ import java.util.Map; import java.util.function.Consumer; public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerListener { - public static final Logger LOGGER = LogUtils.getLogger(); + public static final Logger LOGGER = LogUtils.getLogger(); - private @Nullable GenericContainerScreenHandler handler; - private String titleLowercase; - public final boolean noHandler; - private ScreenMaster.ScreenLayer widgetsLayer = null; - private Screen parent = null; + private @Nullable GenericContainerScreenHandler handler; + private String titleLowercase; + public final boolean noHandler; + private ScreenMaster.ScreenLayer widgetsLayer = null; + private Screen parent = null; - private boolean tabPreview = false; - private PreviewTab previewTab; + private boolean tabPreview = false; + private PreviewTab previewTab; - private final Map nameToLocation = Map.ofEntries( - Map.entry("private islands", Location.PRIVATE_ISLAND), - Map.entry("the hub", Location.HUB), - Map.entry("the dungeon hub", Location.DUNGEON_HUB), - Map.entry("the farming islands", Location.THE_FARMING_ISLAND), - Map.entry("garden", Location.GARDEN), - Map.entry("the park", Location.THE_PARK), - Map.entry("the gold mine", Location.GOLD_MINE), - Map.entry("deep caverns", Location.DEEP_CAVERNS), - Map.entry("dwarven mines", Location.DWARVEN_MINES), - Map.entry("crystal hollows", Location.CRYSTAL_HOLLOWS), - Map.entry("the mineshaft", Location.GLACITE_MINESHAFT), - Map.entry("spider's den", Location.SPIDERS_DEN), - Map.entry("the end", Location.THE_END), - Map.entry("crimson isle", Location.CRIMSON_ISLE), - Map.entry("kuudra", Location.KUUDRAS_HOLLOW), - Map.entry("the rift", Location.THE_RIFT), - Map.entry("jerry's workshop", Location.WINTER_ISLAND) - ); - private Location currentLocation = Utils.getLocation(); + private final Map nameToLocation = Map.ofEntries( + Map.entry("private islands", Location.PRIVATE_ISLAND), + Map.entry("the hub", Location.HUB), + Map.entry("the dungeon hub", Location.DUNGEON_HUB), + Map.entry("the farming islands", Location.THE_FARMING_ISLAND), + Map.entry("garden", Location.GARDEN), + Map.entry("the park", Location.THE_PARK), + Map.entry("the gold mine", Location.GOLD_MINE), + Map.entry("deep caverns", Location.DEEP_CAVERNS), + Map.entry("dwarven mines", Location.DWARVEN_MINES), + Map.entry("crystal hollows", Location.CRYSTAL_HOLLOWS), + Map.entry("the mineshaft", Location.GLACITE_MINESHAFT), + Map.entry("spider's den", Location.SPIDERS_DEN), + Map.entry("the end", Location.THE_END), + Map.entry("crimson isle", Location.CRIMSON_ISLE), + Map.entry("kuudra", Location.KUUDRAS_HOLLOW), + Map.entry("the rift", Location.THE_RIFT), + Map.entry("jerry's workshop", Location.WINTER_ISLAND) + ); + private Location currentLocation = Utils.getLocation(); - public Location getCurrentLocation() { - return currentLocation; - } + public Location getCurrentLocation() { + return currentLocation; + } - public boolean isPreviewVisible() { - return tabPreview; - } + public boolean isPreviewVisible() { + return tabPreview; + } - // Tabs and stuff - private final TabManager tabManager = new TabManager(this::addDrawableChild, this::remove); - private TabNavigationWidget tabNavigation; - private WidgetsListTab widgetsListTab; + // Tabs and stuff + private final TabManager tabManager = new TabManager(this::addDrawableChild, this::remove); + private TabNavigationWidget tabNavigation; + private WidgetsListTab widgetsListTab; - private boolean switchingToPopup = false; + private boolean switchingToPopup = false; - /** - * Creates the screen to configure, putting the handler at null will hide the first tab. Putting it to null is used in the config - * @param handler the container handler - * @param titleLowercase the title in lowercase - */ - private WidgetsConfigurationScreen(@Nullable GenericContainerScreenHandler handler, String titleLowercase, Location targetLocation, @Nullable ScreenMaster.ScreenLayer widgetLayerToGoTo) { - super(Text.literal("Widgets Configuration")); - this.handler = handler; - this.titleLowercase = titleLowercase; - this.noHandler = handler == null; - if (!noHandler) { - this.handler.addListener(this); - parseLocation(); - } else { - currentLocation = targetLocation; - widgetsLayer = widgetLayerToGoTo; - } - ScreenMaster.getScreenBuilder(currentLocation).backupPositioning(); - } + /** + * Creates the screen to configure, putting the handler at null will hide the first tab. Putting it to null is used in the config + * + * @param handler the container handler + * @param titleLowercase the title in lowercase + */ + private WidgetsConfigurationScreen(@Nullable GenericContainerScreenHandler handler, String titleLowercase, Location targetLocation, @Nullable ScreenMaster.ScreenLayer widgetLayerToGoTo) { + super(Text.literal("Widgets Configuration")); + this.handler = handler; + this.titleLowercase = titleLowercase; + this.noHandler = handler == null; + if (!noHandler) { + this.handler.addListener(this); + parseLocation(); + } else { + currentLocation = targetLocation; + widgetsLayer = widgetLayerToGoTo; + } + ScreenMaster.getScreenBuilder(currentLocation).backupPositioning(); + } - /** - * Create the screen for when backed by hypixel's widgets menu - * @param handler the container handler - * @param titleLowercase the title in lowercase, to figure out where you are - */ - public WidgetsConfigurationScreen(@NotNull GenericContainerScreenHandler handler, String titleLowercase) { - this(handler, titleLowercase, Location.UNKNOWN, null); - } + /** + * Create the screen for when backed by hypixel's widgets menu + * + * @param handler the container handler + * @param titleLowercase the title in lowercase, to figure out where