From af46b0c6b8d38d876e59e523d4af4c939053a988 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Fri, 22 Mar 2024 08:43:08 +0100 Subject: start --- .../skyblock/auction/AuctionBrowserScreen.java | 20 ++++ .../auction/AuctionHouseScreenHandler.java | 40 ++++++++ .../skyblock/auction/SlotClickHandler.java | 11 +++ .../auction/widgets/AuctionTypeWidget.java | 66 +++++++++++++ .../auction/widgets/CategoryTabWidget.java | 61 ++++++++++++ .../skyblock/auction/widgets/SliderWidget.java | 110 +++++++++++++++++++++ .../skyblock/auction/widgets/SortWidget.java | 66 +++++++++++++ 7 files changed, 374 insertions(+) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/SlotClickHandler.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java new file mode 100644 index 00000000..48b528ee --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -0,0 +1,20 @@ +package de.hysky.skyblocker.skyblock.auction; + +import de.hysky.skyblocker.SkyblockerMod; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +public class AuctionBrowserScreen extends HandledScreen { + protected static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background.png"); + public AuctionBrowserScreen(AuctionHouseScreenHandler handler, PlayerInventory inventory, Text title) { + super(handler, inventory, title); + } + + @Override + protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { + context.drawTexture(TEXTURE, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight); + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java new file mode 100644 index 00000000..58adfc6c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java @@ -0,0 +1,40 @@ +package de.hysky.skyblocker.skyblock.auction; + +import de.hysky.skyblocker.mixin.accessor.SlotAccessor; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.Inventory; +import net.minecraft.screen.GenericContainerScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.screen.slot.Slot; + +public class AuctionHouseScreenHandler extends GenericContainerScreenHandler { + public AuctionHouseScreenHandler(ScreenHandlerType type, int syncId, PlayerInventory playerInventory, Inventory inventory, int rows, boolean isView) { + super(type, syncId, playerInventory, inventory, rows); + + int yOffset = (rows - 4) * 18; + // Shift player inventory by 2 pixels and also remove the yOffset + for (int i = rows*9; i < slots.size(); i++) { + SlotAccessor slotAccessor = (SlotAccessor) slots.get(i); + slotAccessor.setY(2-yOffset); + } + + if (isView) return; + // disable ALL THE OTHER SLOTS MWAHAHAHA and also move the good ones around and stuff + for (int i = 9; i < (rows-1)*9; i++) { + int lineI = i % 9; + Slot slot = slots.get(i); + if (lineI > 1 && lineI < 8) { + SlotAccessor slotAccessor = (SlotAccessor) slot; + slotAccessor.setX(8+ lineI * 18); + slotAccessor.setY(18 + (i/9 -1) * 18); + } else { + slots.set(i, new Slot(slot.inventory, slot.getIndex(), slot.x, slot.y){ + @Override + public boolean isEnabled() { + return false; + } + }); + } + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/SlotClickHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/SlotClickHandler.java new file mode 100644 index 00000000..b64a4583 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/SlotClickHandler.java @@ -0,0 +1,11 @@ +package de.hysky.skyblocker.skyblock.auction; + +@FunctionalInterface +public interface SlotClickHandler { + + void click(int slot, int button); + + default void click(int slot) { + click(slot, 0); + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java new file mode 100644 index 00000000..64410d72 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java @@ -0,0 +1,66 @@ +package de.hysky.skyblocker.skyblock.auction.widgets; + +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.MathHelper; + +public class AuctionTypeWidget extends SliderWidget { + + /** + * @param x x position + * @param y y position + * @param slotClick IDK figure it out + */ + public AuctionTypeWidget(int x, int y, SlotClickHandler slotClick) { + super(x, y, 17, 17, Text.literal("Auction Type Widget"), slotClick, Option.ALL); + } + + public enum Option implements OptionInfo { + ALL("all.png"), + BIN("bin.png"), + AUC("auctions.png"); + + private final Identifier texture; + private static final String prefix = "textures/gui/auctions_gui/auction_type_widget/"; + private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "hover.png"); + private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE,prefix + "back.png"); + + Option(String textureName) { + texture = new Identifier(SkyblockerMod.NAMESPACE, prefix + textureName); + } + private static final AuctionTypeWidget.Option[] values = values(); + public static AuctionTypeWidget.Option get(int ordinal) {return values[MathHelper.clamp(ordinal, 0, values.length-1)];} + + @Override + public boolean isVertical() { + return true; + } + + @Override + public int getOffset() { + return 4 * ordinal(); + } + + @Override + public int[] getOptionSize() { + return new int[]{17, 9}; + } + + @Override + public Identifier getOptionTexture() { + return texture; + } + + @Override + public Identifier getBackTexture() { + return BACK_TEXTURE; + } + + @Override + public Identifier getHoverTexture() { + return HOVER_TEXTURE; + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java new file mode 100644 index 00000000..6c515e50 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java @@ -0,0 +1,61 @@ +package de.hysky.skyblocker.skyblock.auction.widgets; + +import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.ButtonTextures; +import net.minecraft.client.gui.widget.ToggleButtonWidget; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Identifier; +import org.jetbrains.annotations.NotNull; + +public class CategoryTabWidget extends ToggleButtonWidget { + private static final ButtonTextures TEXTURES = new ButtonTextures(new Identifier("recipe_book/tab"), new Identifier("recipe_book/tab_selected")); + + public void setIcon(@NotNull ItemStack icon) { + this.icon = icon.copy(); + } + + private @NotNull ItemStack icon; + private final SlotClickHandler slotClick; + private int slotId = -1; + + public CategoryTabWidget(@NotNull ItemStack icon, SlotClickHandler slotClick) { + super(0, 0, 35, 27, false); + this.icon = icon.copy(); // copy prevents item disappearing on click + this.slotClick = slotClick; + setTextures(TEXTURES); + } + + @Override + public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + if (textures == null) return; + Identifier identifier = textures.get(true, this.toggled); + int x = getX(); + if (toggled) x-=2; + //RenderSystem.disableDepthTest(); + context.drawGuiTexture(identifier, x, this.getY(), this.width, this.height); + //RenderSystem.enableDepthTest(); + context.drawItem(icon, x+9, getY()+5); + + if (isMouseOver(mouseX, mouseY)) { + context.getMatrices().push(); + //context.getMatrices().translate(0, 0, 500f); + context.drawTooltip(MinecraftClient.getInstance().textRenderer, icon.getTooltip(MinecraftClient.getInstance().player, TooltipContext.BASIC), mouseX, mouseY); + context.getMatrices().pop(); + } + + } + + public void setSlotId(int slotId) { + this.slotId = slotId; + } + + @Override + public void onClick(double mouseX, double mouseY) { + if (this.toggled || slotId == -1) return; + slotClick.click(slotId); + this.setToggled(true); + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java new file mode 100644 index 00000000..97543d23 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java @@ -0,0 +1,110 @@ +package de.hysky.skyblocker.skyblock.auction.widgets; + +import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; +import net.minecraft.client.gui.widget.ClickableWidget; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +import java.util.function.Consumer; +import java.util.function.DoubleConsumer; + +// This is kinda excessive, but I thought it was a good idea +public class SliderWidget & SliderWidget.OptionInfo> extends ClickableWidget { + private final SlotClickHandler clickSlot; + private int button = 0; + private int slotId = -1; + + protected E current; + + float posProgress; + + /** + * + * @param x x position + * @param y y position + * @param width width + * @param height height + * @param message probably useless, just put the widget name + * @param clickSlot the parent AuctionsBrowser + * @param defaultOption the default option should be the one at ordinal 0 + */ + public SliderWidget(int x, int y, int width, int height, Text message, SlotClickHandler clickSlot, E defaultOption) { + super(x, y, width, height, message); + this.clickSlot = clickSlot; + this.current = defaultOption; + posProgress = current.getOffset(); + } + + @Override + protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + if (posProgress < current.getOffset()) { + posProgress += delta * 5; + if (posProgress > current.getOffset()) posProgress = current.getOffset(); + } else if (posProgress > current.getOffset()) { + posProgress -= delta * 5; + if (posProgress < current.getOffset()) posProgress = current.getOffset(); + } + + + context.getMatrices().push(); + context.getMatrices().translate(getX(), getY(), 0); + + int x = current.isVertical() ? 0: Math.round(posProgress); + int y = current.isVertical() ? Math.round(posProgress): 0; + + int optionWidth = current.getOptionSize()[0]; + int optionHeight = current.getOptionSize()[1]; + + //context.drawText(parent.getTextRender(), String.valueOf(slotId), 0, -9, Colors.RED, true); + context.drawTexture(current.getBackTexture(), 0, 0, 0, 0, getWidth(), getHeight(), getWidth(), getHeight()); + context.drawTexture(current.getOptionTexture(), x, y, 0, 0, optionWidth, optionHeight, optionWidth, optionHeight); + if (isHovered()) { + context.drawTexture(current.getHoverTexture(), x, y, 0, 0, optionWidth, optionHeight, optionWidth, optionHeight); + + } + context.getMatrices().pop(); + } + + @Override + public void onClick(double mouseX, double mouseY) { + if (slotId == -1) return; + clickSlot.click(slotId, button); + super.onClick(mouseX, mouseY); + } + + @Override + protected boolean isValidClickButton(int button) { + this.button = button; + return super.isValidClickButton(button) || button == 1; + } + + public void setSlotId(int slotId) { + this.slotId = slotId; + } + + public void setCurrent(E current) { + this.current = current; + } + + @Override + protected void appendClickableNarrations(NarrationMessageBuilder builder) {} + public interface OptionInfo { + boolean isVertical(); + + /** + * @return The current option's position offset from the first option's position + */ + int getOffset(); + + int[] getOptionSize(); + + Identifier getOptionTexture(); + + Identifier getBackTexture(); + + Identifier getHoverTexture(); + + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java new file mode 100644 index 00000000..62c3a497 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java @@ -0,0 +1,66 @@ +package de.hysky.skyblocker.skyblock.auction.widgets; + +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.MathHelper; + +public class SortWidget extends SliderWidget { + + /** + * @param x x position + * @param y y position + * @param clickSlot the parent AuctionsBrowser + */ + public SortWidget(int x, int y, SlotClickHandler clickSlot) { + super(x, y, 36, 9, Text.literal("Sort Widget"), clickSlot, Option.HIGH); + } + + public enum Option implements OptionInfo { + HIGH("high.png"), + LOW("low.png"), + SOON("soon.png"), + RAND("rand.png"); + + private final Identifier texture; + private static final String prefix = "textures/gui/auctions_gui/sort_widget/"; + private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "hover.png"); + private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE,prefix + "back.png"); + + Option(String textureName) { + texture = new Identifier(SkyblockerMod.NAMESPACE, prefix + textureName); + } + public Identifier getOptionTexture() { + return texture; + } + + private static final Option[] values = values(); + public static Option get(int ordinal) {return values[MathHelper.clamp(ordinal, 0, values.length-1)];} + + @Override + public boolean isVertical() { + return false; + } + + @Override + public int getOffset() { + return 5 * ordinal(); + } + + @Override + public int[] getOptionSize() { + return new int[]{21, 9}; + } + + @Override + public Identifier getBackTexture() { + return BACK_TEXTURE; + } + + @Override + public Identifier getHoverTexture() { + return HOVER_TEXTURE; + } + } +} -- cgit From 5b258a6cd798678b2cb98be029443c5048496a86 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Fri, 22 Mar 2024 22:02:46 +0100 Subject: rebasing1 --- .../mixin/HandledScreenProviderMixin.java | 10 ++ .../skyblocker/mixin/accessor/SlotAccessor.java | 3 + .../skyblock/auction/AuctionBrowserScreen.java | 155 ++++++++++++++++++++- .../auction/AuctionHouseScreenHandler.java | 31 ++++- .../skyblock/auction/widgets/RarityWidget.java | 94 +++++++++++++ 5 files changed, 284 insertions(+), 9 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java index 975c9c51..cd2baa4b 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java @@ -2,6 +2,8 @@ package de.hysky.skyblocker.mixin; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.auction.AuctionBrowserScreen; +import de.hysky.skyblocker.skyblock.auction.AuctionHouseScreenHandler; import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreenHandler; import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreen; @@ -26,6 +28,8 @@ public interface HandledScreenProviderMixin { if (player == null) return; if (!Utils.isOnSkyblock()) return; T screenHandler = type.create(id, player.getInventory()); + if (!(screenHandler instanceof GenericContainerScreenHandler containerScreenHandler)) return; + if (PartyFinderScreen.possibleInventoryNames.contains(name.getString().toLowerCase())) { if (SkyblockerConfigManager.get().general.betterPartyFinder && screenHandler instanceof GenericContainerScreenHandler containerScreenHandler && PartyFinderScreen.possibleInventoryNames.contains(name.getString().toLowerCase())) { if (client.currentScreen != null) { String lowerCase = client.currentScreen.getTitle().getString().toLowerCase(); @@ -44,6 +48,12 @@ public interface HandledScreenProviderMixin { client.setScreen(new PartyFinderScreen(containerScreenHandler, player.getInventory(), name)); } + ci.cancel(); + } else if (name.getString().toLowerCase().contains("auctions browser")) { + System.out.println("another one"); + AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, false); + client.player.currentScreenHandler = auctionHouseScreenHandler; + client.setScreen(new AuctionBrowserScreen(auctionHouseScreenHandler, client.player.getInventory())); ci.cancel(); } else if (SkyblockerConfigManager.get().general.fancyCraftingTable && screenHandler instanceof GenericContainerScreenHandler containerScreenHandler && name.getString().toLowerCase().contains("craft item")) { SkyblockCraftingTableScreenHandler skyblockCraftingTableScreenHandler = new SkyblockCraftingTableScreenHandler(containerScreenHandler, player.getInventory()); diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java b/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java index 2a0a418f..b8c5618f 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java @@ -2,13 +2,16 @@ package de.hysky.skyblocker.mixin.accessor; import net.minecraft.screen.slot.Slot; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(Slot.class) public interface SlotAccessor { + @Mutable @Accessor("x") void setX(int x); + @Mutable @Accessor("y") void setY(int y); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 48b528ee..a06b9649 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -1,20 +1,169 @@ package de.hysky.skyblocker.skyblock.auction; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.skyblock.auction.widgets.AuctionTypeWidget; +import de.hysky.skyblocker.skyblock.auction.widgets.CategoryTabWidget; +import de.hysky.skyblocker.skyblock.auction.widgets.RarityWidget; +import de.hysky.skyblocker.skyblock.auction.widgets.SortWidget; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.client.gui.tooltip.Tooltip; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerListener; +import net.minecraft.screen.slot.SlotActionType; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.minecraft.util.math.MathHelper; -public class AuctionBrowserScreen extends HandledScreen { +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + +public class AuctionBrowserScreen extends HandledScreen implements ScreenHandlerListener { protected static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background.png"); - public AuctionBrowserScreen(AuctionHouseScreenHandler handler, PlayerInventory inventory, Text title) { - super(handler, inventory, title); + + // WIDGETS + private SortWidget sortWidget; + private AuctionTypeWidget auctionTypeWidget; + private RarityWidget rarityWidget; + private ButtonWidget resetFiltersButton; + private final List categoryTabWidgets = new ArrayList<>(6); + + public static int RESET_SLOT_ID = 45; + + + boolean isWaitingForServer = false; + + public AuctionBrowserScreen(AuctionHouseScreenHandler handler, PlayerInventory inventory) { + super(handler, inventory, Text.literal("Auctions Browser")); + this.backgroundHeight = 187; + this.playerInventoryTitleY = 92; + this.titleX = 999; + handler.addListener(this); + } + + @Override + protected void init() { + super.init(); + x = (this.width - 176) / 2; + y = (this.height - 187) / 2; + sortWidget = new SortWidget(x + 25, y + 81, this::clickSlot); + sortWidget.setSlotId(50); + addDrawableChild(sortWidget); + auctionTypeWidget = new AuctionTypeWidget(x + 134, y + 77, this::clickSlot); + auctionTypeWidget.setSlotId(52); + addDrawableChild(auctionTypeWidget); + rarityWidget = new RarityWidget(x + 73, y + 80, this::clickSlot); + rarityWidget.setSlotId(51); + addDrawableChild(rarityWidget); + resetFiltersButton = new ScaledTextButtonWidget(x + 10, y + 77, 12, 12, Text.literal("↻"), this::onResetPressed); + addDrawableChild(resetFiltersButton); + resetFiltersButton.setTooltip(Tooltip.of(Text.literal("Reset Filters"))); + resetFiltersButton.setTooltipDelay(500); + if (categoryTabWidgets.isEmpty()) + for (int i = 0; i < 6; i++) { + CategoryTabWidget categoryTabWidget = new CategoryTabWidget(new ItemStack(Items.SPONGE), this::clickSlot); + categoryTabWidgets.add(categoryTabWidget); + addSelectableChild(categoryTabWidget); // This method only makes it clickable, does not add it to the drawables list + // manually rendered in the render method to have it not render behind the durability bars + categoryTabWidget.setPosition(x - 30, y + 3 + i * 28); + } + else + for (int i = 0; i < categoryTabWidgets.size(); i++) { + CategoryTabWidget categoryTabWidget = categoryTabWidgets.get(i); + categoryTabWidget.setPosition(x - 30, y + 3 + i * 28); + + } + } + + protected void clickSlot(int slotID, int button) { + if (isWaitingForServer) return; + if (client == null) return; + assert this.client.interactionManager != null; + this.client.interactionManager.clickSlot(handler.syncId, slotID, button, SlotActionType.PICKUP, client.player); + } + + private void onResetPressed(ButtonWidget buttonWidget) { + buttonWidget.setFocused(false); // Annoying. + if (RESET_SLOT_ID == -1) return; + this.clickSlot(RESET_SLOT_ID, 0); } @Override protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { context.drawTexture(TEXTURE, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight); } + + @Override + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + super.render(context, mouseX, mouseY, delta); + this.drawMouseoverTooltip(context, mouseX, mouseY); + } + + private static int getOrdinal(List tooltip) { + int ordinal = 0; + for (int j = 0; j < tooltip.size()-3; j++) { + if (j+2 >= tooltip.size()) break; + if (tooltip.get(j+2).getString().contains("▶")) { + ordinal = j; + break; + } + } + return ordinal; + } + + @Override + public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack) { + if (client == null || stack.isEmpty()) return; + if (slotId == 50) { + sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + } else if (slotId == 52) { + auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + } else if (slotId == 51) { + List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); + int ordinal = getOrdinal(tooltip); + String split = tooltip.get(ordinal+2).getString().substring(2); + rarityWidget.setText(tooltip.subList(1, tooltip.size()-3), split); + } else if (slotId == 45) { + if (resetFiltersButton != null) resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); + } + } + + @Override + public void removed() { + super.removed(); + handler.removeListener(this); + } + + @Override + public void onPropertyUpdate(ScreenHandler handler, int property, int value) {} + + private static class ScaledTextButtonWidget extends ButtonWidget { + + protected ScaledTextButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress) { + super(x, y, width, height, message, onPress, Supplier::get); + } + + // Code taken mostly from YACL by isxander. Love you <3 + @Override + public void drawMessage(DrawContext graphics, TextRenderer textRenderer, int color) { + TextRenderer font = MinecraftClient.getInstance().textRenderer; + MatrixStack pose = graphics.getMatrices(); + float textScale = 2.f; + + pose.push(); + pose.translate(((this.getX() + this.width / 2f) - font.getWidth(getMessage()) * textScale / 2) + 1, (float)this.getY() + (this.height - font.fontHeight * textScale) / 2f - 1, 0); + pose.scale(textScale, textScale, 1); + graphics.drawText(font, getMessage(), 0, 0, color | MathHelper.ceil(this.alpha * 255.0F) << 24, true); + pose.pop(); + } + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java index 58adfc6c..7df3cef5 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java @@ -1,8 +1,10 @@ package de.hysky.skyblocker.skyblock.auction; import de.hysky.skyblocker.mixin.accessor.SlotAccessor; +import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.Inventory; +import net.minecraft.item.ItemStack; import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.slot.Slot; @@ -14,19 +16,21 @@ public class AuctionHouseScreenHandler extends GenericContainerScreenHandler { int yOffset = (rows - 4) * 18; // Shift player inventory by 2 pixels and also remove the yOffset for (int i = rows*9; i < slots.size(); i++) { - SlotAccessor slotAccessor = (SlotAccessor) slots.get(i); - slotAccessor.setY(2-yOffset); + Slot slot = slots.get(i); + SlotAccessor slotAccessor = (SlotAccessor) slot; + slotAccessor.setY(slot.y+2-yOffset); } if (isView) return; // disable ALL THE OTHER SLOTS MWAHAHAHA and also move the good ones around and stuff - for (int i = 9; i < (rows-1)*9; i++) { + for (int i = 0; i < rows*9; i++) { int lineI = i % 9; Slot slot = slots.get(i); - if (lineI > 1 && lineI < 8) { + if (i>9 && i<(rows-1)*9 && lineI > 1 && lineI < 8) { + int miniInventorySlot = lineI - 2 + (i/9 - 1)*6; SlotAccessor slotAccessor = (SlotAccessor) slot; - slotAccessor.setX(8+ lineI * 18); - slotAccessor.setY(18 + (i/9 -1) * 18); + slotAccessor.setX(8 + miniInventorySlot%8 * 18); + slotAccessor.setY(18 + miniInventorySlot/8 * 18); } else { slots.set(i, new Slot(slot.inventory, slot.getIndex(), slot.x, slot.y){ @Override @@ -37,4 +41,19 @@ public class AuctionHouseScreenHandler extends GenericContainerScreenHandler { } } } + + public static AuctionHouseScreenHandler of(GenericContainerScreenHandler original, boolean isView) { + return new AuctionHouseScreenHandler(original.getType(), + original.syncId, + MinecraftClient.getInstance().player.getInventory(), + original.getInventory(), + original.getRows(), + isView); + } + + @Override + public void setStackInSlot(int slot, int revision, ItemStack stack) { + super.setStackInSlot(slot, revision, stack); + onContentChanged(slots.get(slot).inventory); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java new file mode 100644 index 00000000..1affdc0c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java @@ -0,0 +1,94 @@ +package de.hysky.skyblocker.skyblock.auction.widgets; + +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; +import net.minecraft.client.gui.widget.ClickableWidget; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +import java.util.List; + +public class RarityWidget extends ClickableWidget { + + private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/rarity_widget/hover.png"); + private static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/rarity_widget/background.png"); + private final SlotClickHandler onClick; + private int slotId = -1; + + public RarityWidget(int x, int y, SlotClickHandler onClick) { + super(x, y, 48, 11, Text.literal("rarity selector thing, hi mom")); + this.onClick = onClick; + } + + @Override + protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.translate(getX(), getY(), 0); + //context.drawText(parent.getTextRender(), String.valueOf(slotId), 0, -9, Colors.RED, true); + boolean onLeftArrow = isOnLeftArrow(mouseX); + boolean onRightArrow = isOnRightArrow(mouseX); + context.drawTexture(TEXTURE, 0, 0, 0, 0, 48, 11, 48, 11); + if (onLeftArrow) context.drawTexture(HOVER_TEXTURE, 0, 0, 0, 0, 6, 11, 6, 11); + if (onRightArrow) context.drawTexture(HOVER_TEXTURE, 42, 0, 0, 0, 6, 11, 6, 11); + + // Text + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + int textWidth = textRenderer.getWidth(current); + int color = 0xFFEAEAEA; + if (textWidth > 34) { + matrices.push(); + //matrices.translate(-7-getX(), -5.5f-getY(), 0); + matrices.translate(7, 5.5f, 0); + matrices.scale(34.f/textWidth, 34.f/textWidth, 1.f); + context.drawText(textRenderer, current, 0, -textRenderer.fontHeight/2, color, false); + matrices.pop(); + } else { + context.drawText(textRenderer, current, 7, 2, color, false); + } + + matrices.pop(); + if (!onLeftArrow && !onRightArrow && isHovered()) context.drawTooltip(textRenderer, tooltip, mouseX, mouseY); + + } + + private boolean isOnRightArrow(int mouseX) { + return isHovered() && mouseX - getX() > 40; + } + + private boolean isOnLeftArrow(int mouseX) { + return isHovered() && mouseX - getX() < 7; + } + + @Override + protected void appendClickableNarrations(NarrationMessageBuilder builder) { + + } + + public void setSlotId(int slotId) { + this.slotId = slotId; + } + + private List tooltip = List.of(); + private String current = "?"; + + public void setText(List tooltip, String current) { + this.tooltip = tooltip; + this.current = current; + } + + @Override + public void onClick(double mouseX, double mouseY) { + if (slotId == -1) return; + if (isOnLeftArrow((int) mouseX)) { + onClick.click(slotId, 1); + } else if (isOnRightArrow((int) mouseX)) { + onClick.click(slotId, 0); + } + } +} -- cgit From 8e487a87c51da89072c70f9c46e0b0e5d423d45f Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sat, 23 Mar 2024 21:19:33 +0100 Subject: it works ain't that GREAT --- .../skyblocker/mixin/ClientPlayerEntityMixin.java | 7 + .../mixin/HandledScreenProviderMixin.java | 23 ++- .../mixin/accessor/HandledScreenAccessor.java | 6 + .../skyblock/auction/AuctionBrowserScreen.java | 212 +++++++++++++++++---- .../auction/AuctionHouseScreenHandler.java | 4 +- .../skyblock/auction/AuctionViewScreen.java | 201 +++++++++++++++++++ .../skyblocker/skyblock/auction/EditBidPopup.java | 99 ++++++++++ .../utils/render/gui/AbstractCustomHypixelGUI.java | 56 ++++++ .../utils/render/gui/BarebonesPopupScreen.java | 56 ++++++ 9 files changed, 616 insertions(+), 48 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java create mode 100644 src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractCustomHypixelGUI.java create mode 100644 src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java index ceda9ed4..049443f7 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java @@ -2,6 +2,8 @@ package de.hysky.skyblocker.mixin; import com.mojang.authlib.GameProfile; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.auction.AuctionViewScreen; +import de.hysky.skyblocker.skyblock.auction.EditBidPopup; import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; import de.hysky.skyblocker.skyblock.item.HotbarSlotLock; import de.hysky.skyblocker.skyblock.item.ItemProtection; @@ -58,6 +60,11 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity return; } + if (client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { + this.client.setScreen(new EditBidPopup(auctionViewScreen, sign, front, auctionViewScreen.minBid)); + callbackInfo.cancel(); + } + // Search Overlay if (client.currentScreen != null) { if (SkyblockerConfigManager.get().general.searchOverlay.enableAuctionHouse && client.currentScreen.getTitle().getString().toLowerCase().contains("auction")) { diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java index cd2baa4b..10d65669 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java @@ -2,8 +2,10 @@ package de.hysky.skyblocker.mixin; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.mixin.accessor.HandledScreenAccessor; import de.hysky.skyblocker.skyblock.auction.AuctionBrowserScreen; import de.hysky.skyblocker.skyblock.auction.AuctionHouseScreenHandler; +import de.hysky.skyblocker.skyblock.auction.AuctionViewScreen; import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreenHandler; import de.hysky.skyblocker.skyblock.item.SkyblockCraftingTableScreen; @@ -29,7 +31,8 @@ public interface HandledScreenProviderMixin { if (!Utils.isOnSkyblock()) return; T screenHandler = type.create(id, player.getInventory()); if (!(screenHandler instanceof GenericContainerScreenHandler containerScreenHandler)) return; - if (PartyFinderScreen.possibleInventoryNames.contains(name.getString().toLowerCase())) { + String nameLowercase = name.getString().toLowerCase(); + if (PartyFinderScreen.possibleInventoryNames.contains(nameLowercase)) { if (SkyblockerConfigManager.get().general.betterPartyFinder && screenHandler instanceof GenericContainerScreenHandler containerScreenHandler && PartyFinderScreen.possibleInventoryNames.contains(name.getString().toLowerCase())) { if (client.currentScreen != null) { String lowerCase = client.currentScreen.getTitle().getString().toLowerCase(); @@ -49,11 +52,23 @@ public interface HandledScreenProviderMixin { } ci.cancel(); - } else if (name.getString().toLowerCase().contains("auctions browser")) { - System.out.println("another one"); + } else if (nameLowercase.contains("auctions browser") || nameLowercase.contains("auctions: ")) { AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, false); client.player.currentScreenHandler = auctionHouseScreenHandler; - client.setScreen(new AuctionBrowserScreen(auctionHouseScreenHandler, client.player.getInventory())); + if (client.currentScreen instanceof AuctionBrowserScreen auctionBrowserScreen) { + auctionBrowserScreen.changeHandler(auctionHouseScreenHandler); + } else client.setScreen(new AuctionBrowserScreen(auctionHouseScreenHandler, client.player.getInventory())); + ci.cancel(); + } else if (nameLowercase.contains("auction view")) { + AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, true); + client.player.currentScreenHandler = auctionHouseScreenHandler; + if (client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { + auctionViewScreen.changeHandler(auctionHouseScreenHandler); + } else client.setScreen(new AuctionViewScreen(auctionHouseScreenHandler, client.player.getInventory(), name)); + ci.cancel(); + } else if ((nameLowercase.contains("confirm purchase") || nameLowercase.contains("confirm bid")) && client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { + client.setScreen(auctionViewScreen.getConfirmPurchasePopup(name)); + client.player.currentScreenHandler = containerScreenHandler; ci.cancel(); } else if (SkyblockerConfigManager.get().general.fancyCraftingTable && screenHandler instanceof GenericContainerScreenHandler containerScreenHandler && name.getString().toLowerCase().contains("craft item")) { SkyblockCraftingTableScreenHandler skyblockCraftingTableScreenHandler = new SkyblockCraftingTableScreenHandler(containerScreenHandler, player.getInventory()); diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/HandledScreenAccessor.java b/src/main/java/de/hysky/skyblocker/mixin/accessor/HandledScreenAccessor.java index d82422cb..5b84072d 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/HandledScreenAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixin/accessor/HandledScreenAccessor.java @@ -1,7 +1,9 @@ package de.hysky.skyblocker.mixin.accessor; import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.screen.ScreenHandler; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(HandledScreen.class) @@ -17,4 +19,8 @@ public interface HandledScreenAccessor { @Accessor int getBackgroundHeight(); + + @Mutable + @Accessor("handler") + void setHandler(ScreenHandler handler); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index a06b9649..11a41d0c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -5,21 +5,23 @@ import de.hysky.skyblocker.skyblock.auction.widgets.AuctionTypeWidget; import de.hysky.skyblocker.skyblock.auction.widgets.CategoryTabWidget; import de.hysky.skyblocker.skyblock.auction.widgets.RarityWidget; import de.hysky.skyblocker.skyblock.auction.widgets.SortWidget; +import de.hysky.skyblocker.utils.render.gui.AbstractCustomHypixelGUI; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.screen.ScreenHandler; -import net.minecraft.screen.ScreenHandlerListener; +import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; +import net.minecraft.text.Style; import net.minecraft.text.Text; +import net.minecraft.util.Colors; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -27,8 +29,27 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; -public class AuctionBrowserScreen extends HandledScreen implements ScreenHandlerListener { +public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { protected static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background.png"); + private static final Identifier SCROLLER_TEXTURE = new Identifier("container/creative_inventory/scroller"); + + private static final Identifier up_arrow_tex = new Identifier(SkyblockerMod.NAMESPACE, "up_arrow_even"); // Put them in their own fields to avoid object allocation on each frame + private static final Identifier down_arrow_tex = new Identifier(SkyblockerMod.NAMESPACE, "down_arrow_even"); + public static final Supplier UP_ARROW = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(up_arrow_tex); + public static final Supplier DOWN_ARROW = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(down_arrow_tex); + + + // SLOTS + public static final int RESET_BUTTON_SLOT = 47; + public static final int SEARCH_BUTTON_SLOT = 48; + public static final int BACK_BUTTON_SLOT = 49; + public static final int SORT_BUTTON_SLOT = 50; + public static final int RARITY_BUTTON_SLOT = 51; + public static final int AUCTION_TYPE_BUTTON_SLOT = 52; + + public static final int PREV_PAGE_BUTTON = 46; + public static final int NEXT_PAGE_BUTTON = 53; + // WIDGETS private SortWidget sortWidget; @@ -36,18 +57,13 @@ public class AuctionBrowserScreen extends HandledScreen categoryTabWidgets = new ArrayList<>(6); - - public static int RESET_SLOT_ID = 45; - - - boolean isWaitingForServer = false; + private String search; public AuctionBrowserScreen(AuctionHouseScreenHandler handler, PlayerInventory inventory) { super(handler, inventory, Text.literal("Auctions Browser")); this.backgroundHeight = 187; this.playerInventoryTitleY = 92; this.titleX = 999; - handler.addListener(this); } @Override @@ -56,13 +72,13 @@ public class AuctionBrowserScreen extends HandledScreen tooltip) { - int ordinal = 0; - for (int j = 0; j < tooltip.size()-3; j++) { - if (j+2 >= tooltip.size()) break; - if (tooltip.get(j+2).getString().contains("▶")) { - ordinal = j; - break; - } + @Override + protected void onMouseClick(Slot slot, int slotId, int button, SlotActionType actionType) { + if (slotId >= handler.getRows()*9) return; + super.onMouseClick(slot, slotId, button, actionType); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (isWaitingForServer) return super.mouseClicked(mouseX, mouseY, button); + if (onScrollbarTop((int)mouseX, (int) mouseY) && prevPageVisible) { + clickSlot(PREV_PAGE_BUTTON); + return true; } - return ordinal; + if (onScrollbarBottom((int)mouseX, (int) mouseY) && nextPageVisible) { + clickSlot(NEXT_PAGE_BUTTON); + return true; + } + + if (onSearchField((int)mouseX, (int) mouseY)) { + clickSlot(SEARCH_BUTTON_SLOT); + return true; + } + return super.mouseClicked(mouseX, mouseY, button); + } + + private boolean onScrollbarTop(int mouseX, int mouseY) { + int localX = mouseX - x; + int localY = mouseY - y; + return localX > 154 && localX < 169 && localY > 6 && localY < 44; + } + + private boolean onScrollbarBottom(int mouseX, int mouseY) { + int localX = mouseX - x; + int localY = mouseY - y; + return localX > 154 && localX < 169 && localY > 43 && localY < 80; + } + private boolean onSearchField(int mouseX, int mouseY) { + int localX = mouseX - x; + int localY = mouseY - y; + return localX > 6 && localX < 97 && localY > 3 && localY < 16; } @Override - public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack) { + public void onSlotChange(AuctionHouseScreenHandler handler, int slotId, ItemStack stack) { if (client == null || stack.isEmpty()) return; - if (slotId == 50) { + isWaitingForServer = false; + if (slotId == PREV_PAGE_BUTTON) prevPageVisible = false; + if (slotId == NEXT_PAGE_BUTTON) nextPageVisible = false; + if (slotId == SORT_BUTTON_SLOT) { sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); - } else if (slotId == 52) { + } else if (slotId == AUCTION_TYPE_BUTTON_SLOT) { auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); - } else if (slotId == 51) { + } else if (slotId == RARITY_BUTTON_SLOT) { List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); int ordinal = getOrdinal(tooltip); String split = tooltip.get(ordinal+2).getString().substring(2); rarityWidget.setText(tooltip.subList(1, tooltip.size()-3), split); - } else if (slotId == 45) { + } else if (slotId == RESET_BUTTON_SLOT) { if (resetFiltersButton != null) resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); + } else if (slotId < this.handler.getRows()*9 && slotId%9 == 0) { + CategoryTabWidget categoryTabWidget = categoryTabWidgets.get(slotId / 9); + categoryTabWidget.setSlotId(slotId); + categoryTabWidget.setIcon(handler.getSlot(slotId).getStack()); + List tooltip = handler.getSlot(slotId).getStack().getTooltip(client.player, TooltipContext.BASIC); + for (int j = tooltip.size() - 1; j >= 0; j--) { + String lowerCase = tooltip.get(j).getString().toLowerCase(); + if (lowerCase.contains("currently")) { + categoryTabWidget.setToggled(true); + break; + } else if (lowerCase.contains("click")) { + categoryTabWidget.setToggled(false); + break; + } else categoryTabWidget.setToggled(false); + } + } else if (slotId == PREV_PAGE_BUTTON && stack.isOf(Items.ARROW)) { + prevPageVisible = true; + parsePage(stack); + } else if (slotId == NEXT_PAGE_BUTTON && stack.isOf(Items.ARROW)) { + nextPageVisible = true; + parsePage(stack); + } else if (slotId == SEARCH_BUTTON_SLOT) { + List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); + for (Text text : tooltip) { + String string = text.getString(); + if (string.contains("Filtered:")) { + String[] split = string.split(":"); + if (split.length < 2) { + search = ""; + } else search = split[1].trim(); + break; + } + } } } - @Override - public void removed() { - super.removed(); - handler.removeListener(this); + private static int getOrdinal(List tooltip) { + int ordinal = 0; + for (int j = 0; j < tooltip.size()-3; j++) { + if (j+2 >= tooltip.size()) break; + if (tooltip.get(j+2).getString().contains("▶")) { + ordinal = j; + break; + } + } + return ordinal; + } + + int currentPage = 0; + int totalPages = 1; + private boolean prevPageVisible = false; + private boolean nextPageVisible = false; + private void parsePage(ItemStack stack) { + List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); + String str = tooltip.get(1).getString().trim(); + str = str.substring(1, str.length() - 1); // remove parentheses + String[] parts = str.split("/"); // split the string + try { + currentPage = Integer.parseInt(parts[0].replace(",", "")); // parse current page + totalPages = Integer.parseInt(parts[1].replace(",", "")); // parse total + } catch (NumberFormatException ignored) {} } @Override - public void onPropertyUpdate(ScreenHandler handler, int property, int value) {} + protected boolean isClickOutsideBounds(double mouseX, double mouseY, int left, int top, int button) { + return mouseX < (double)left - 32 || mouseY < (double)top || mouseX >= (double)(left + this.backgroundWidth) || mouseY >= (double)(top + this.backgroundHeight); + } private static class ScaledTextButtonWidget extends ButtonWidget { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java index 7df3cef5..fbc9fb17 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java @@ -20,13 +20,11 @@ public class AuctionHouseScreenHandler extends GenericContainerScreenHandler { SlotAccessor slotAccessor = (SlotAccessor) slot; slotAccessor.setY(slot.y+2-yOffset); } - - if (isView) return; // disable ALL THE OTHER SLOTS MWAHAHAHA and also move the good ones around and stuff for (int i = 0; i < rows*9; i++) { int lineI = i % 9; Slot slot = slots.get(i); - if (i>9 && i<(rows-1)*9 && lineI > 1 && lineI < 8) { + if (!isView && i>9 && i<(rows-1)*9 && lineI > 1 && lineI < 8) { int miniInventorySlot = lineI - 2 + (i/9 - 1)*6; SlotAccessor slotAccessor = (SlotAccessor) slot; slotAccessor.setX(8 + miniInventorySlot%8 * 18); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java new file mode 100644 index 00000000..d482ccd8 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java @@ -0,0 +1,201 @@ +package de.hysky.skyblocker.skyblock.auction; + +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.utils.render.gui.AbstractCustomHypixelGUI; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.PopupScreen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.DirectionalLayoutWidget; +import net.minecraft.client.gui.widget.SimplePositioningWidget; +import net.minecraft.client.gui.widget.TextWidget; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.screen.slot.SlotActionType; +import net.minecraft.text.MutableText; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import net.minecraft.util.Colors; +import net.minecraft.util.Formatting; +import net.minecraft.util.Identifier; + +import java.util.List; + +public class AuctionViewScreen extends AbstractCustomHypixelGUI { + protected static final Identifier BACKGROUND_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE,"textures/gui/auctions_gui/browser/background_view.png"); + + DirectionalLayoutWidget verticalLayout = DirectionalLayoutWidget.vertical(); + + public final boolean isBinAuction; + private TextWidget priceWidget; + private final Text clickToEditBidText = Text.literal("Click to edit Bid!").setStyle(Style.EMPTY.withUnderline(true)); + + private TextWidget cantAffordText; + public String minBid = ""; + + private BuyState buyState = BuyState.CANT_AFFORD; + private MutableText priceText = Text.literal("?"); + + public AuctionViewScreen(AuctionHouseScreenHandler handler, PlayerInventory inventory, Text title) { + super(handler, inventory, title); + backgroundHeight = 187; + isBinAuction = this.getTitle().getString().toLowerCase().contains("bin"); + playerInventoryTitleY = 93; + } + + @Override + protected void init() { + super.init(); + verticalLayout.spacing(2).getMainPositioner().alignHorizontalCenter(); + verticalLayout.add(new TextWidget(Text.literal(isBinAuction ? "Price:" : "New Bid:"), textRenderer).alignCenter()); + + priceWidget = new TextWidget(Text.literal("?"), textRenderer).alignCenter(); + priceWidget.setWidth(textRenderer.getWidth(clickToEditBidText)); + priceWidget.active = true; + verticalLayout.add(priceWidget); + + cantAffordText = new TextWidget(Text.literal("Can't Afford"), textRenderer).alignCenter(); + verticalLayout.add(cantAffordText); + + verticalLayout.add(ButtonWidget.builder(Text.literal(isBinAuction?"Buy!":"Bid!"), button -> { + if (buySlotID == -1) return; + clickSlot(buySlotID); + }).size(50, 12).build()); + verticalLayout.forEachChild(this::addDrawableChild); + updateLayout(); + + + } + + private void changeState(BuyState newState) { + if (newState == buyState) return; + buyState = newState; + switch (buyState) { + case CANT_AFFORD -> cantAffordText.setMessage(Text.literal("Can't Afford!").withColor(Colors.RED)); + case TOP_BID -> cantAffordText.setMessage(Text.literal("Already top bid!").withColor(Colors.LIGHT_YELLOW)); + case AFFORD -> cantAffordText.setMessage(Text.empty()); + } + cantAffordText.setWidth(textRenderer.getWidth(cantAffordText.getMessage())); + updateLayout(); + } + + private void updateLayout() { + verticalLayout.refreshPositions(); + SimplePositioningWidget.setPos(verticalLayout, x, y+36, backgroundWidth, 60); + } + + @Override + protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { + context.drawTexture(BACKGROUND_TEXTURE, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight); + } + + @Override + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + super.render(context, mouseX, mouseY, delta); + + MatrixStack matrices = context.getMatrices(); + + matrices.push(); + matrices.translate(x+77, y+14, 0); + matrices.scale(1.375f, 1.375f, 1.375f); + //matrices.translate(0, 0, 100f); + ItemStack stack = handler.getSlot(13).getStack(); + context.drawItem(stack, 0, 0); + context.drawItemInSlot(textRenderer, stack, 0, 0); + matrices.pop(); + + if (!isBinAuction) { + if (priceWidget.isMouseOver(mouseX, mouseY) && buyState != BuyState.CANT_AFFORD) { + priceWidget.setMessage(clickToEditBidText); + } else { + priceWidget.setMessage(priceText); + } + } + + drawMouseoverTooltip(context, mouseX, mouseY); + } + + @Override + protected void drawMouseoverTooltip(DrawContext context, int x, int y) { + super.drawMouseoverTooltip(context, x, y); + if (x>this.x+75 && xthis.y+13 && y tooltip) { + if (priceParsed) return; + String minBid = null; + String priceString = "???"; + for (Text text : tooltip) { + String string = text.getString(); + String thingToLookFor = (isBinAuction) ? "price:" : "new bid:"; + if (string.toLowerCase().contains(thingToLookFor)) { + String[] split = string.split(":"); + if (split.length < 2) continue; + priceString = split[1].trim(); + break; + } else if (string.toLowerCase().contains("minimum bid:") && !isBinAuction) { + String[] split = string.split(":"); + if (split.length < 2) continue; + minBid = split[1].replace("coins", "").replace(",", "").trim(); + } + } + if (minBid != null) this.minBid = minBid; + else this.minBid = priceString; + priceText = Text.literal(priceString).setStyle(Style.EMPTY.withFormatting(Formatting.BOLD).withColor(Formatting.GOLD)); + priceWidget.setMessage(priceText); + int width = textRenderer.getWidth(priceText); + if (width > priceWidget.getWidth()) priceWidget.setWidth(width); + priceParsed = true; + updateLayout(); + } + + public PopupScreen getConfirmPurchasePopup(Text title) { + // This really shouldn't be possible to be null in its ACTUAL use case. + //noinspection DataFlowIssue + return new PopupScreen.Builder(this, title) + .button(Text.literal("Confirm"), popupScreen -> this.client.interactionManager.clickSlot(this.client.player.currentScreenHandler.syncId, 11, 0, SlotActionType.PICKUP, client.player)) + .button(Text.literal("Cancel"), popupScreen -> this.client.interactionManager.clickSlot(this.client.player.currentScreenHandler.syncId, 15, 0, SlotActionType.PICKUP, client.player)) + .message(Text.literal(isBinAuction ? "Price: " : "New Bid: ").append(priceText)).build(); + } + + private enum BuyState { + CANT_AFFORD, + AFFORD, + TOP_BID + } +} diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java new file mode 100644 index 00000000..ccdb7353 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java @@ -0,0 +1,99 @@ +package de.hysky.skyblocker.skyblock.auction; + +import de.hysky.skyblocker.utils.render.gui.BarebonesPopupScreen; +import net.minecraft.block.entity.SignBlockEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.*; +import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import org.jetbrains.annotations.NotNull; + +public class EditBidPopup extends BarebonesPopupScreen { + private DirectionalLayoutWidget layout = DirectionalLayoutWidget.vertical(); + private final String minimumBid; + private final SignBlockEntity signBlockEntity; + + private final boolean signFront; + + private TextFieldWidget textFieldWidget; + + private boolean packetSent = false; + + public EditBidPopup(AuctionViewScreen auctionViewScreen, @NotNull SignBlockEntity signBlockEntity, boolean signFront, String minimumBid) { + super(Text.literal("Edit Bid"), auctionViewScreen); + this.minimumBid = minimumBid; + this.signBlockEntity = signBlockEntity; + this.signFront = signFront; + } + + @Override + protected void init() { + super.init(); + layout = DirectionalLayoutWidget.vertical(); + layout.spacing(8).getMainPositioner().alignHorizontalCenter(); + textFieldWidget = new TextFieldWidget(textRenderer, 120, 15, Text.empty()); + textFieldWidget.setTextPredicate(this::isStringGood); + layout.add(new TextWidget(Text.literal("- Set Bid -").fillStyle(Style.EMPTY.withBold(true)), textRenderer)); + layout.add(textFieldWidget); + layout.add(new TextWidget(Text.literal("Minimum Bid: " + minimumBid), textRenderer)); + DirectionalLayoutWidget horizontal = DirectionalLayoutWidget.horizontal(); + ButtonWidget buttonWidget = ButtonWidget.builder(Text.literal("Set Minimum Bid"), this::buttonMinimumBid).width(80).build(); + buttonWidget.active = isStringGood(minimumBid); + horizontal.add(buttonWidget); + horizontal.add(ButtonWidget.builder(Text.literal("Done"), this::done).width(80).build()); + layout.add(horizontal); + layout.forEachChild(this::addDrawableChild); + this.layout.refreshPositions(); + SimplePositioningWidget.setPos(layout, this.getNavigationFocus()); + setInitialFocus(textFieldWidget); + } + + @Override + public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) { + super.renderBackground(context, mouseX, mouseY, delta); + drawPopupBackground(context, layout.getX(), layout.getY(), layout.getWidth(), layout.getHeight()); + } + + private boolean isStringGood(String s) { + assert this.client != null; + return this.client.textRenderer.getWidth(minimumBid) <= this.signBlockEntity.getMaxTextWidth(); + } + + private void buttonMinimumBid(ButtonWidget widget) { + if (!isStringGood(minimumBid)) return; + sendPacket(minimumBid); + this.close(); + } + + private void done(ButtonWidget widget) { + if(!isStringGood(textFieldWidget.getText().trim())) return; + sendPacket(textFieldWidget.getText().trim()); + this.close(); + } + + private void sendPacket(String string) { + assert MinecraftClient.getInstance().player != null; + MinecraftClient.getInstance().player.networkHandler.sendPacket(new UpdateSignC2SPacket(signBlockEntity.getPos(), signFront, + string, + "", + "", + "" + )); + packetSent = true; + } + + @Override + public void close() { + if (!packetSent) sendPacket(""); + this.client.setScreen(null); + } + + @Override + public void removed() { + if (!packetSent) sendPacket(""); + super.removed(); + } +} diff --git a/src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractCustomHypixelGUI.java b/src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractCustomHypixelGUI.java new file mode 100644 index 00000000..4f648b8c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractCustomHypixelGUI.java @@ -0,0 +1,56 @@ +package de.hysky.skyblocker.utils.render.gui; + +import de.hysky.skyblocker.mixin.accessor.HandledScreenAccessor; +import de.hysky.skyblocker.skyblock.auction.AuctionHouseScreenHandler; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.screen.ScreenHandlerListener; +import net.minecraft.screen.slot.SlotActionType; +import net.minecraft.text.Text; + +public abstract class AbstractCustomHypixelGUI extends HandledScreen implements ScreenHandlerListener { + + public boolean isWaitingForServer = true; + public AbstractCustomHypixelGUI(T handler, PlayerInventory inventory, Text title) { + super(handler, inventory, title); + handler.addListener(this); + } + + protected void clickSlot(int slotID, int button) { + if (isWaitingForServer) return; + if (client == null) return; + assert this.client.interactionManager != null; + this.client.interactionManager.clickSlot(handler.syncId, slotID, button, SlotActionType.PICKUP, client.player); + handler.getCursorStack().setCount(0); + isWaitingForServer = true; + } + + protected void clickSlot(int slotID) { + clickSlot(slotID, 0); + } + + public void changeHandler(AuctionHouseScreenHandler newHandler) { + handler.removeListener(this); + ((HandledScreenAccessor) this).setHandler(newHandler); + handler.addListener(this); + } + + @Override + public void removed() { + super.removed(); + handler.removeListener(this); + } + + @Override + public final void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack) { + onSlotChange(this.handler, slotId, stack); + isWaitingForServer = false; + } + + protected abstract void onSlotChange(T handler, int slotID, ItemStack stack); + + @Override + public void onPropertyUpdate(ScreenHandler handler, int property, int value) {} +} diff --git a/src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java b/src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java new file mode 100644 index 00000000..56b07966 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java @@ -0,0 +1,56 @@ +package de.hysky.skyblocker.utils.render.gui; + +import com.mojang.blaze3d.platform.GlConst; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +/** + * A more bare-bones version of Vanilla's Popup Screen. Meant to be extended. + */ +public class BarebonesPopupScreen extends Screen { + private static final Identifier BACKGROUND_TEXTURE = new Identifier("popup/background"); + private final Screen backgroundScreen; + + protected BarebonesPopupScreen(Text title, Screen backgroundScreen) { + super(title); + this.backgroundScreen = backgroundScreen; + } + + @Override + public void close() { + assert this.client != null; + this.client.setScreen(this.backgroundScreen); + } + + @Override + public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) { + this.backgroundScreen.render(context, -1, -1, delta); + context.draw(); + RenderSystem.clear(GlConst.GL_DEPTH_BUFFER_BIT, MinecraftClient.IS_SYSTEM_MAC); + this.renderInGameBackground(context); + } + + /** + * These are the inner positions and size of the popup, not outer + */ + public static void drawPopupBackground(DrawContext context, int x, int y, int width, int height) { + context.drawGuiTexture(BACKGROUND_TEXTURE, x - 18, y - 18, width + 36, height + 36); + } + + @Override + protected void init() { + super.init(); + this.backgroundScreen.resize(this.client, width, height); + + } + + @Override + public void onDisplayed() { + super.onDisplayed(); + this.backgroundScreen.blur(); + } +} \ No newline at end of file -- cgit From 1afbd1cc0c86b2c7905b5220d1f6e48937bbd98e Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sat, 23 Mar 2024 21:41:14 +0100 Subject: REFORMAT WHOLE FILE REFORMAT WHOLE FILE --- .../mixin/HandledScreenProviderMixin.java | 1 - .../skyblock/auction/AuctionBrowserScreen.java | 11 ++++++++--- .../skyblock/auction/AuctionHouseScreenHandler.java | 19 ++++++++++--------- .../skyblock/auction/AuctionViewScreen.java | 13 ++++++++----- .../skyblocker/skyblock/auction/EditBidPopup.java | 4 ++-- .../skyblock/auction/widgets/AuctionTypeWidget.java | 14 +++++++++----- .../skyblock/auction/widgets/CategoryTabWidget.java | 4 ++-- .../skyblock/auction/widgets/RarityWidget.java | 4 ++-- .../skyblock/auction/widgets/SliderWidget.java | 21 +++++++++++---------- .../skyblock/auction/widgets/SortWidget.java | 14 +++++++++----- 10 files changed, 61 insertions(+), 44 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java index 10d65669..75d604a6 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java @@ -2,7 +2,6 @@ package de.hysky.skyblocker.mixin; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.mixin.accessor.HandledScreenAccessor; import de.hysky.skyblocker.skyblock.auction.AuctionBrowserScreen; import de.hysky.skyblocker.skyblock.auction.AuctionHouseScreenHandler; import de.hysky.skyblocker.skyblock.auction.AuctionViewScreen; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 11a41d0c..31c84d9e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -57,7 +57,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI categoryTabWidgets = new ArrayList<>(6); - private String search; + private String search = ""; public AuctionBrowserScreen(AuctionHouseScreenHandler handler, PlayerInventory inventory) { super(handler, inventory, Text.literal("Auctions Browser")); @@ -69,8 +69,6 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI this.clickSlot(BACK_BUTTON_SLOT)) + .position(x + backgroundWidth - 16, y+4) + .size(12, 12) + .build()); + if (categoryTabWidgets.isEmpty()) for (int i = 0; i < 6; i++) { CategoryTabWidget categoryTabWidget = new CategoryTabWidget(new ItemStack(Items.SPONGE), this::clickSlot); @@ -261,6 +265,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); String str = tooltip.get(1).getString().trim(); str = str.substring(1, str.length() - 1); // remove parentheses diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java index fbc9fb17..28898cdc 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionHouseScreenHandler.java @@ -15,22 +15,22 @@ public class AuctionHouseScreenHandler extends GenericContainerScreenHandler { int yOffset = (rows - 4) * 18; // Shift player inventory by 2 pixels and also remove the yOffset - for (int i = rows*9; i < slots.size(); i++) { + for (int i = rows * 9; i < slots.size(); i++) { Slot slot = slots.get(i); SlotAccessor slotAccessor = (SlotAccessor) slot; - slotAccessor.setY(slot.y+2-yOffset); + slotAccessor.setY(slot.y + 2 - yOffset); } // disable ALL THE OTHER SLOTS MWAHAHAHA and also move the good ones around and stuff - for (int i = 0; i < rows*9; i++) { + for (int i = 0; i < rows * 9; i++) { int lineI = i % 9; Slot slot = slots.get(i); - if (!isView && i>9 && i<(rows-1)*9 && lineI > 1 && lineI < 8) { - int miniInventorySlot = lineI - 2 + (i/9 - 1)*6; + if (!isView && i > 9 && i < (rows - 1) * 9 && lineI > 1 && lineI < 8) { + int miniInventorySlot = lineI - 2 + (i / 9 - 1) * 6; SlotAccessor slotAccessor = (SlotAccessor) slot; - slotAccessor.setX(8 + miniInventorySlot%8 * 18); - slotAccessor.setY(18 + miniInventorySlot/8 * 18); + slotAccessor.setX(8 + miniInventorySlot % 8 * 18); + slotAccessor.setY(18 + miniInventorySlot / 8 * 18); } else { - slots.set(i, new Slot(slot.inventory, slot.getIndex(), slot.x, slot.y){ + slots.set(i, new Slot(slot.inventory, slot.getIndex(), slot.x, slot.y) { @Override public boolean isEnabled() { return false; @@ -39,8 +39,9 @@ public class AuctionHouseScreenHandler extends GenericContainerScreenHandler { } } } - + public static AuctionHouseScreenHandler of(GenericContainerScreenHandler original, boolean isView) { + assert MinecraftClient.getInstance().player != null; return new AuctionHouseScreenHandler(original.getType(), original.syncId, MinecraftClient.getInstance().player.getInventory(), diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java index d482ccd8..84d77933 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java @@ -24,7 +24,7 @@ import net.minecraft.util.Identifier; import java.util.List; public class AuctionViewScreen extends AbstractCustomHypixelGUI { - protected static final Identifier BACKGROUND_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE,"textures/gui/auctions_gui/browser/background_view.png"); + protected static final Identifier BACKGROUND_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background_view.png"); DirectionalLayoutWidget verticalLayout = DirectionalLayoutWidget.vertical(); @@ -59,7 +59,7 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI { + verticalLayout.add(ButtonWidget.builder(Text.literal(isBinAuction ? "Buy!" : "Bid!"), button -> { if (buySlotID == -1) return; clickSlot(buySlotID); }).size(50, 12).build()); @@ -83,7 +83,7 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUIthis.x+75 && xthis.y+13 && y this.x + 75 && x < this.x + 75 + 26 && y > this.y + 13 && y < this.y + 13 + 26) { context.drawTooltip(this.textRenderer, this.getTooltipFromItem(handler.getSlot(13).getStack()), x, y); } } @@ -156,6 +158,7 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI tooltip) { if (priceParsed) return; String minBid = null; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java index ccdb7353..1b046d66 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java @@ -4,7 +4,6 @@ import de.hysky.skyblocker.utils.render.gui.BarebonesPopupScreen; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.*; import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; import net.minecraft.text.Style; @@ -69,7 +68,7 @@ public class EditBidPopup extends BarebonesPopupScreen { } private void done(ButtonWidget widget) { - if(!isStringGood(textFieldWidget.getText().trim())) return; + if (!isStringGood(textFieldWidget.getText().trim())) return; sendPacket(textFieldWidget.getText().trim()); this.close(); } @@ -88,6 +87,7 @@ public class EditBidPopup extends BarebonesPopupScreen { @Override public void close() { if (!packetSent) sendPacket(""); + assert this.client != null; this.client.setScreen(null); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java index 64410d72..0caa233a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/AuctionTypeWidget.java @@ -9,9 +9,9 @@ import net.minecraft.util.math.MathHelper; public class AuctionTypeWidget extends SliderWidget { /** - * @param x x position - * @param y y position - * @param slotClick IDK figure it out + * @param x x position + * @param y y position + * @param slotClick IDK figure it out */ public AuctionTypeWidget(int x, int y, SlotClickHandler slotClick) { super(x, y, 17, 17, Text.literal("Auction Type Widget"), slotClick, Option.ALL); @@ -25,13 +25,17 @@ public class AuctionTypeWidget extends SliderWidget { private final Identifier texture; private static final String prefix = "textures/gui/auctions_gui/auction_type_widget/"; private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "hover.png"); - private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE,prefix + "back.png"); + private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "back.png"); Option(String textureName) { texture = new Identifier(SkyblockerMod.NAMESPACE, prefix + textureName); } + private static final AuctionTypeWidget.Option[] values = values(); - public static AuctionTypeWidget.Option get(int ordinal) {return values[MathHelper.clamp(ordinal, 0, values.length-1)];} + + public static AuctionTypeWidget.Option get(int ordinal) { + return values[MathHelper.clamp(ordinal, 0, values.length - 1)]; + } @Override public boolean isVertical() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java index 6c515e50..f200179a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java @@ -33,11 +33,11 @@ public class CategoryTabWidget extends ToggleButtonWidget { if (textures == null) return; Identifier identifier = textures.get(true, this.toggled); int x = getX(); - if (toggled) x-=2; + if (toggled) x -= 2; //RenderSystem.disableDepthTest(); context.drawGuiTexture(identifier, x, this.getY(), this.width, this.height); //RenderSystem.enableDepthTest(); - context.drawItem(icon, x+9, getY()+5); + context.drawItem(icon, x + 9, getY() + 5); if (isMouseOver(mouseX, mouseY)) { context.getMatrices().push(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java index 1affdc0c..a5bc34a3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java @@ -45,8 +45,8 @@ public class RarityWidget extends ClickableWidget { matrices.push(); //matrices.translate(-7-getX(), -5.5f-getY(), 0); matrices.translate(7, 5.5f, 0); - matrices.scale(34.f/textWidth, 34.f/textWidth, 1.f); - context.drawText(textRenderer, current, 0, -textRenderer.fontHeight/2, color, false); + matrices.scale(34.f / textWidth, 34.f / textWidth, 1.f); + context.drawText(textRenderer, current, 0, -textRenderer.fontHeight / 2, color, false); matrices.pop(); } else { context.drawText(textRenderer, current, 7, 2, color, false); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java index 97543d23..c1f73f20 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java @@ -21,13 +21,12 @@ public class SliderWidget & SliderWidget.OptionInfo> extends C float posProgress; /** - * - * @param x x position - * @param y y position - * @param width width - * @param height height - * @param message probably useless, just put the widget name - * @param clickSlot the parent AuctionsBrowser + * @param x x position + * @param y y position + * @param width width + * @param height height + * @param message probably useless, just put the widget name + * @param clickSlot the parent AuctionsBrowser * @param defaultOption the default option should be the one at ordinal 0 */ public SliderWidget(int x, int y, int width, int height, Text message, SlotClickHandler clickSlot, E defaultOption) { @@ -51,8 +50,8 @@ public class SliderWidget & SliderWidget.OptionInfo> extends C context.getMatrices().push(); context.getMatrices().translate(getX(), getY(), 0); - int x = current.isVertical() ? 0: Math.round(posProgress); - int y = current.isVertical() ? Math.round(posProgress): 0; + int x = current.isVertical() ? 0 : Math.round(posProgress); + int y = current.isVertical() ? Math.round(posProgress) : 0; int optionWidth = current.getOptionSize()[0]; int optionHeight = current.getOptionSize()[1]; @@ -89,7 +88,9 @@ public class SliderWidget & SliderWidget.OptionInfo> extends C } @Override - protected void appendClickableNarrations(NarrationMessageBuilder builder) {} + protected void appendClickableNarrations(NarrationMessageBuilder builder) { + } + public interface OptionInfo { boolean isVertical(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java index 62c3a497..dab3c6b4 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SortWidget.java @@ -9,9 +9,9 @@ import net.minecraft.util.math.MathHelper; public class SortWidget extends SliderWidget { /** - * @param x x position - * @param y y position - * @param clickSlot the parent AuctionsBrowser + * @param x x position + * @param y y position + * @param clickSlot the parent AuctionsBrowser */ public SortWidget(int x, int y, SlotClickHandler clickSlot) { super(x, y, 36, 9, Text.literal("Sort Widget"), clickSlot, Option.HIGH); @@ -26,17 +26,21 @@ public class SortWidget extends SliderWidget { private final Identifier texture; private static final String prefix = "textures/gui/auctions_gui/sort_widget/"; private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "hover.png"); - private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE,prefix + "back.png"); + private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "back.png"); Option(String textureName) { texture = new Identifier(SkyblockerMod.NAMESPACE, prefix + textureName); } + public Identifier getOptionTexture() { return texture; } private static final Option[] values = values(); - public static Option get(int ordinal) {return values[MathHelper.clamp(ordinal, 0, values.length-1)];} + + public static Option get(int ordinal) { + return values[MathHelper.clamp(ordinal, 0, values.length - 1)]; + } @Override public boolean isVertical() { -- cgit From 3597b0ef53f35859056e9c3c2f167a0fee553fea Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sat, 23 Mar 2024 21:41:47 +0100 Subject: begone unused imports --- .../de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java index c1f73f20..549980ae 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java @@ -7,9 +7,6 @@ import net.minecraft.client.gui.widget.ClickableWidget; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import java.util.function.Consumer; -import java.util.function.DoubleConsumer; - // This is kinda excessive, but I thought it was a good idea public class SliderWidget & SliderWidget.OptionInfo> extends ClickableWidget { private final SlotClickHandler clickSlot; -- cgit From 7e9fb689583c640cd664b9578402eb434fe15f17 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sat, 23 Mar 2024 22:52:56 +0100 Subject: c h aaan ggeess --- .../skyblock/auction/AuctionBrowserScreen.java | 4 ++-- .../skyblocker/skyblock/auction/AuctionViewScreen.java | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 31c84d9e..360c0cd3 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -84,7 +84,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI this.clickSlot(BACK_BUTTON_SLOT)) - .position(x + backgroundWidth - 16, y+4) + .position(x + 98, y+4) .size(12, 12) .build()); @@ -142,7 +142,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { protected static final Identifier BACKGROUND_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background_view.png"); + public static final int BACK_BUTTON_SLOT = 49; + DirectionalLayoutWidget verticalLayout = DirectionalLayoutWidget.vertical(); public final boolean isBinAuction; @@ -35,14 +37,17 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI { + buyButton = ButtonWidget.builder(Text.literal(isBinAuction ? "Buy!" : "Bid!"), button -> { if (buySlotID == -1) return; clickSlot(buySlotID); - }).size(50, 12).build()); + }).size(50, 12).build(); + verticalLayout.add(buyButton); verticalLayout.forEachChild(this::addDrawableChild); updateLayout(); + addDrawableChild(new ButtonWidget.Builder( Text.literal("<"), button -> this.clickSlot(BACK_BUTTON_SLOT)) + .position(x + backgroundWidth - 16, y+4) + .size(12, 12) + .build()); + } @@ -78,6 +89,7 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI cantAffordText.setMessage(Text.empty()); } cantAffordText.setWidth(textRenderer.getWidth(cantAffordText.getMessage())); + buyButton.active = buyState != BuyState.CANT_AFFORD; updateLayout(); } -- cgit From 7dc87dce4304a9d563be8d491cb047db6e9a81d3 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sat, 23 Mar 2024 23:26:51 +0100 Subject: slot highlight --- .../skyblock/auction/AuctionBrowserScreen.java | 139 ++++++++++++++------- .../skyblock/item/tooltip/ItemTooltip.java | 49 ++++---- 2 files changed, 124 insertions(+), 64 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 360c0cd3..0e40758f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -1,11 +1,15 @@ package de.hysky.skyblocker.skyblock.auction; +import com.google.gson.JsonElement; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.skyblock.auction.widgets.AuctionTypeWidget; import de.hysky.skyblocker.skyblock.auction.widgets.CategoryTabWidget; import de.hysky.skyblocker.skyblock.auction.widgets.RarityWidget; import de.hysky.skyblocker.skyblock.auction.widgets.SortWidget; +import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; +import de.hysky.skyblocker.skyblock.item.tooltip.TooltipInfoType; import de.hysky.skyblocker.utils.render.gui.AbstractCustomHypixelGUI; +import it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -25,6 +29,7 @@ import net.minecraft.util.Colors; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; +import java.awt.*; import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; @@ -50,6 +55,8 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI= handler.getRows()*9) return; @@ -199,50 +214,88 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); - int ordinal = getOrdinal(tooltip); - String split = tooltip.get(ordinal+2).getString().substring(2); - rarityWidget.setText(tooltip.subList(1, tooltip.size()-3), split); - } else if (slotId == RESET_BUTTON_SLOT) { - if (resetFiltersButton != null) resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); - } else if (slotId < this.handler.getRows()*9 && slotId%9 == 0) { - CategoryTabWidget categoryTabWidget = categoryTabWidgets.get(slotId / 9); - categoryTabWidget.setSlotId(slotId); - categoryTabWidget.setIcon(handler.getSlot(slotId).getStack()); - List tooltip = handler.getSlot(slotId).getStack().getTooltip(client.player, TooltipContext.BASIC); - for (int j = tooltip.size() - 1; j >= 0; j--) { - String lowerCase = tooltip.get(j).getString().toLowerCase(); - if (lowerCase.contains("currently")) { - categoryTabWidget.setToggled(true); - break; - } else if (lowerCase.contains("click")) { - categoryTabWidget.setToggled(false); - break; - } else categoryTabWidget.setToggled(false); + + switch (slotId) { + case PREV_PAGE_BUTTON -> { + prevPageVisible = false; + if (stack.isOf(Items.ARROW)) { + prevPageVisible = true; + parsePage(stack); + } + } + case NEXT_PAGE_BUTTON -> { + nextPageVisible = false; + if (stack.isOf(Items.ARROW)) { + nextPageVisible = true; + parsePage(stack); + } + } + case SORT_BUTTON_SLOT -> sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + case AUCTION_TYPE_BUTTON_SLOT -> auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + case RARITY_BUTTON_SLOT -> { + List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); + int ordinal = getOrdinal(tooltip); + String split = tooltip.get(ordinal+2).getString().substring(2); + rarityWidget.setText(tooltip.subList(1, tooltip.size()-3), split); + } + case RESET_BUTTON_SLOT -> { + if (resetFiltersButton != null) resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); + } + case SEARCH_BUTTON_SLOT -> { + List tooltipSearch = stack.getTooltip(client.player, TooltipContext.BASIC); + for (Text text : tooltipSearch) { + String string = text.getString(); + if (string.contains("Filtered:")) { + String[] splitSearch = string.split(":"); + if (splitSearch.length < 2) { + search = ""; + } else search = splitSearch[1].trim(); + break; + } + } } - } else if (slotId == PREV_PAGE_BUTTON && stack.isOf(Items.ARROW)) { - prevPageVisible = true; - parsePage(stack); - } else if (slotId == NEXT_PAGE_BUTTON && stack.isOf(Items.ARROW)) { - nextPageVisible = true; - parsePage(stack); - } else if (slotId == SEARCH_BUTTON_SLOT) { - List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); - for (Text text : tooltip) { - String string = text.getString(); - if (string.contains("Filtered:")) { - String[] split = string.split(":"); - if (split.length < 2) { - search = ""; - } else search = split[1].trim(); - break; + default -> { + if (slotId < this.handler.getRows()*9 && slotId%9 == 0) { + CategoryTabWidget categoryTabWidget = categoryTabWidgets.get(slotId / 9); + categoryTabWidget.setSlotId(slotId); + categoryTabWidget.setIcon(handler.getSlot(slotId).getStack()); + List tooltipDefault = handler.getSlot(slotId).getStack().getTooltip(client.player, TooltipContext.BASIC); + for (int j = tooltipDefault.size() - 1; j >= 0; j--) { + String lowerCase = tooltipDefault.get(j).getString().toLowerCase(); + if (lowerCase.contains("currently")) { + categoryTabWidget.setToggled(true); + break; + } else if (lowerCase.contains("click")) { + categoryTabWidget.setToggled(false); + break; + } else categoryTabWidget.setToggled(false); + } + } else if (slotId > 9 && slotId < (handler.getRows()-1)*9 && slotId%9 > 1 && slotId%9 < 8) { + List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); + for (int k = tooltip.size() - 1; k >= 0; k--) { + Text text = tooltip.get(k); + String string = text.getString(); + if (string.toLowerCase().contains("buy it now:")) { + String[] split = string.split(":"); + if (split.length < 2) continue; + String coins = split[1].replace(",", "").replace("coins", "").trim(); + try { + int parsed = Integer.parseInt(coins); + String name = ItemTooltip.getInternalNameFromNBT(stack, false); + String internalID = ItemTooltip.getInternalNameFromNBT(stack, true); + String neuName = name; + if (name == null || internalID == null) break; + if (name.startsWith("ISSHINY_")) { + neuName = internalID; + } + JsonElement jsonElement = TooltipInfoType.THREE_DAY_AVERAGE.getData().get(ItemTooltip.getNeuName(internalID, neuName)); + if (jsonElement == null) break; + else { + isSlotHighlighted.put(slotId, jsonElement.getAsDouble() > parsed); + } + } catch (NumberFormatException ignored) {} + } + } } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java index 62c50735..7c3be9c9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/ItemTooltip.java @@ -20,6 +20,7 @@ import net.minecraft.nbt.NbtElement; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,27 +93,7 @@ public class ItemTooltip { We are skipping check average prices for potions, runes and enchanted books because there is no data for their in API. */ - switch (internalID) { - case "PET" -> { - neuName = neuName.replaceAll("LVL_\\d*_", ""); - String[] parts = neuName.split("_"); - String type = parts[0]; - neuName = neuName.replaceAll(type + "_", ""); - neuName = neuName + "-" + type; - neuName = neuName.replace("UNCOMMON", "1") - .replace("COMMON", "0") - .replace("RARE", "2") - .replace("EPIC", "3") - .replace("LEGENDARY", "4") - .replace("MYTHIC", "5") - .replace("-", ";"); - } - case "RUNE" -> neuName = neuName.replaceAll("_(?!.*_)", ";"); - case "POTION" -> neuName = ""; - case "ATTRIBUTE_SHARD" -> - neuName = internalID + "+" + neuName.replace("SHARD-", "").replaceAll("_(?!.*_)", ";"); - default -> neuName = neuName.replace(":", "-"); - } + neuName = getNeuName(internalID, neuName); if (!neuName.isEmpty() && lbinExist) { SkyblockerConfig.Average type = config.avg; @@ -264,6 +245,32 @@ public class ItemTooltip { } } + @NotNull + public static String getNeuName(String internalID, String neuName) { + switch (internalID) { + case "PET" -> { + neuName = neuName.replaceAll("LVL_\\d*_", ""); + String[] parts = neuName.split("_"); + String type = parts[0]; + neuName = neuName.replaceAll(type + "_", ""); + neuName = neuName + "-" + type; + neuName = neuName.replace("UNCOMMON", "1") + .replace("COMMON", "0") + .replace("RARE", "2") + .replace("EPIC", "3") + .replace("LEGENDARY", "4") + .replace("MYTHIC", "5") + .replace("-", ";"); + } + case "RUNE" -> neuName = neuName.replaceAll("_(?!.*_)", ";"); + case "POTION" -> neuName = ""; + case "ATTRIBUTE_SHARD" -> + neuName = internalID + "+" + neuName.replace("SHARD-", "").replaceAll("_(?!.*_)", ";"); + default -> neuName = neuName.replace(":", "-"); + } + return neuName; + } + private static void addExoticTooltip(List lines, String internalID, NbtCompound nbt, String colorHex, String expectedHex, String existingTooltip) { if (expectedHex != null && !colorHex.equalsIgnoreCase(expectedHex) && !ExoticTooltip.isException(internalID, colorHex) && !ExoticTooltip.intendedDyed(nbt)) { final ExoticTooltip.DyeType type = ExoticTooltip.checkDyeType(colorHex); -- cgit From 047b356c63d5e271930f09a8ac40073bae6c8167 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sun, 24 Mar 2024 16:04:12 +0100 Subject: Auction view edge cases --- .../skyblock/auction/AuctionViewScreen.java | 111 ++++++++++++++++++--- .../skyblocker/skyblock/auction/EditBidPopup.java | 16 ++- 2 files changed, 109 insertions(+), 18 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java index d8612abc..1654334c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java @@ -17,11 +17,15 @@ import net.minecraft.screen.slot.SlotActionType; import net.minecraft.text.MutableText; import net.minecraft.text.Style; import net.minecraft.text.Text; +import net.minecraft.text.TextColor; import net.minecraft.util.Colors; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicReference; public class AuctionViewScreen extends AbstractCustomHypixelGUI { protected static final Identifier BACKGROUND_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background_view.png"); @@ -34,12 +38,13 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI { if (buySlotID == -1) return; clickSlot(buySlotID); - }).size(50, 12).build(); + }).size(60, 15).build(); verticalLayout.add(buyButton); verticalLayout.forEachChild(this::addDrawableChild); updateLayout(); @@ -84,12 +90,44 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI cantAffordText.setMessage(Text.literal("Can't Afford!").withColor(Colors.RED)); - case TOP_BID -> cantAffordText.setMessage(Text.literal("Already top bid!").withColor(Colors.LIGHT_YELLOW)); - case AFFORD -> cantAffordText.setMessage(Text.empty()); + case CANT_AFFORD -> { + infoTextWidget.setMessage(Text.literal("Can't Afford!").withColor(Colors.RED)); + buyButton.active = false; + } + case TOP_BID -> infoTextWidget.setMessage(Text.literal("Already top bid!").withColor(Colors.LIGHT_YELLOW)); + case AFFORD -> infoTextWidget.setMessage(Text.empty()); + case COLLECT_AUCTION -> { + infoTextWidget.setMessage(changeProfile ? Text.literal("On a different profile"): wonAuction ? Text.empty() : Text.literal("Didn't win :(")); + //priceWidget.setMessage(Text.empty()); + priceWidget.active = false; + + if (changeProfile) { + buyButton.setMessage(Text.literal("Change Profile").setStyle(Style.EMPTY.withColor(Formatting.AQUA))); + } else if (wonAuction) { + buyButton.setMessage(Text.literal("Collect Auction")); + } else { + buyButton.setMessage(Text.literal("Collect Bid")); + } + buyButton.setWidth(textRenderer.getWidth(buyButton.getMessage()) + 4); + + priceTextWidget.setMessage(Text.literal("Auction Ended!")); + priceTextWidget.setWidth(textRenderer.getWidth(priceTextWidget.getMessage())); + } + case CANCELLABLE_AUCTION -> { + buyButton.setMessage(Text.literal("Cancel Auction").setStyle(Style.EMPTY.withColor(Formatting.RED))); + buyButton.setWidth(textRenderer.getWidth(buyButton.getMessage()) + 4); + + buyButton.active = true; + buyButton.visible = true; + } + case OWN_AUCTION -> { + buyButton.visible = false; + priceWidget.active = false; + + infoTextWidget.setMessage(Text.literal("This is your auction!")); + } } - cantAffordText.setWidth(textRenderer.getWidth(cantAffordText.getMessage())); - buyButton.active = buyState != BuyState.CANT_AFFORD; + infoTextWidget.setWidth(textRenderer.getWidth(infoTextWidget.getMessage())); updateLayout(); } @@ -120,7 +158,7 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI tooltip) { if (priceParsed) return; String minBid = null; - String priceString = "???"; + String priceString = null; + AtomicReference stringAtomicReference = new AtomicReference<>(""); + for (Text text : tooltip) { String string = text.getString(); String thingToLookFor = (isBinAuction) ? "price:" : "new bid:"; - if (string.toLowerCase().contains(thingToLookFor)) { + String lowerCase = string.toLowerCase(); + if (lowerCase.contains(thingToLookFor)) { String[] split = string.split(":"); if (split.length < 2) continue; priceString = split[1].trim(); - break; - } else if (string.toLowerCase().contains("minimum bid:") && !isBinAuction) { + } else if (lowerCase.contains("minimum bid:") && !isBinAuction) { String[] split = string.split(":"); if (split.length < 2) continue; minBid = split[1].replace("coins", "").replace(",", "").trim(); + } else if (lowerCase.contains("you pay:")) { + String[] split = string.split(":"); + if (split.length < 2) continue; + if (buyState != BuyState.CANT_AFFORD && !isBinAuction) { + infoTextWidget.setMessage(Text.literal("You pay: " + split[1].trim())); + infoTextWidget.setWidth(textRenderer.getWidth(infoTextWidget.getMessage())); + } + + } else if (lowerCase.contains("top bid:")) { // Shows up when an auction ended and you lost + wonAuction = false; + } else if (lowerCase.contains("correct profile")) { // When an auction ended but on a different profile + changeProfile = true; + priceWidget.setMessage(Text.empty()); + } else if (lowerCase.contains("own auction")) { // it's yours + changeState(BuyState.OWN_AUCTION); } + text.visit((style, asString) -> { + // The regex removes [, ] and +. To ignore mvp++ rank and orange + in mvp+ + String res = Objects.equals(style.getColor(), TextColor.fromFormatting(Formatting.GOLD)) && !asString.matches(".*[]\\[+].*") && !asString.contains("Collect") ? asString: null; + return Optional.ofNullable(res); + }, Style.EMPTY).ifPresent(s -> stringAtomicReference.set(stringAtomicReference.get()+s)); } + //System.out.println("Experiment: " + stringAtomicReference.get()); + if (priceString == null) priceString = stringAtomicReference.get(); if (minBid != null) this.minBid = minBid; else this.minBid = priceString; priceText = Text.literal(priceString).setStyle(Style.EMPTY.withFormatting(Formatting.BOLD).withColor(Formatting.GOLD)); @@ -211,6 +287,9 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI Date: Sun, 24 Mar 2024 17:47:39 +0100 Subject: localization and config --- .../hysky/skyblocker/config/SkyblockerConfig.java | 10 +++++++ .../config/categories/GeneralCategory.java | 20 ++++++++++++++ .../mixin/HandledScreenProviderMixin.java | 8 +++--- .../skyblock/auction/AuctionBrowserScreen.java | 4 ++- .../skyblock/auction/AuctionViewScreen.java | 32 +++++++++++----------- .../resources/assets/skyblocker/lang/en_us.json | 23 +++++++++++++++- 6 files changed, 75 insertions(+), 22 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index bf98ac1f..a8f22bbc 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -250,6 +250,9 @@ public class SkyblockerConfig { @SerialEntry public SearchOverlay searchOverlay = new SearchOverlay(); + @SerialEntry + public FancyAuctionHouse fancyAuctionHouse = new FancyAuctionHouse(); + @SerialEntry public List lockedSlots = new ArrayList<>(); @@ -269,6 +272,13 @@ public class SkyblockerConfig { public Object2ObjectOpenHashMap customAnimatedDyes = new Object2ObjectOpenHashMap<>(); } + public static class FancyAuctionHouse { + @SerialEntry + public boolean enabled = true; + @SerialEntry + public boolean highlightCheapBIN = true; + } + public static class TabHudConf { @SerialEntry public boolean tabHudEnabled = true; diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index e310cb85..a74b9483 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -739,6 +739,26 @@ public class GeneralCategory { .controller(ConfigUtils::createBooleanController) .build()) .build()) + + // Fancy Auction House + .group(OptionGroup.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.betterAuctionHouse")) + .collapsed(true) + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.betterAuctionHouse.enabled")) + .binding(defaults.general.fancyAuctionHouse.enabled, + () -> config.general.fancyAuctionHouse.enabled, + newValue -> config.general.fancyAuctionHouse.enabled = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.general.betterAuctionHouse.highlightUnderAvgPrice")) + .binding(defaults.general.fancyAuctionHouse.highlightCheapBIN, + () -> config.general.fancyAuctionHouse.highlightCheapBIN, + newValue -> config.general.fancyAuctionHouse.highlightCheapBIN = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .build()) .build(); } } diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java index 75d604a6..566cc18f 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java @@ -31,7 +31,7 @@ public interface HandledScreenProviderMixin { T screenHandler = type.create(id, player.getInventory()); if (!(screenHandler instanceof GenericContainerScreenHandler containerScreenHandler)) return; String nameLowercase = name.getString().toLowerCase(); - if (PartyFinderScreen.possibleInventoryNames.contains(nameLowercase)) { + if (SkyblockerConfigManager.get().general.betterPartyFinder && PartyFinderScreen.possibleInventoryNames.contains(nameLowercase)) { if (SkyblockerConfigManager.get().general.betterPartyFinder && screenHandler instanceof GenericContainerScreenHandler containerScreenHandler && PartyFinderScreen.possibleInventoryNames.contains(name.getString().toLowerCase())) { if (client.currentScreen != null) { String lowerCase = client.currentScreen.getTitle().getString().toLowerCase(); @@ -51,21 +51,21 @@ public interface HandledScreenProviderMixin { } ci.cancel(); - } else if (nameLowercase.contains("auctions browser") || nameLowercase.contains("auctions: ")) { + } else if (SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && (nameLowercase.contains("auctions browser") || nameLowercase.contains("auctions: "))) { AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, false); client.player.currentScreenHandler = auctionHouseScreenHandler; if (client.currentScreen instanceof AuctionBrowserScreen auctionBrowserScreen) { auctionBrowserScreen.changeHandler(auctionHouseScreenHandler); } else client.setScreen(new AuctionBrowserScreen(auctionHouseScreenHandler, client.player.getInventory())); ci.cancel(); - } else if (nameLowercase.contains("auction view")) { + } else if (SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && nameLowercase.contains("auction view")) { AuctionHouseScreenHandler auctionHouseScreenHandler = AuctionHouseScreenHandler.of(containerScreenHandler, true); client.player.currentScreenHandler = auctionHouseScreenHandler; if (client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { auctionViewScreen.changeHandler(auctionHouseScreenHandler); } else client.setScreen(new AuctionViewScreen(auctionHouseScreenHandler, client.player.getInventory(), name)); ci.cancel(); - } else if ((nameLowercase.contains("confirm purchase") || nameLowercase.contains("confirm bid")) && client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { + } else if (SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && (nameLowercase.contains("confirm purchase") || nameLowercase.contains("confirm bid")) && client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { client.setScreen(auctionViewScreen.getConfirmPurchasePopup(name)); client.player.currentScreenHandler = containerScreenHandler; ci.cancel(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 0e40758f..8e0c695b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -2,6 +2,7 @@ package de.hysky.skyblocker.skyblock.auction; import com.google.gson.JsonElement; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.auction.widgets.AuctionTypeWidget; import de.hysky.skyblocker.skyblock.auction.widgets.CategoryTabWidget; import de.hysky.skyblocker.skyblock.auction.widgets.RarityWidget; @@ -162,7 +163,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI 9 && slotId < (handler.getRows()-1)*9 && slotId%9 > 1 && slotId%9 < 8) { List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); + if (!SkyblockerConfigManager.get().general.fancyAuctionHouse.highlightCheapBIN) return; for (int k = tooltip.size() - 1; k >= 0; k--) { Text text = tooltip.get(k); String string = text.getString(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java index 1654334c..82cd4a91 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java @@ -36,7 +36,7 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI { + buyButton = ButtonWidget.builder(isBinAuction ? Text.translatable("skyblocker.fancyAuctionHouse.buy") : Text.translatable("skyblocker.fancyAuctionHouse.bid"), button -> { if (buySlotID == -1) return; clickSlot(buySlotID); }).size(60, 15).build(); @@ -91,30 +91,30 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI { - infoTextWidget.setMessage(Text.literal("Can't Afford!").withColor(Colors.RED)); + infoTextWidget.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.cantAfford").withColor(Colors.RED)); buyButton.active = false; } - case TOP_BID -> infoTextWidget.setMessage(Text.literal("Already top bid!").withColor(Colors.LIGHT_YELLOW)); + case TOP_BID -> infoTextWidget.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.alreadyTopBid").withColor(Colors.LIGHT_YELLOW)); case AFFORD -> infoTextWidget.setMessage(Text.empty()); case COLLECT_AUCTION -> { - infoTextWidget.setMessage(changeProfile ? Text.literal("On a different profile"): wonAuction ? Text.empty() : Text.literal("Didn't win :(")); + infoTextWidget.setMessage(changeProfile ? Text.translatable("skyblocker.fancyAuctionHouse.differentProfile"): wonAuction ? Text.empty() : Text.translatable("skyblocker.fancyAuctionHouse.didntWin")); //priceWidget.setMessage(Text.empty()); priceWidget.active = false; if (changeProfile) { - buyButton.setMessage(Text.literal("Change Profile").setStyle(Style.EMPTY.withColor(Formatting.AQUA))); + buyButton.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.changeProfile").setStyle(Style.EMPTY.withColor(Formatting.AQUA))); } else if (wonAuction) { - buyButton.setMessage(Text.literal("Collect Auction")); + buyButton.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.collectAuction")); } else { - buyButton.setMessage(Text.literal("Collect Bid")); + buyButton.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.collectBid")); } buyButton.setWidth(textRenderer.getWidth(buyButton.getMessage()) + 4); - priceTextWidget.setMessage(Text.literal("Auction Ended!")); + priceTextWidget.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.auctionEnded")); priceTextWidget.setWidth(textRenderer.getWidth(priceTextWidget.getMessage())); } case CANCELLABLE_AUCTION -> { - buyButton.setMessage(Text.literal("Cancel Auction").setStyle(Style.EMPTY.withColor(Formatting.RED))); + buyButton.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.cancelAuction").setStyle(Style.EMPTY.withColor(Formatting.RED))); buyButton.setWidth(textRenderer.getWidth(buyButton.getMessage()) + 4); buyButton.active = true; @@ -124,7 +124,7 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI this.client.interactionManager.clickSlot(this.client.player.currentScreenHandler.syncId, 11, 0, SlotActionType.PICKUP, client.player)) - .button(Text.literal("Cancel"), popupScreen -> this.client.interactionManager.clickSlot(this.client.player.currentScreenHandler.syncId, 15, 0, SlotActionType.PICKUP, client.player)) - .message(Text.literal(isBinAuction ? "Price: " : "New Bid: ").append(priceText)).build(); + .button(Text.translatable("text.skyblocker.confirm"), popupScreen -> this.client.interactionManager.clickSlot(this.client.player.currentScreenHandler.syncId, 11, 0, SlotActionType.PICKUP, client.player)) + .button(Text.translatable("gui.cancel"), popupScreen -> this.client.interactionManager.clickSlot(this.client.player.currentScreenHandler.syncId, 15, 0, SlotActionType.PICKUP, client.player)) + .message((isBinAuction ? Text.translatable("skyblocker.fancyAuctionHouse.price") : Text.translatable("skyblocker.fancyAuctionHouse.newBid")).append(" ").append(priceText)).build(); } private enum BuyState { diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index b1f3df9f..bda6a909 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -11,6 +11,7 @@ "text.skyblocker.quit_config": "Changes Not Saved", "text.skyblocker.quit_config_sure": "Are you sure you want to quit editing the config? Changes will not be saved!", "text.skyblocker.quit_discard": "Quit & Discard Changes", + "text.skyblocker.confirm": "Confirm", "text.skyblocker.config": "Open Config...", "text.skyblocker.source": "Source", "text.skyblocker.website": "Website", @@ -168,6 +169,9 @@ "text.autoconfig.skyblocker.option.general.searchOverlay.historyLabel": "History:", "text.autoconfig.skyblocker.option.general.betterPartyFinder": "Better Party Finder", "text.autoconfig.skyblocker.option.general.fancyCraftingTable": "Fancy Crafting Table UI", + "text.autoconfig.skyblocker.option.general.betterAuctionHouse": "Better Auction House", + "text.autoconfig.skyblocker.option.general.betterAuctionHouse.enabled": "Enabled", + "text.autoconfig.skyblocker.option.general.betterAuctionHouse.highlightUnderAvgPrice": "Highlight BIN under average price", "skyblocker.itemTooltip.nullMessage": "§cItem price information on tooltip will renew in max 60 seconds. If not, check latest.log", "skyblocker.itemTooltip.noData": "§cNo Data", @@ -619,9 +623,26 @@ "skyblocker.partyFinder.deList": "Click to de-list", "skyblocker.partyFinder.join": "Click to join", + "skyblocker.fancyAuctionHouse.editBid": "Click to edit bid!", + "skyblocker.fancyAuctionHouse.price": "Price:", + "skyblocker.fancyAuctionHouse.newBid": "New Bid:", + "skyblocker.fancyAuctionHouse.buy": "Buy!", + "skyblocker.fancyAuctionHouse.bid": "Bid!", + "skyblocker.fancyAuctionHouse.cantAfford": "Can't Afford!", + "skyblocker.fancyAuctionHouse.alreadyTopBid": "Already Top Bid!", + "skyblocker.fancyAuctionHouse.differentProfile": "On a different profile", + "skyblocker.fancyAuctionHouse.didntWin": "Didn't win :(", + "skyblocker.fancyAuctionHouse.changeProfile": "Change Profile", + "skyblocker.fancyAuctionHouse.collectAuction": "Collect Auction", + "skyblocker.fancyAuctionHouse.collectBid": "Collect Bid", + "skyblocker.fancyAuctionHouse.auctionEnded": "Auction Ended!", + "skyblocker.fancyAuctionHouse.cancelAuction": "Cancel Auction", + "skyblocker.fancyAuctionHouse.yourAuction": "This is your auction!", + "skyblocker.fancyAuctionHouse.youPay": "You pay: %s", + "skyblocker.crimson.kuudra.noArrowPoison": "No Arrow Poison!", "skyblocker.crimson.kuudra.lowArrowPoison": "Low on Arrow Poison!", - + "skyblocker.waypoints.ordered.groupNonExistent": "§cThe waypoint group %s doesn't exist.", "skyblocker.waypoints.ordered.add.invalidHexColor": "§cInvalid HEX color code!", "skyblocker.waypoints.ordered.addAt.success": "Added a waypoint in group %s at index %d.", -- cgit From 8ed55895fc8469e22e3ae65bf450f3af794d2545 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Sun, 24 Mar 2024 17:59:31 +0100 Subject: REFORMAT WHOLE FILE THE SEQUEL --- .../mixin/HandledScreenProviderMixin.java | 5 +- .../skyblock/auction/AuctionBrowserScreen.java | 53 ++++++++++++---------- .../skyblock/auction/AuctionViewScreen.java | 15 +++--- .../skyblocker/skyblock/auction/EditBidPopup.java | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java index 566cc18f..373785d0 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/HandledScreenProviderMixin.java @@ -29,7 +29,7 @@ public interface HandledScreenProviderMixin { if (player == null) return; if (!Utils.isOnSkyblock()) return; T screenHandler = type.create(id, player.getInventory()); - if (!(screenHandler instanceof GenericContainerScreenHandler containerScreenHandler)) return; + if (!(screenHandler instanceof GenericContainerScreenHandler containerScreenHandler)) return; String nameLowercase = name.getString().toLowerCase(); if (SkyblockerConfigManager.get().general.betterPartyFinder && PartyFinderScreen.possibleInventoryNames.contains(nameLowercase)) { if (SkyblockerConfigManager.get().general.betterPartyFinder && screenHandler instanceof GenericContainerScreenHandler containerScreenHandler && PartyFinderScreen.possibleInventoryNames.contains(name.getString().toLowerCase())) { @@ -63,7 +63,8 @@ public interface HandledScreenProviderMixin { client.player.currentScreenHandler = auctionHouseScreenHandler; if (client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { auctionViewScreen.changeHandler(auctionHouseScreenHandler); - } else client.setScreen(new AuctionViewScreen(auctionHouseScreenHandler, client.player.getInventory(), name)); + } else + client.setScreen(new AuctionViewScreen(auctionHouseScreenHandler, client.player.getInventory(), name)); ci.cancel(); } else if (SkyblockerConfigManager.get().general.fancyAuctionHouse.enabled && (nameLowercase.contains("confirm purchase") || nameLowercase.contains("confirm bid")) && client.currentScreen instanceof AuctionViewScreen auctionViewScreen) { client.setScreen(auctionViewScreen.getConfirmPurchasePopup(name)); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 8e0c695b..6d87515d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -91,8 +91,8 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI this.clickSlot(BACK_BUTTON_SLOT)) - .position(x + 98, y+4) + addDrawableChild(new ButtonWidget.Builder(Text.literal("<"), button -> this.clickSlot(BACK_BUTTON_SLOT)) + .position(x + 98, y + 4) .size(12, 12) .build()); @@ -132,9 +132,9 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI= handler.getRows()*9) return; + if (slotId >= handler.getRows() * 9) return; super.onMouseClick(slot, slotId, button, actionType); } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (isWaitingForServer) return super.mouseClicked(mouseX, mouseY, button); - if (onScrollbarTop((int)mouseX, (int) mouseY) && prevPageVisible) { + if (onScrollbarTop((int) mouseX, (int) mouseY) && prevPageVisible) { clickSlot(PREV_PAGE_BUTTON); return true; } - if (onScrollbarBottom((int)mouseX, (int) mouseY) && nextPageVisible) { + if (onScrollbarBottom((int) mouseX, (int) mouseY) && nextPageVisible) { clickSlot(NEXT_PAGE_BUTTON); return true; } - if (onSearchField((int)mouseX, (int) mouseY)) { + if (onSearchField((int) mouseX, (int) mouseY)) { clickSlot(SEARCH_BUTTON_SLOT); return true; } @@ -205,6 +205,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI 154 && localX < 169 && localY > 43 && localY < 80; } + private boolean onSearchField(int mouseX, int mouseY) { int localX = mouseX - x; int localY = mouseY - y; @@ -231,16 +232,19 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); - case AUCTION_TYPE_BUTTON_SLOT -> auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + case SORT_BUTTON_SLOT -> + sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + case AUCTION_TYPE_BUTTON_SLOT -> + auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); case RARITY_BUTTON_SLOT -> { List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); int ordinal = getOrdinal(tooltip); - String split = tooltip.get(ordinal+2).getString().substring(2); - rarityWidget.setText(tooltip.subList(1, tooltip.size()-3), split); + String split = tooltip.get(ordinal + 2).getString().substring(2); + rarityWidget.setText(tooltip.subList(1, tooltip.size() - 3), split); } case RESET_BUTTON_SLOT -> { - if (resetFiltersButton != null) resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); + if (resetFiltersButton != null) + resetFiltersButton.active = handler.getSlot(slotId).getStack().isOf(Items.ANVIL); } case SEARCH_BUTTON_SLOT -> { List tooltipSearch = stack.getTooltip(client.player, TooltipContext.BASIC); @@ -256,7 +260,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { - if (slotId < this.handler.getRows()*9 && slotId%9 == 0) { + if (slotId < this.handler.getRows() * 9 && slotId % 9 == 0) { CategoryTabWidget categoryTabWidget = categoryTabWidgets.get(slotId / 9); categoryTabWidget.setSlotId(slotId); categoryTabWidget.setIcon(handler.getSlot(slotId).getStack()); @@ -271,7 +275,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI 9 && slotId < (handler.getRows()-1)*9 && slotId%9 > 1 && slotId%9 < 8) { + } else if (slotId > 9 && slotId < (handler.getRows() - 1) * 9 && slotId % 9 > 1 && slotId % 9 < 8) { List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); if (!SkyblockerConfigManager.get().general.fancyAuctionHouse.highlightCheapBIN) return; for (int k = tooltip.size() - 1; k >= 0; k--) { @@ -295,7 +299,8 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI parsed); } - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } } } } @@ -305,9 +310,9 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip) { int ordinal = 0; - for (int j = 0; j < tooltip.size()-3; j++) { - if (j+2 >= tooltip.size()) break; - if (tooltip.get(j+2).getString().contains("▶")) { + for (int j = 0; j < tooltip.size() - 3; j++) { + if (j + 2 >= tooltip.size()) break; + if (tooltip.get(j + 2).getString().contains("▶")) { ordinal = j; break; } @@ -319,6 +324,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); @@ -328,12 +334,13 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI= (double)(left + this.backgroundWidth) || mouseY >= (double)(top + this.backgroundHeight); + return mouseX < (double) left - 32 || mouseY < (double) top || mouseX >= (double) (left + this.backgroundWidth) || mouseY >= (double) (top + this.backgroundHeight); } private static class ScaledTextButtonWidget extends ButtonWidget { @@ -350,7 +357,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { + buyButton = ButtonWidget.builder(isBinAuction ? Text.translatable("skyblocker.fancyAuctionHouse.buy") : Text.translatable("skyblocker.fancyAuctionHouse.bid"), button -> { if (buySlotID == -1) return; clickSlot(buySlotID); }).size(60, 15).build(); @@ -78,8 +78,8 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI this.clickSlot(BACK_BUTTON_SLOT)) - .position(x + backgroundWidth - 16, y+4) + addDrawableChild(new ButtonWidget.Builder(Text.literal("<"), button -> this.clickSlot(BACK_BUTTON_SLOT)) + .position(x + backgroundWidth - 16, y + 4) .size(12, 12) .build()); @@ -94,10 +94,11 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI infoTextWidget.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.alreadyTopBid").withColor(Colors.LIGHT_YELLOW)); + case TOP_BID -> + infoTextWidget.setMessage(Text.translatable("skyblocker.fancyAuctionHouse.alreadyTopBid").withColor(Colors.LIGHT_YELLOW)); case AFFORD -> infoTextWidget.setMessage(Text.empty()); case COLLECT_AUCTION -> { - infoTextWidget.setMessage(changeProfile ? Text.translatable("skyblocker.fancyAuctionHouse.differentProfile"): wonAuction ? Text.empty() : Text.translatable("skyblocker.fancyAuctionHouse.didntWin")); + infoTextWidget.setMessage(changeProfile ? Text.translatable("skyblocker.fancyAuctionHouse.differentProfile") : wonAuction ? Text.empty() : Text.translatable("skyblocker.fancyAuctionHouse.didntWin")); //priceWidget.setMessage(Text.empty()); priceWidget.active = false; @@ -259,9 +260,9 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI { // The regex removes [, ] and +. To ignore mvp++ rank and orange + in mvp+ - String res = Objects.equals(style.getColor(), TextColor.fromFormatting(Formatting.GOLD)) && !asString.matches(".*[]\\[+].*") && !asString.contains("Collect") ? asString: null; + String res = Objects.equals(style.getColor(), TextColor.fromFormatting(Formatting.GOLD)) && !asString.matches(".*[]\\[+].*") && !asString.contains("Collect") ? asString : null; return Optional.ofNullable(res); - }, Style.EMPTY).ifPresent(s -> stringAtomicReference.set(stringAtomicReference.get()+s)); + }, Style.EMPTY).ifPresent(s -> stringAtomicReference.set(stringAtomicReference.get() + s)); } //System.out.println("Experiment: " + stringAtomicReference.get()); if (priceString == null) priceString = stringAtomicReference.get(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java index 6853d0c4..86d5c44b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java @@ -34,7 +34,7 @@ public class EditBidPopup extends BarebonesPopupScreen { super.init(); layout = DirectionalLayoutWidget.vertical(); layout.spacing(8).getMainPositioner().alignHorizontalCenter(); - textFieldWidget = new TextFieldWidget(textRenderer, 120, 15, Text.empty()){ + textFieldWidget = new TextFieldWidget(textRenderer, 120, 15, Text.empty()) { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (!super.keyPressed(keyCode, scanCode, modifiers)) { -- cgit From c4b7b4ac8e2678eb817df75ad708c6aaa5bfc3e0 Mon Sep 17 00:00:00 2001 From: vicisacat Date: Mon, 25 Mar 2024 22:01:40 +0100 Subject: up and down arrows in browser --- .../skyblocker/skyblock/auction/AuctionBrowserScreen.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 6d87515d..628c5bd5 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -29,6 +29,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Colors; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; +import org.lwjgl.glfw.GLFW; import java.awt.*; import java.util.ArrayList; @@ -308,6 +309,19 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip) { int ordinal = 0; for (int j = 0; j < tooltip.size() - 3; j++) { -- cgit From 27e9e7b90a76bb662fd7a5f8fe1d7fbec17a8cb9 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Fri, 12 Apr 2024 18:10:12 -0400 Subject: Refactor fancy auction house - Add color and center rarity filter text - Use ItemUtils.getNbtTooltips - Use longs for item prices --- .../hysky/skyblocker/config/SkyblockerConfig.java | 269 +++++++++++---------- .../skyblocker/mixin/accessor/SlotAccessor.java | 2 +- .../skyblock/auction/AuctionBrowserScreen.java | 48 ++-- .../skyblock/auction/AuctionViewScreen.java | 12 +- .../skyblocker/skyblock/auction/EditBidPopup.java | 4 +- .../auction/widgets/CategoryTabWidget.java | 3 - .../skyblock/auction/widgets/RarityWidget.java | 33 ++- .../skyblock/auction/widgets/SliderWidget.java | 1 - .../skyblock/item/ItemRarityBackgrounds.java | 2 +- .../skyblock/item/SkyblockItemRarity.java | 11 +- .../utils/render/gui/AbstractPopupScreen.java | 60 +++++ .../utils/render/gui/BarebonesPopupScreen.java | 56 ----- src/main/resources/skyblocker.mixins.json | 7 +- 13 files changed, 264 insertions(+), 244 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractPopupScreen.java delete mode 100644 src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java (limited to 'src/main/java/de/hysky/skyblocker/skyblock') diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index a8f22bbc..a1e1dadc 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -272,13 +272,6 @@ public class SkyblockerConfig { public Object2ObjectOpenHashMap customAnimatedDyes = new Object2ObjectOpenHashMap<>(); } - public static class FancyAuctionHouse { - @SerialEntry - public boolean enabled = true; - @SerialEntry - public boolean highlightCheapBIN = true; - } - public static class TabHudConf { @SerialEntry public boolean tabHudEnabled = true; @@ -416,138 +409,11 @@ public class SkyblockerConfig { public boolean enableQuiverWarningAfterDungeon = true; } - public static class Hitbox { - @SerialEntry - public boolean oldFarmlandHitbox = false; - - @SerialEntry - public boolean oldLeverHitbox = false; - } - - public static class TitleContainer { - @SerialEntry - public float titleContainerScale = 100; - - @SerialEntry - public int x = 540; - - @SerialEntry - public int y = 10; - - @SerialEntry - public Direction direction = Direction.HORIZONTAL; - - @SerialEntry - public Alignment alignment = Alignment.MIDDLE; - } - - public enum Direction { - HORIZONTAL, VERTICAL; - - @Override - public String toString() { - return switch (this) { - case HORIZONTAL -> "Horizontal"; - case VERTICAL -> "Vertical"; - }; - } - } - - public enum Alignment { - LEFT, RIGHT, MIDDLE; - - @Override - public String toString() { - return switch (this) { - case LEFT -> "Left"; - case RIGHT -> "Right"; - case MIDDLE -> "Middle"; - }; - } - } - - public static class TeleportOverlay { - @SerialEntry - public boolean enableTeleportOverlays = true; - - @SerialEntry - public boolean enableWeirdTransmission = true; - - @SerialEntry - public boolean enableInstantTransmission = true; - - @SerialEntry - public boolean enableEtherTransmission = true; - - @SerialEntry - public boolean enableSinrecallTransmission = true; - - @SerialEntry - public boolean enableWitherImpact = true; - } - - public static class FlameOverlay { - @SerialEntry - public int flameHeight = 100; - - @SerialEntry - public int flameOpacity = 100; - } - - public static class SearchOverlay { - @SerialEntry - public boolean enableBazaar = true; - - @SerialEntry - public boolean enableAuctionHouse = true; - - @SerialEntry - public boolean keepPreviousSearches = false; - - @SerialEntry - public int maxSuggestions = 3; - - @SerialEntry - public int historyLength = 3; - - @SerialEntry - public boolean enableCommands = false; - - @SerialEntry - public List bazaarHistory = new ArrayList<>(); - - @SerialEntry - public List auctionHistory = new ArrayList<>(); - } - - public static class RichPresence { - @SerialEntry - public boolean enableRichPresence = false; - - @SerialEntry - public Info info = Info.LOCATION; - - @SerialEntry - public boolean cycleMode = false; - - @SerialEntry - public String customMessage = "Playing Skyblock"; - } - public static class ItemList { @SerialEntry public boolean enableItemList = true; } - public enum Average { - ONE_DAY, THREE_DAY, BOTH; - - @Override - public String toString() { - return I18n.translate("text.autoconfig.skyblocker.option.general.itemTooltip.avg." + name()); - } - } - public static class ItemTooltip { @SerialEntry public boolean enableNPCPrice = true; @@ -580,6 +446,15 @@ public class SkyblockerConfig { public boolean enableAccessoriesHelper = true; } + public enum Average { + ONE_DAY, THREE_DAY, BOTH; + + @Override + public String toString() { + return I18n.translate("text.autoconfig.skyblocker.option.general.itemTooltip.avg." + name()); + } + } + public static class ItemInfoDisplay { @SerialEntry public boolean attributeShardInfo = true; @@ -661,6 +536,118 @@ public class SkyblockerConfig { public boolean rareDungeonDropEffects = true; } + public static class Hitbox { + @SerialEntry + public boolean oldFarmlandHitbox = false; + + @SerialEntry + public boolean oldLeverHitbox = false; + } + + public static class TitleContainer { + @SerialEntry + public float titleContainerScale = 100; + + @SerialEntry + public int x = 540; + + @SerialEntry + public int y = 10; + + @SerialEntry + public Direction direction = Direction.HORIZONTAL; + + @SerialEntry + public Alignment alignment = Alignment.MIDDLE; + } + + public enum Direction { + HORIZONTAL, VERTICAL; + + @Override + public String toString() { + return switch (this) { + case HORIZONTAL -> "Horizontal"; + case VERTICAL -> "Vertical"; + }; + } + } + + public enum Alignment { + LEFT, RIGHT, MIDDLE; + + @Override + public String toString() { + return switch (this) { + case LEFT -> "Left"; + case RIGHT -> "Right"; + case MIDDLE -> "Middle"; + }; + } + } + + public static class TeleportOverlay { + @SerialEntry + public boolean enableTeleportOverlays = true; + + @SerialEntry + public boolean enableWeirdTransmission = true; + + @SerialEntry + public boolean enableInstantTransmission = true; + + @SerialEntry + public boolean enableEtherTransmission = true; + + @SerialEntry + public boolean enableSinrecallTransmission = true; + + @SerialEntry + public boolean enableWitherImpact = true; + } + + public static class FlameOverlay { + @SerialEntry + public int flameHeight = 100; + + @SerialEntry + public int flameOpacity = 100; + } + + public static class SearchOverlay { + @SerialEntry + public boolean enableBazaar = true; + + @SerialEntry + public boolean enableAuctionHouse = true; + + @SerialEntry + public boolean keepPreviousSearches = false; + + @SerialEntry + public int maxSuggestions = 3; + + @SerialEntry + public int historyLength = 3; + + @SerialEntry + public boolean enableCommands = false; + + @SerialEntry + public List bazaarHistory = new ArrayList<>(); + + @SerialEntry + public List auctionHistory = new ArrayList<>(); + } + + public static class FancyAuctionHouse { + @SerialEntry + public boolean enabled = true; + + @SerialEntry + public boolean highlightCheapBIN = true; + } + public static class Locations { @SerialEntry public Barn barn = new Barn(); @@ -1252,6 +1239,20 @@ public class SkyblockerConfig { public int announcementScale = 3; } + public static class RichPresence { + @SerialEntry + public boolean enableRichPresence = false; + + @SerialEntry + public Info info = Info.LOCATION; + + @SerialEntry + public boolean cycleMode = false; + + @SerialEntry + public String customMessage = "Playing Skyblock"; + } + public enum Info { PURSE, BITS, LOCATION; diff --git a/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java b/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java index b8c5618f..ef11006c 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java +++ b/src/main/java/de/hysky/skyblocker/mixin/accessor/SlotAccessor.java @@ -7,10 +7,10 @@ import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(Slot.class) public interface SlotAccessor { - @Mutable @Accessor("x") void setX(int x); + @Mutable @Accessor("y") void setY(int y); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java index 628c5bd5..d47fef05 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionBrowserScreen.java @@ -9,6 +9,7 @@ import de.hysky.skyblocker.skyblock.auction.widgets.RarityWidget; import de.hysky.skyblocker.skyblock.auction.widgets.SortWidget; import de.hysky.skyblocker.skyblock.item.tooltip.ItemTooltip; import de.hysky.skyblocker.skyblock.item.tooltip.TooltipInfoType; +import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.render.gui.AbstractCustomHypixelGUI; import it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap; import net.minecraft.client.MinecraftClient; @@ -16,7 +17,6 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.item.TooltipContext; import net.minecraft.client.texture.Sprite; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; @@ -30,6 +30,8 @@ import net.minecraft.util.Colors; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import org.lwjgl.glfw.GLFW; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.util.ArrayList; @@ -37,7 +39,8 @@ import java.util.List; import java.util.function.Supplier; public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { - protected static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background.png"); + private static final Logger LOGGER = LoggerFactory.getLogger(AuctionBrowserScreen.class); + private static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background.png"); private static final Identifier SCROLLER_TEXTURE = new Identifier("container/creative_inventory/scroller"); private static final Identifier up_arrow_tex = new Identifier(SkyblockerMod.NAMESPACE, "up_arrow_even"); // Put them in their own fields to avoid object allocation on each frame @@ -129,7 +132,10 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI - sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + sortWidget.setCurrent(SortWidget.Option.get(getOrdinal(ItemUtils.getNbtTooltips(stack)))); case AUCTION_TYPE_BUTTON_SLOT -> - auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(stack.getTooltip(client.player, TooltipContext.BASIC)))); + auctionTypeWidget.setCurrent(AuctionTypeWidget.Option.get(getOrdinal(ItemUtils.getNbtTooltips(stack)))); case RARITY_BUTTON_SLOT -> { - List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); + List tooltip = ItemUtils.getNbtTooltips(stack); int ordinal = getOrdinal(tooltip); - String split = tooltip.get(ordinal + 2).getString().substring(2); + String split = tooltip.get(ordinal + 1).getString().substring(2); rarityWidget.setText(tooltip.subList(1, tooltip.size() - 3), split); } case RESET_BUTTON_SLOT -> { @@ -248,7 +254,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI { - List tooltipSearch = stack.getTooltip(client.player, TooltipContext.BASIC); + List tooltipSearch = ItemUtils.getNbtTooltips(stack); for (Text text : tooltipSearch) { String string = text.getString(); if (string.contains("Filtered:")) { @@ -265,7 +271,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltipDefault = handler.getSlot(slotId).getStack().getTooltip(client.player, TooltipContext.BASIC); + List tooltipDefault = ItemUtils.getNbtTooltips(handler.getSlot(slotId).getStack()); for (int j = tooltipDefault.size() - 1; j >= 0; j--) { String lowerCase = tooltipDefault.get(j).getString().toLowerCase(); if (lowerCase.contains("currently")) { @@ -277,8 +283,8 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI 9 && slotId < (handler.getRows() - 1) * 9 && slotId % 9 > 1 && slotId % 9 < 8) { - List tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); if (!SkyblockerConfigManager.get().general.fancyAuctionHouse.highlightCheapBIN) return; + List tooltip = ItemUtils.getNbtTooltips(stack); for (int k = tooltip.size() - 1; k >= 0; k--) { Text text = tooltip.get(k); String string = text.getString(); @@ -287,7 +293,7 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI parsed); } - } catch (NumberFormatException ignored) { + } catch (Exception e) { + LOGGER.error("[Skyblocker Fancy Auction House] Failed to parse BIN price", e); } } } @@ -324,9 +331,9 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip) { int ordinal = 0; - for (int j = 0; j < tooltip.size() - 3; j++) { - if (j + 2 >= tooltip.size()) break; - if (tooltip.get(j + 2).getString().contains("▶")) { + for (int j = 0; j < tooltip.size() - 4; j++) { + if (j + 1 >= tooltip.size()) break; + if (tooltip.get(j + 1).getString().contains("▶")) { ordinal = j; break; } @@ -341,14 +348,15 @@ public class AuctionBrowserScreen extends AbstractCustomHypixelGUI tooltip = stack.getTooltip(client.player, TooltipContext.BASIC); - String str = tooltip.get(1).getString().trim(); - str = str.substring(1, str.length() - 1); // remove parentheses - String[] parts = str.split("/"); // split the string try { + List tooltip = ItemUtils.getNbtTooltips(stack); + String str = tooltip.get(0).getString().trim(); + str = str.substring(1, str.length() - 1); // remove parentheses + String[] parts = str.split("/"); // split the string currentPage = Integer.parseInt(parts[0].replace(",", "")); // parse current page totalPages = Integer.parseInt(parts[1].replace(",", "")); // parse total - } catch (NumberFormatException ignored) { + } catch (Exception e) { + LOGGER.error("[Skyblocker Fancy Auction House] Failed to parse page arrow", e); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java index a365b799..a8b30a50 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/AuctionViewScreen.java @@ -1,6 +1,7 @@ package de.hysky.skyblocker.skyblock.auction; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.utils.ItemUtils; import de.hysky.skyblocker.utils.render.gui.AbstractCustomHypixelGUI; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.PopupScreen; @@ -8,7 +9,6 @@ import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.DirectionalLayoutWidget; import net.minecraft.client.gui.widget.SimplePositioningWidget; import net.minecraft.client.gui.widget.TextWidget; -import net.minecraft.client.item.TooltipContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; @@ -198,18 +198,18 @@ public class AuctionViewScreen extends AbstractCustomHypixelGUI stringAtomicReference.set(stringAtomicReference.get() + s)); } - //System.out.println("Experiment: " + stringAtomicReference.get()); + if (priceString == null) priceString = stringAtomicReference.get(); if (minBid != null) this.minBid = minBid; else this.minBid = priceString; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java index 86d5c44b..6b90b86c 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/EditBidPopup.java @@ -1,6 +1,6 @@ package de.hysky.skyblocker.skyblock.auction; -import de.hysky.skyblocker.utils.render.gui.BarebonesPopupScreen; +import de.hysky.skyblocker.utils.render.gui.AbstractPopupScreen; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; @@ -11,7 +11,7 @@ import net.minecraft.text.Text; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFW; -public class EditBidPopup extends BarebonesPopupScreen { +public class EditBidPopup extends AbstractPopupScreen { private DirectionalLayoutWidget layout = DirectionalLayoutWidget.vertical(); private final String minimumBid; private final SignBlockEntity signBlockEntity; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java index f200179a..03d91780 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/CategoryTabWidget.java @@ -34,14 +34,11 @@ public class CategoryTabWidget extends ToggleButtonWidget { Identifier identifier = textures.get(true, this.toggled); int x = getX(); if (toggled) x -= 2; - //RenderSystem.disableDepthTest(); context.drawGuiTexture(identifier, x, this.getY(), this.width, this.height); - //RenderSystem.enableDepthTest(); context.drawItem(icon, x + 9, getY() + 5); if (isMouseOver(mouseX, mouseY)) { context.getMatrices().push(); - //context.getMatrices().translate(0, 0, 500f); context.drawTooltip(MinecraftClient.getInstance().textRenderer, icon.getTooltip(MinecraftClient.getInstance().player, TooltipContext.BASIC), mouseX, mouseY); context.getMatrices().pop(); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java index a5bc34a3..b6bd42a9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/RarityWidget.java @@ -2,6 +2,8 @@ package de.hysky.skyblocker.skyblock.auction.widgets; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.skyblock.auction.SlotClickHandler; +import de.hysky.skyblocker.skyblock.item.ItemRarityBackgrounds; +import de.hysky.skyblocker.skyblock.item.SkyblockItemRarity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -9,9 +11,11 @@ import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.widget.ClickableWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import java.util.List; +import java.util.Map; public class RarityWidget extends ClickableWidget { @@ -30,7 +34,6 @@ public class RarityWidget extends ClickableWidget { MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(getX(), getY(), 0); - //context.drawText(parent.getTextRender(), String.valueOf(slotId), 0, -9, Colors.RED, true); boolean onLeftArrow = isOnLeftArrow(mouseX); boolean onRightArrow = isOnRightArrow(mouseX); context.drawTexture(TEXTURE, 0, 0, 0, 0, 48, 11, 48, 11); @@ -40,16 +43,15 @@ public class RarityWidget extends ClickableWidget { // Text TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; int textWidth = textRenderer.getWidth(current); - int color = 0xFFEAEAEA; if (textWidth > 34) { + float scale = 34f / textWidth; matrices.push(); - //matrices.translate(-7-getX(), -5.5f-getY(), 0); - matrices.translate(7, 5.5f, 0); - matrices.scale(34.f / textWidth, 34.f / textWidth, 1.f); - context.drawText(textRenderer, current, 0, -textRenderer.fontHeight / 2, color, false); + matrices.translate(0, 5.5, 0); + matrices.scale(scale, scale, 1); + context.drawCenteredTextWithShadow(textRenderer, current, (int) (24 / scale), -textRenderer.fontHeight / 2, color); matrices.pop(); } else { - context.drawText(textRenderer, current, 7, 2, color, false); + context.drawCenteredTextWithShadow(textRenderer, current, 24, 2, color); } matrices.pop(); @@ -57,11 +59,11 @@ public class RarityWidget extends ClickableWidget { } - private boolean isOnRightArrow(int mouseX) { + private boolean isOnRightArrow(double mouseX) { return isHovered() && mouseX - getX() > 40; } - private boolean isOnLeftArrow(int mouseX) { + private boolean isOnLeftArrow(double mouseX) { return isHovered() && mouseX - getX() < 7; } @@ -76,18 +78,27 @@ public class RarityWidget extends ClickableWidget { private List tooltip = List.of(); private String current = "?"; + private int color = 0xFFEAEAEA; public void setText(List tooltip, String current) { this.tooltip = tooltip; this.current = current; + for (Map.Entry rarity : ItemRarityBackgrounds.LORE_RARITIES.entrySet()) { + if (current.toUpperCase().contains(rarity.getKey())) { + this.color = rarity.getValue().color | 0xFF000000; + return; + } + } + //noinspection DataFlowIssue + this.color = Formatting.GRAY.getColorValue() | 0xFF000000; } @Override public void onClick(double mouseX, double mouseY) { if (slotId == -1) return; - if (isOnLeftArrow((int) mouseX)) { + if (isOnLeftArrow(mouseX)) { onClick.click(slotId, 1); - } else if (isOnRightArrow((int) mouseX)) { + } else if (isOnRightArrow(mouseX)) { onClick.click(slotId, 0); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java index 549980ae..22fa1ad8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/auction/widgets/SliderWidget.java @@ -53,7 +53,6 @@ public class SliderWidget & SliderWidget.OptionInfo> extends C int optionWidth = current.getOptionSize()[0]; int optionHeight = current.getOptionSize()[1]; - //context.drawText(parent.getTextRender(), String.valueOf(slotId), 0, -9, Colors.RED, true); context.drawTexture(current.getBackTexture(), 0, 0, 0, 0, getWidth(), getHeight(), getWidth(), getHeight()); context.drawTexture(current.getOptionTexture(), x, y, 0, 0, optionWidth, optionHeight, optionWidth, optionHeight); if (isHovered()) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java b/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java index c9cdb99a..d4bf3d52 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/ItemRarityBackgrounds.java @@ -26,7 +26,7 @@ import net.minecraft.text.Text; public class ItemRarityBackgrounds { private static final SkyblockerConfig.ItemInfoDisplay CONFIG = SkyblockerConfigManager.get().general.itemInfoDisplay; private static final Supplier SPRITE = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(CONFIG.itemRarityBackgroundStyle.tex); - private static final ImmutableMap LORE_RARITIES = ImmutableMap.ofEntries( + public static final ImmutableMap LORE_RARITIES = ImmutableMap.ofEntries( Map.entry("ADMIN", SkyblockItemRarity.ADMIN), Map.entry("ULTIMATE", SkyblockItemRarity.ULTIMATE), Map.entry("SPECIAL", SkyblockItemRarity.SPECIAL), //Very special is the same color so this will cover it diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockItemRarity.java b/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockItemRarity.java index 4addeac6..60bda976 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockItemRarity.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/SkyblockItemRarity.java @@ -15,16 +15,17 @@ public enum SkyblockItemRarity { UNCOMMON(Formatting.GREEN), COMMON(Formatting.WHITE); + public final int color; public final float r; public final float g; public final float b; SkyblockItemRarity(Formatting formatting) { - @SuppressWarnings("DataFlowIssue") - int rgb = formatting.getColorValue(); + //noinspection DataFlowIssue + this.color = formatting.getColorValue(); - this.r = ((rgb >> 16) & 0xFF) / 255f; - this.g = ((rgb >> 8) & 0xFF) / 255f; - this.b = (rgb & 0xFF) / 255f; + this.r = ((color >> 16) & 0xFF) / 255f; + this.g = ((color >> 8) & 0xFF) / 255f; + this.b = (color & 0xFF) / 255f; } } diff --git a/src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractPopupScreen.java b/src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractPopupScreen.java new file mode 100644 index 00000000..2bd15955 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/utils/render/gui/AbstractPopupScreen.java @@ -0,0 +1,60 @@ +package de.hysky.skyblocker.utils.render.gui; + +import com.mojang.blaze3d.platform.GlConst; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +/** + * A more bare-bones version of Vanilla's Popup Screen. Meant to be extended. + */ +public class AbstractPopupScreen extends Screen { + private static final Identifier BACKGROUND_TEXTURE = new Identifier("popup/background"); + private final Screen backgroundScreen; + + protected AbstractPopupScreen(Text title, Screen backgroundScreen) { + super(title); + this.backgroundScreen = backgroundScreen; + } + + @Override + public void close() { + assert this.client != null; + this.client.setScreen(this.backgroundScreen); + } + + @Override + public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) { + this.backgroundScreen.render(context, -1, -1, delta); + context.draw(); + RenderSystem.clear(GlConst.GL_DEPTH_BUFFER_BIT, MinecraftClient.IS_SYSTEM_MAC); + this.renderInGameBackground(context); + } + + /** + * These are the inner positions and size of the popup, not outer + */ + public static void drawPopupBackground(DrawContext context, int x, int y, int width, int height) { + context.drawGuiTexture(BACKGROUND_TEXTURE, x - 18, y - 18, width + 36, height + 36); + } + + @Override + protected void init() { + super.init(); + initTabNavigation(); + } + + @Override + protected void initTabNavigation() { + this.backgroundScreen.resize(this.client, this.width, this.height); + } + + @Override + public void onDisplayed() { + super.onDisplayed(); + this.backgroundScreen.blur(); + } +} \ No newline at end of file diff --git a/src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java b/src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java deleted file mode 100644 index 56b07966..00000000 --- a/src/main/java/de/hysky/skyblocker/utils/render/gui/BarebonesPopupScreen.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.hysky.skyblocker.utils.render.gui; - -import com.mojang.blaze3d.platform.GlConst; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; - -/** - * A more bare-bones version of Vanilla's Popup Screen. Meant to be extended. - */ -public class BarebonesPopupScreen extends Screen { - private static final Identifier BACKGROUND_TEXTURE = new Identifier("popup/background"); - private final Screen backgroundScreen; - - protected BarebonesPopupScreen(Text title, Screen backgroundScreen) { - super(title); - this.backgroundScreen = backgroundScreen; - } - - @Override - public void close() { - assert this.client != null; - this.client.setScreen(this.backgroundScreen); - } - - @Override - public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) { - this.backgroundScreen.render(context, -1, -1, delta); - context.draw(); - RenderSystem.clear(GlConst.GL_DEPTH_BUFFER_BIT, MinecraftClient.IS_SYSTEM_MAC); - this.renderInGameBackground(context); - } - - /** - * These are the inner positions and size of the popup, not outer - */ - public static void drawPopupBackground(DrawContext context, int x, int y, int width, int height) { - context.drawGuiTexture(BACKGROUND_TEXTURE, x - 18, y - 18, width + 36, height + 36); - } - - @Override - protected void init() { - super.init(); - this.backgroundScreen.resize(this.client, width, height); - - } - - @Override - public void onDisplayed() { - super.onDisplayed(); - this.backgroundScreen.blur(); - } -} \ No newline at end of file diff --git a/src/main/resources/skyblocker.mixins.json b/src/main/resources/skyblocker.mixins.json index 80093a4b..1466d8f2 100644 --- a/src/main/resources/skyblocker.mixins.json +++ b/src/main/resources/skyblocker.mixins.json @@ -47,12 +47,11 @@ "accessor.RecipeBookWidgetAccessor", "accessor.ScreenAccessor", "accessor.SkullBlockEntityAccessor", + "accessor.SlotAccessor", "accessor.WorldRendererAccessor", - "discordipc.ConnectionMixin", - "accessor.SlotAccessor" + "discordipc.ConnectionMixin" ], "injectors": { "defaultRequire": 1 - }, - "mixins": [] + } } -- cgit