From a04c42edcce343b1b19e24b9ef12bc7907a5171b Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:52:38 +0200 Subject: [PATCH 01/10] Add Garden Plots Widget --- .../de/hysky/skyblocker/SkyblockerMod.java | 2 + .../config/categories/FarmingCategory.java | 21 +- .../config/configs/FarmingConfig.java | 6 + .../mixins/InventoryScreenMixin.java | 40 +++ .../skyblock/garden/GardenPlotsWidget.java | 296 ++++++++++++++++++ .../assets/skyblocker/lang/en_us.json | 10 + 6 files changed, 371 insertions(+), 4 deletions(-) create mode 100644 src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 47ad0f41c7..46d652369a 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -34,6 +34,7 @@ import de.hysky.skyblocker.skyblock.events.EventNotifications; import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars; import de.hysky.skyblocker.skyblock.garden.FarmingHud; +import de.hysky.skyblocker.skyblock.garden.GardenPlotsWidget; import de.hysky.skyblocker.skyblock.garden.LowerSensitivity; import de.hysky.skyblocker.skyblock.garden.VisitorHelper; import de.hysky.skyblocker.skyblock.item.*; @@ -216,6 +217,7 @@ public void onInitializeClient() { MobGlow.init(); MayorUtils.init(); SlayerEntitiesGlow.init(); + GardenPlotsWidget.init(); Scheduler.INSTANCE.scheduleCyclic(Utils::update, 20); Scheduler.INSTANCE.scheduleCyclic(DiscordRPCManager::updateDataAndPresence, 200); diff --git a/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java index 90b36c7238..407ff7971a 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/FarmingCategory.java @@ -3,10 +3,7 @@ import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.skyblock.garden.FarmingHudConfigScreen; -import dev.isxander.yacl3.api.ButtonOption; -import dev.isxander.yacl3.api.ConfigCategory; -import dev.isxander.yacl3.api.Option; -import dev.isxander.yacl3.api.OptionGroup; +import dev.isxander.yacl3.api.*; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; @@ -60,6 +57,22 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.farming.garden.lockMouseGroundOnly = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.farming.garden.gardenPlotsWidget")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.gardenPlotsWidget.@Tooltip"))) + .binding(defaults.farming.garden.gardenPlotsWidget, + () -> config.farming.garden.gardenPlotsWidget, + newValue -> config.farming.garden.gardenPlotsWidget = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) + .option(Option.createBuilder() + .name(Text.translatable("skyblocker.config.farming.garden.closeScreenOnPlotClick")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.farming.garden.closeScreenOnPlotClick.@Tooltip"))) + .binding(defaults.farming.garden.closeScreenOnPlotClick, + () -> config.farming.garden.closeScreenOnPlotClick, + newValue -> config.farming.garden.closeScreenOnPlotClick = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) .build(); } diff --git a/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java index b2faf00518..568165a707 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/FarmingConfig.java @@ -22,6 +22,12 @@ public static class Garden { @SerialEntry public boolean lockMouseGroundOnly = false; + + @SerialEntry + public boolean gardenPlotsWidget = true; + + @SerialEntry + public boolean closeScreenOnPlotClick = false; } public static class FarmingHud { diff --git a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java index f5b22c2150..c5711f8740 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java @@ -2,16 +2,30 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.skyblock.garden.GardenPlotsWidget; import de.hysky.skyblocker.skyblock.itemlist.ItemListWidget; +import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.scheduler.MessageScheduler; +import net.minecraft.client.gui.screen.ButtonTextures; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.TexturedButtonWidget; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.screen.PlayerScreenHandler; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(InventoryScreen.class) public abstract class InventoryScreenMixin { + @ModifyExpressionValue(method = "", at = @At(value = "NEW", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;")) private RecipeBookWidget skyblocker$replaceRecipeBook(RecipeBookWidget original) { return SkyblockerConfigManager.get().general.itemList.enableItemList && Utils.isOnSkyblock() ? new ItemListWidget() : original; @@ -26,4 +40,30 @@ public abstract class InventoryScreenMixin { private int skyblocker$moveButtonWhenPressed(int x) { return Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.showEquipmentInInventory ? x + 21 : x; } + + + @Unique + private GardenPlotsWidget gardenPlotsWidget; + @Unique + private ButtonWidget deskButton; + + @Inject(method = "method_19891", at = @At("TAIL")) + private void skyblocker$moveGardenPlotsWdiget(CallbackInfo ci) { + if (Utils.getLocation().equals(Location.GARDEN) && gardenPlotsWidget != null) { + gardenPlotsWidget.setPosition(x + backgroundWidth + 4, y); + if (deskButton != null) deskButton.setPosition(gardenPlotsWidget.getX() + 4, y + 108); + } + } + + @Inject(method = "init", at = @At("TAIL")) + private void skyblocker$addGardenPlotsWidget(CallbackInfo ci) { + if (Utils.getLocation().equals(Location.GARDEN) && SkyblockerConfigManager.get().farming.garden.gardenPlotsWidget) { + gardenPlotsWidget = new GardenPlotsWidget(x + backgroundWidth + 4, y); + addDrawableChild(gardenPlotsWidget); + deskButton = ButtonWidget.builder(Text.translatable("skyblocker.gardenPlots.openDesk"), button -> MessageScheduler.INSTANCE.sendMessageAfterCooldown("/desk")) + .dimensions(gardenPlotsWidget.getX() + 7, y + 108, 60, 15) + .build(); + addDrawableChild(deskButton); + } + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java new file mode 100644 index 0000000000..7882a188aa --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -0,0 +1,296 @@ +package de.hysky.skyblocker.skyblock.garden; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.mojang.serialization.JsonOps; +import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.events.SkyblockEvents; +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; +import de.hysky.skyblocker.utils.Utils; +import de.hysky.skyblocker.utils.scheduler.MessageScheduler; +import it.unimi.dsi.fastutil.ints.*; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; +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.component.DataComponentTypes; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.screen.GenericContainerScreenHandler; +import net.minecraft.screen.slot.Slot; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import net.minecraft.util.Identifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +public class GardenPlotsWidget extends ClickableWidget { + + private static final Logger LOGGER = LoggerFactory.getLogger("Garden Plots"); + private static final Path FOLDER = SkyblockerMod.CONFIG_DIR.resolve("garden_plots"); + + ////////////////////////// + // STATIC SHENANIGANS + ////////////////////////// + + public static final Int2IntMap GARDEN_PLOT_TO_SLOT = Int2IntMaps.unmodifiable(new Int2IntOpenHashMap(Map.ofEntries( + Map.entry(1, 7), + Map.entry(2, 11), + Map.entry(3, 13), + Map.entry(4, 17), + Map.entry(5, 6), + Map.entry(6, 8), + Map.entry(7, 16), + Map.entry(8, 18), + Map.entry(9, 2), + Map.entry(10, 10), + Map.entry(11, 14), + Map.entry(12, 22), + Map.entry(13, 1), + Map.entry(14, 3), + Map.entry(15, 5), + Map.entry(16, 9), + Map.entry(17, 15), + Map.entry(18, 19), + Map.entry(19, 21), + Map.entry(20, 23), + Map.entry(21, 0), + Map.entry(22, 4), + Map.entry(23, 20), + Map.entry(24, 24) + ))); + + private static final GardenPlot[] gardenPlots = new GardenPlot[25]; + + public static void init() { + ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> { + if (screen instanceof GenericContainerScreen containerScreen && screen.getTitle().getString().trim().equals("Configure Plots")) { + ScreenEvents.remove(screen).register(ignored -> { + GenericContainerScreenHandler screenHandler = containerScreen.getScreenHandler(); + // Take plot icons and names + for (int i = 2; i < 43; i += (i % 9 == 6 ? 5 : 1)) { + if (i == 22) continue; // Barn icon + Slot slot = screenHandler.slots.get(i); + ItemStack stack = slot.getStack(); + if (stack.isEmpty() || stack.isOf(Items.RED_STAINED_GLASS_PANE) || stack.isOf(Items.OAK_BUTTON) || stack.isOf(Items.BLACK_STAINED_GLASS_PANE)) + continue; + gardenPlots[(i / 9) * 5 + (i % 9 - 2)] = new GardenPlot(stack.getItem(), stack.getName().getString().split("-", 2)[1].trim()); + } + + }); + } + }); + + SkyblockEvents.PROFILE_CHANGE.register(((prevProfileId, profileId) -> { + if (!prevProfileId.isEmpty()) + CompletableFuture.runAsync(() -> save(prevProfileId)).thenRun(() -> load(profileId)); + else load(profileId); + })); + + ClientLifecycleEvents.CLIENT_STOPPING.register(client1 -> { + String profileId = Utils.getProfileId(); + if (!profileId.isBlank()) { + CompletableFuture.runAsync(() -> save(profileId)); + } + }); + } + + private static void save(String profileId) { + try { + Files.createDirectories(FOLDER); + } catch (IOException e) { + LOGGER.error("[Skyblocker] Failed to create folder for garden plots!", e); + } + Path resolve = FOLDER.resolve(profileId + ".json"); + + try (BufferedWriter writer = Files.newBufferedWriter(resolve)) { + JsonArray elements = new JsonArray(); + Arrays.stream(gardenPlots).map(gardenPlot -> { + if (gardenPlot == null) return null; + JsonObject jsonObject = new JsonObject(); + jsonObject.add("icon", ItemStack.ITEM_CODEC.encodeStart(JsonOps.INSTANCE, gardenPlot.item.getRegistryEntry()).getOrThrow()); + jsonObject.addProperty("name", gardenPlot.name); + return jsonObject; + }).forEach(elements::add); + + SkyblockerMod.GSON.toJson(elements, writer); + } catch (Exception e) { + LOGGER.error("[Skyblocker] Failed to save Garden Plots data", e); + } + } + + private static void load(String profileId) { + Path resolve = FOLDER.resolve(profileId + ".json"); + CompletableFuture.supplyAsync(() -> { + try (BufferedReader reader = Files.newBufferedReader(resolve)) { + return SkyblockerMod.GSON.fromJson(reader, JsonArray.class).asList().stream().map(jsonElement -> { + if (jsonElement == null || jsonElement.isJsonNull()) return null; + JsonObject jsonObject = jsonElement.getAsJsonObject(); + return new GardenPlot(ItemStack.ITEM_CODEC.decode(JsonOps.INSTANCE, jsonObject.get("icon")).getOrThrow().getFirst().value(), jsonObject.get("name").getAsString()); + } + ).toArray(GardenPlot[]::new); + } catch (NoSuchFileException ignored) { + } catch (Exception e) { + LOGGER.error("[Skyblocker] Failed to load Equipment data", e); + } + return new GardenPlot[25]; + // Schedule on main thread to avoid any async weirdness + }).thenAccept(newPlots -> MinecraftClient.getInstance().execute(() -> System.arraycopy(newPlots, 0, gardenPlots, 0, Math.min(newPlots.length, 25)))); + } + + ///////////////////////////// + // THE WIDGET ITSELF + ///////////////////////////// + + private static final Identifier BACKGROUND_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/garden_plots.png"); + private static final MutableText GROSS_PEST_TEXT = Text.translatable("skyblocker.gardenPlots.pests").formatted(Formatting.RED, Formatting.BOLD); + private static final MutableText TP_TEXT = Text.translatable("skyblocker.gardenPlots.tp").formatted(Formatting.YELLOW, Formatting.BOLD); + + private final ItemStack[] items; + private int hoveredSlot = -1; + private long updateFromTabTime = System.currentTimeMillis(); + private final IntList infectedPlots = new IntArrayList(8); + + public GardenPlotsWidget(int x, int y) { + super(x, y, 104, 127, Text.translatable("skyblocker.gardenPlots")); + items = Arrays.stream(gardenPlots).map(gardenPlot -> { + if (gardenPlot == null) return null; + ItemStack itemStack = new ItemStack(gardenPlot.item()); + itemStack.set(DataComponentTypes.ITEM_NAME, Text.literal(gardenPlot.name()).formatted(Formatting.GREEN, Formatting.BOLD)); + return itemStack; + }).toArray(ItemStack[]::new); + items[12] = new ItemStack(Items.LODESTONE); + items[12].set(DataComponentTypes.ITEM_NAME, Text.literal("The Barn")); + updateInfestedFromTab(); + } + + @Override + protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.translate(getX(), getY(), 0); + + context.drawTexture(BACKGROUND_TEXTURE, 0, 0, 0, 0, getWidth(), getHeight(), getWidth(), getHeight()); + + context.drawText(textRenderer, getMessage(), 8, 6, 4210752, false); + + hoveredSlot = -1; + long timeMillis = System.currentTimeMillis(); + for (int i = 0; i < items.length; i++) { + ItemStack item = items[i]; + if (item == null) continue; + + + int slotX = 7 + (i % 5) * 18; + int slotY = 17 + (i / 5) * 18; + boolean hovered = slotX + getX() <= mouseX && mouseX < slotX + getX() + 18 && slotY + getY() <= mouseY && mouseY < slotY + getY() + 18; + + if (hovered) { + context.fill(slotX + 1, slotY + 1, slotX + 17, slotY + 17, 0xAA_FF_FF_FF); + matrices.push(); + matrices.translate(slotX - 1, slotY - 1, 100.f); + matrices.scale(1.125f, 1.125f, 1.125f); + context.drawItem(item, 0, 0); + matrices.pop(); + hoveredSlot = i; + } else + context.drawItem(item, slotX + 1, slotY + 1); + + boolean infested = infectedPlots.contains(i); + if (infested && (timeMillis & 512) != 0) { + context.drawBorder(slotX + 1, slotY + 1, 16, 16, 0xFF_FF0000); + } + + // tooltip + if (hovered) { + List tooltip = infested ? + List.of( + Text.translatable("skyblocker.gardenPlots.plot", item.getName()), + GROSS_PEST_TEXT, + Text.empty(), + TP_TEXT) : + + i == 12 ? + List.of( + item.getName(), + Text.empty(), + TP_TEXT) : + + List.of( + Text.translatable("skyblocker.gardenPlots.plot", item.getName()), + Text.empty(), + TP_TEXT + ); + context.drawTooltip(textRenderer, tooltip, mouseX - getX(), mouseY - getY()); + } + } + + matrices.pop(); + + + if (timeMillis - updateFromTabTime > 3000) { + updateFromTabTime = timeMillis; + updateInfestedFromTab(); + } + } + + private void updateInfestedFromTab() { + infectedPlots.clear(); + for (int i = 0; i < PlayerListMgr.getSize(); i++) { + Text displayName = PlayerListMgr.getRaw(i).getDisplayName(); + if (displayName == null) continue; + String string = displayName.getString(); + if (string.startsWith(" Plots:")) { + String[] split = string.split(":")[1].split(","); + for (String s : split) { + try { + infectedPlots.add(GARDEN_PLOT_TO_SLOT.getOrDefault(Integer.parseInt(s.strip()), -1)); + } catch (NumberFormatException ignored) {} + } + break; + } + } + } + + @Override + public void onClick(double mouseX, double mouseY) { + super.onClick(mouseX, mouseY); + if (hoveredSlot == -1) return; + if (hoveredSlot == 12) MessageScheduler.INSTANCE.sendMessageAfterCooldown("/warp garden"); + else MessageScheduler.INSTANCE.sendMessageAfterCooldown("/plottp " + gardenPlots[hoveredSlot].name); + if (SkyblockerConfigManager.get().farming.garden.closeScreenOnPlotClick && MinecraftClient.getInstance().currentScreen != null) + MinecraftClient.getInstance().currentScreen.close(); + } + + @Override + protected boolean isValidClickButton(int button) { + return super.isValidClickButton(button) && hoveredSlot != -1; + } + + @Override + protected void appendClickableNarrations(NarrationMessageBuilder builder) { + } + + private record GardenPlot(Item item, String name) { + } +} diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index b0537af03d..7dc790a1c9 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -210,9 +210,13 @@ "skyblocker.config.farming": "Farming", "skyblocker.config.farming.garden": "Garden", + "skyblocker.config.farming.garden.closeScreenOnPlotClick": "Close inventory on plot tp", + "skyblocker.config.farming.garden.closeScreenOnPlotClick.@Tooltip": "Whether or not your inventory should automatically close when teleporting to a plot using the Garden Plots Widget", "skyblocker.config.farming.garden.dicerTitlePrevent": "Enable Dicer Title Prevent", "skyblocker.config.farming.garden.enableHud": "Enable Farming HUD", "skyblocker.config.farming.garden.farmingHud": "Farming HUD Config...", + "skyblocker.config.farming.garden.gardenPlotsWidget": "Enable Garden Plots Widget", + "skyblocker.config.farming.garden.gardenPlotsWidget.@Tooltip": "While in the garden, in your on the right of your inventory there will be a widget to quickly teleport to plots. It will also show plots that have pests.", "skyblocker.config.farming.garden.lockMouseGround": "Only lock camera when on the ground", "skyblocker.config.farming.garden.lockMouseTool": "Lock camera when holding a farming tool", "skyblocker.config.farming.garden.visitorHelper": "Visitor helper", @@ -1061,6 +1065,12 @@ "skyblocker.fancyAuctionHouse.yourAuction": "This is your auction!", "skyblocker.fancyAuctionHouse.youPay": "You pay: %s", + "skyblocker.gardenPlots": "Garden Plots", + "skyblocker.gardenPlots.openDesk": "Open Desk", + "skyblocker.gardenPlots.pests": "GROSS! This plot has pests!", + "skyblocker.gardenPlots.plot": "Plot - %s", + "skyblocker.gardenPlots.tp": "Click to TP to it!", + "skyblocker.crimson.dojo": "Dojo", "skyblocker.crimson.dojo.forceHelper": "Enable Force Helper", "skyblocker.crimson.dojo.forceHelper.@Tooltip": "Shows timer showing how long until a zombie despawns and outlines negative zombies.", From af980fa915839543f9a56b0573cb3bcce423a7a9 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:58:23 +0200 Subject: [PATCH 02/10] small fix --- .../de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java index 7882a188aa..53bd6805ef 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -208,7 +208,7 @@ protected void renderWidget(DrawContext context, int mouseX, int mouseY, float d if (hovered) { context.fill(slotX + 1, slotY + 1, slotX + 17, slotY + 17, 0xAA_FF_FF_FF); matrices.push(); - matrices.translate(slotX - 1, slotY - 1, 100.f); + matrices.translate(slotX, slotY, 100.f); matrices.scale(1.125f, 1.125f, 1.125f); context.drawItem(item, 0, 0); matrices.pop(); From c01b50d5f3f51339e9c6e0263404f4929e77fce1 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:09:37 +0200 Subject: [PATCH 03/10] make for loop more boring --- .../de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java index 53bd6805ef..db122a2b3b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -87,7 +87,7 @@ public static void init() { ScreenEvents.remove(screen).register(ignored -> { GenericContainerScreenHandler screenHandler = containerScreen.getScreenHandler(); // Take plot icons and names - for (int i = 2; i < 43; i += (i % 9 == 6 ? 5 : 1)) { + for (int row = 0; row < 5; row++) for (int i = row * 9 + 2; i < row * 9 + 7; i++) { if (i == 22) continue; // Barn icon Slot slot = screenHandler.slots.get(i); ItemStack stack = slot.getStack(); From 29ee5bbcec6a415d6aafaaef4b43b014cedee338 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Thu, 15 Aug 2024 22:14:39 +0200 Subject: [PATCH 04/10] exclusion zones --- .../compatibility/emi/SkyblockerEMIPlugin.java | 11 +++++++++++ .../rei/SkyblockerREIClientPlugin.java | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/main/java/de/hysky/skyblocker/compatibility/emi/SkyblockerEMIPlugin.java b/src/main/java/de/hysky/skyblocker/compatibility/emi/SkyblockerEMIPlugin.java index 9d5a2a46c0..d8d2d28c47 100644 --- a/src/main/java/de/hysky/skyblocker/compatibility/emi/SkyblockerEMIPlugin.java +++ b/src/main/java/de/hysky/skyblocker/compatibility/emi/SkyblockerEMIPlugin.java @@ -1,14 +1,20 @@ package de.hysky.skyblocker.compatibility.emi; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; import de.hysky.skyblocker.utils.ItemUtils; +import de.hysky.skyblocker.utils.Location; +import de.hysky.skyblocker.utils.Utils; import dev.emi.emi.api.EmiPlugin; import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.recipe.EmiRecipeCategory; import dev.emi.emi.api.render.EmiTexture; import dev.emi.emi.api.stack.Comparison; import dev.emi.emi.api.stack.EmiStack; +import dev.emi.emi.api.widget.Bounds; +import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.item.Items; import net.minecraft.util.Identifier; @@ -29,5 +35,10 @@ public void register(EmiRegistry registry) { registry.addCategory(SKYBLOCK); registry.addWorkstation(SKYBLOCK, EmiStack.of(Items.CRAFTING_TABLE)); ItemRepository.getRecipesStream().map(SkyblockEmiRecipe::new).forEach(registry::addRecipe); + registry.addExclusionArea(InventoryScreen.class, (screen, consumer) -> { + if (!SkyblockerConfigManager.get().farming.garden.gardenPlotsWidget || !Utils.getLocation().equals(Location.GARDEN)) return; + HandledScreenAccessor accessor = (HandledScreenAccessor) screen; + consumer.accept(new Bounds(accessor.getX() + accessor.getBackgroundWidth() + 4, accessor.getY(), 104, 127)); + }); } } diff --git a/src/main/java/de/hysky/skyblocker/compatibility/rei/SkyblockerREIClientPlugin.java b/src/main/java/de/hysky/skyblocker/compatibility/rei/SkyblockerREIClientPlugin.java index 7ed322a061..dccc3b7800 100644 --- a/src/main/java/de/hysky/skyblocker/compatibility/rei/SkyblockerREIClientPlugin.java +++ b/src/main/java/de/hysky/skyblocker/compatibility/rei/SkyblockerREIClientPlugin.java @@ -1,15 +1,24 @@ package de.hysky.skyblocker.compatibility.rei; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; +import de.hysky.skyblocker.utils.Location; +import de.hysky.skyblocker.utils.Utils; +import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.item.Items; +import java.util.List; + /** * REI integration */ @@ -31,4 +40,13 @@ public void registerDisplays(DisplayRegistry displayRegistry) { public void registerEntries(EntryRegistry entryRegistry) { entryRegistry.addEntries(ItemRepository.getItemsStream().map(EntryStacks::of).toList()); } + + @Override + public void registerExclusionZones(ExclusionZones zones) { + zones.register(InventoryScreen.class, screen -> { + if (!SkyblockerConfigManager.get().farming.garden.gardenPlotsWidget || !Utils.getLocation().equals(Location.GARDEN)) return List.of(); + HandledScreenAccessor accessor = (HandledScreenAccessor) screen; + return List.of(new Rectangle(accessor.getX() + accessor.getBackgroundWidth() + 4, accessor.getY(), 104, 127)); + }); + } } From 4e4c9cc42106cca66a639c557ec6698e95761174 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:20:36 +0200 Subject: [PATCH 05/10] rebase oopsie daisy and JEI exclusion zone --- .../jei/SkyblockerJEIPlugin.java | 24 +++++++++++++++++++ .../mixins/InventoryScreenMixin.java | 8 ++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/compatibility/jei/SkyblockerJEIPlugin.java b/src/main/java/de/hysky/skyblocker/compatibility/jei/SkyblockerJEIPlugin.java index a1e57682af..0fd4219d0c 100644 --- a/src/main/java/de/hysky/skyblocker/compatibility/jei/SkyblockerJEIPlugin.java +++ b/src/main/java/de/hysky/skyblocker/compatibility/jei/SkyblockerJEIPlugin.java @@ -1,23 +1,33 @@ package de.hysky.skyblocker.compatibility.jei; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; +import de.hysky.skyblocker.utils.Location; +import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.datafixer.ItemStackComponentizationFixer; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.handlers.IGuiContainerHandler; +import mezz.jei.api.registration.IGuiHandlerRegistration; import mezz.jei.api.registration.IRecipeCategoryRegistration; import mezz.jei.api.registration.IRecipeRegistration; import mezz.jei.api.registration.ISubtypeRegistration; import mezz.jei.library.ingredients.subtypes.SubtypeInterpreters; import mezz.jei.library.load.registration.SubtypeRegistration; import mezz.jei.library.plugins.vanilla.crafting.CraftingCategoryExtension; +import net.minecraft.client.gui.screen.ingame.InventoryScreen; +import net.minecraft.client.util.math.Rect2i; import net.minecraft.item.ItemStack; import net.minecraft.recipe.*; import net.minecraft.recipe.book.CraftingRecipeCategory; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; +import java.util.Collections; +import java.util.List; import java.util.Map; @JeiPlugin @@ -45,6 +55,11 @@ public void registerCategories(@NotNull IRecipeCategoryRegistration registration registration.addRecipeCategories(skyblockCraftingRecipeCategory); } + @Override + public void registerGuiHandlers(@NotNull IGuiHandlerRegistration registration) { + registration.addGuiContainerHandler(InventoryScreen.class, new InventoryContainerHandler()); + } + @Override public void registerRecipes(@NotNull IRecipeRegistration registration) { registration.getIngredientManager().addIngredientsAtRuntime(VanillaTypes.ITEM_STACK, ItemRepository.getItems()); @@ -62,4 +77,13 @@ public void registerRecipes(@NotNull IRecipeRegistration registration) { ), "abc", "def", "ghi"), recipe.getResult())) ).toList()); } + + private static class InventoryContainerHandler implements IGuiContainerHandler { + @Override + public @NotNull List getGuiExtraAreas(@NotNull InventoryScreen containerScreen) { + if (!SkyblockerConfigManager.get().farming.garden.gardenPlotsWidget || !Utils.getLocation().equals(Location.GARDEN)) return List.of(); + HandledScreenAccessor accessor = (HandledScreenAccessor) containerScreen; + return Collections.singletonList(new Rect2i(accessor.getX() + accessor.getBackgroundWidth() + 4, accessor.getY(), 104, 127)); + } + } } diff --git a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java index c5711f8740..b8588c079f 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java @@ -7,12 +7,10 @@ import de.hysky.skyblocker.utils.Location; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; -import net.minecraft.client.gui.screen.ButtonTextures; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.gui.widget.TexturedButtonWidget; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.text.Text; @@ -24,7 +22,11 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(InventoryScreen.class) -public abstract class InventoryScreenMixin { +public abstract class InventoryScreenMixin extends HandledScreen { + + public InventoryScreenMixin(PlayerScreenHandler handler, PlayerInventory inventory, Text title) { + super(handler, inventory, title); + } @ModifyExpressionValue(method = "", at = @At(value = "NEW", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;")) private RecipeBookWidget skyblocker$replaceRecipeBook(RecipeBookWidget original) { From 9aac381362c5eeb9246ef317dfba55129c67f617 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Fri, 23 Aug 2024 19:48:02 +0200 Subject: [PATCH 06/10] ctrl+shift+up arrow --- .../hysky/skyblocker/mixins/InventoryScreenMixin.java | 11 +++++------ .../skyblocker/skyblock/garden/GardenPlotsWidget.java | 6 ++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java index b8588c079f..9de4d6b5c6 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java @@ -24,6 +24,11 @@ @Mixin(InventoryScreen.class) public abstract class InventoryScreenMixin extends HandledScreen { + @Unique + private GardenPlotsWidget gardenPlotsWidget; + @Unique + private ButtonWidget deskButton; + public InventoryScreenMixin(PlayerScreenHandler handler, PlayerInventory inventory, Text title) { super(handler, inventory, title); } @@ -43,12 +48,6 @@ public InventoryScreenMixin(PlayerScreenHandler handler, PlayerInventory invento return Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.showEquipmentInInventory ? x + 21 : x; } - - @Unique - private GardenPlotsWidget gardenPlotsWidget; - @Unique - private ButtonWidget deskButton; - @Inject(method = "method_19891", at = @At("TAIL")) private void skyblocker$moveGardenPlotsWdiget(CallbackInfo ci) { if (Utils.getLocation().equals(Location.GARDEN) && gardenPlotsWidget != null) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java index db122a2b3b..3f54e7e230 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -276,10 +276,12 @@ private void updateInfestedFromTab() { public void onClick(double mouseX, double mouseY) { super.onClick(mouseX, mouseY); if (hoveredSlot == -1) return; - if (hoveredSlot == 12) MessageScheduler.INSTANCE.sendMessageAfterCooldown("/warp garden"); - else MessageScheduler.INSTANCE.sendMessageAfterCooldown("/plottp " + gardenPlots[hoveredSlot].name); + if (SkyblockerConfigManager.get().farming.garden.closeScreenOnPlotClick && MinecraftClient.getInstance().currentScreen != null) MinecraftClient.getInstance().currentScreen.close(); + + if (hoveredSlot == 12) MessageScheduler.INSTANCE.sendMessageAfterCooldown("/warp garden"); + else MessageScheduler.INSTANCE.sendMessageAfterCooldown("/plottp " + gardenPlots[hoveredSlot].name); } @Override From c8dc5d2ad32382da15544aab0067df40ef1c8d4e Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:18:38 -0400 Subject: [PATCH 07/10] Fix init merge conflicts --- src/main/java/de/hysky/skyblocker/SkyblockerMod.java | 2 -- .../skyblocker/skyblock/garden/GardenPlotsWidget.java | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java index 46d652369a..47ad0f41c7 100644 --- a/src/main/java/de/hysky/skyblocker/SkyblockerMod.java +++ b/src/main/java/de/hysky/skyblocker/SkyblockerMod.java @@ -34,7 +34,6 @@ import de.hysky.skyblocker.skyblock.events.EventNotifications; import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars; import de.hysky.skyblocker.skyblock.garden.FarmingHud; -import de.hysky.skyblocker.skyblock.garden.GardenPlotsWidget; import de.hysky.skyblocker.skyblock.garden.LowerSensitivity; import de.hysky.skyblocker.skyblock.garden.VisitorHelper; import de.hysky.skyblocker.skyblock.item.*; @@ -217,7 +216,6 @@ public void onInitializeClient() { MobGlow.init(); MayorUtils.init(); SlayerEntitiesGlow.init(); - GardenPlotsWidget.init(); Scheduler.INSTANCE.scheduleCyclic(Utils::update, 20); Scheduler.INSTANCE.scheduleCyclic(DiscordRPCManager::updateDataAndPresence, 200); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java index 3f54e7e230..370f993203 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -4,6 +4,7 @@ import com.google.gson.JsonObject; import com.mojang.serialization.JsonOps; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.annotations.Init; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.events.SkyblockEvents; import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; @@ -81,6 +82,7 @@ public class GardenPlotsWidget extends ClickableWidget { private static final GardenPlot[] gardenPlots = new GardenPlot[25]; + @Init public static void init() { ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> { if (screen instanceof GenericContainerScreen containerScreen && screen.getTitle().getString().trim().equals("Configure Plots")) { @@ -257,10 +259,8 @@ protected void renderWidget(DrawContext context, int mouseX, int mouseY, float d private void updateInfestedFromTab() { infectedPlots.clear(); for (int i = 0; i < PlayerListMgr.getSize(); i++) { - Text displayName = PlayerListMgr.getRaw(i).getDisplayName(); - if (displayName == null) continue; - String string = displayName.getString(); - if (string.startsWith(" Plots:")) { + String string = PlayerListMgr.getPlayerStringList().get(i); + if (string.startsWith("Plots:")) { String[] split = string.split(":")[1].split(","); for (String s : split) { try { From 38456018df7e6101ea99717cdeddcb125da8f443 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:06:42 +0100 Subject: [PATCH 08/10] merge and port --- .../skyblocker/skyblock/garden/GardenPlotsWidget.java | 7 ++++--- src/main/resources/assets/skyblocker/lang/en_us.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java index 370f993203..54b1cf45a7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -19,6 +19,7 @@ import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.widget.ClickableWidget; +import net.minecraft.client.render.RenderLayer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.component.DataComponentTypes; import net.minecraft.item.Item; @@ -129,7 +130,7 @@ private static void save(String profileId) { Arrays.stream(gardenPlots).map(gardenPlot -> { if (gardenPlot == null) return null; JsonObject jsonObject = new JsonObject(); - jsonObject.add("icon", ItemStack.ITEM_CODEC.encodeStart(JsonOps.INSTANCE, gardenPlot.item.getRegistryEntry()).getOrThrow()); + jsonObject.add("icon", Item.ENTRY_CODEC.encodeStart(JsonOps.INSTANCE, gardenPlot.item.getRegistryEntry()).getOrThrow()); jsonObject.addProperty("name", gardenPlot.name); return jsonObject; }).forEach(elements::add); @@ -147,7 +148,7 @@ private static void load(String profileId) { return SkyblockerMod.GSON.fromJson(reader, JsonArray.class).asList().stream().map(jsonElement -> { if (jsonElement == null || jsonElement.isJsonNull()) return null; JsonObject jsonObject = jsonElement.getAsJsonObject(); - return new GardenPlot(ItemStack.ITEM_CODEC.decode(JsonOps.INSTANCE, jsonObject.get("icon")).getOrThrow().getFirst().value(), jsonObject.get("name").getAsString()); + return new GardenPlot(Item.ENTRY_CODEC.decode(JsonOps.INSTANCE, jsonObject.get("icon")).getOrThrow().getFirst().value(), jsonObject.get("name").getAsString()); } ).toArray(GardenPlot[]::new); } catch (NoSuchFileException ignored) { @@ -192,7 +193,7 @@ protected void renderWidget(DrawContext context, int mouseX, int mouseY, float d matrices.push(); matrices.translate(getX(), getY(), 0); - context.drawTexture(BACKGROUND_TEXTURE, 0, 0, 0, 0, getWidth(), getHeight(), getWidth(), getHeight()); + context.drawTexture(RenderLayer::getGuiTextured, BACKGROUND_TEXTURE, 0, 0, 0, 0, getWidth(), getHeight(), getWidth(), getHeight()); context.drawText(textRenderer, getMessage(), 8, 6, 4210752, false); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 43c80db851..0ad0f6ea69 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -236,7 +236,7 @@ "skyblocker.config.farming.garden.enableHud": "Enable Farming HUD", "skyblocker.config.farming.garden.farmingHud": "Farming HUD Config...", "skyblocker.config.farming.garden.gardenPlotsWidget": "Enable Garden Plots Widget", - "skyblocker.config.farming.garden.gardenPlotsWidget.@Tooltip": "While in the garden, in your on the right of your inventory there will be a widget to quickly teleport to plots. It will also show plots that have pests.", + "skyblocker.config.farming.garden.gardenPlotsWidget.@Tooltip": "While in the garden, on the right of your inventory there will be a widget to quickly teleport to plots. It will also show plots that have pests (this requires the Pests widget to be enabled and visible in the Tab).", "skyblocker.config.farming.garden.lockMouseGround": "Only lock camera when on the ground", "skyblocker.config.farming.garden.lockMouseTool": "Lock camera when holding a farming tool", "skyblocker.config.farming.garden.visitorHelper": "Visitor helper", From a8b776a79af243dba6842be45b409d670f50c997 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Sun, 22 Dec 2024 12:13:28 +0100 Subject: [PATCH 09/10] 1.21.4 --- .../skyblocker/mixins/InventoryScreenMixin.java | 12 +++++++----- .../skyblock/garden/GardenPlotsWidget.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java index 03aad1b2d8..b35d79b2bd 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/InventoryScreenMixin.java @@ -74,11 +74,13 @@ public InventoryScreenMixin(PlayerScreenHandler handler, PlayerInventory invento private void skyblocker$addGardenPlotsWidget(CallbackInfo ci) { if (Utils.getLocation().equals(Location.GARDEN) && SkyblockerConfigManager.get().farming.garden.gardenPlotsWidget) { gardenPlotsWidget = new GardenPlotsWidget(x + backgroundWidth + 4, y); - addDrawableChild(gardenPlotsWidget); - deskButton = ButtonWidget.builder(Text.translatable("skyblocker.gardenPlots.openDesk"), button -> MessageScheduler.INSTANCE.sendMessageAfterCooldown("/desk")) - .dimensions(gardenPlotsWidget.getX() + 7, y + 108, 60, 15) - .build(); - addDrawableChild(deskButton); + deskButton = ButtonWidget.builder(Text.translatable("skyblocker.gardenPlots.openDesk"), button -> MessageScheduler.INSTANCE.sendMessageAfterCooldown("/desk")) + .dimensions(gardenPlotsWidget.getX() + 7, y + 108, 60, 15) + .build(); + // make desk button get selected before the widget but render after the widget + addSelectableChild(deskButton); + addDrawableChild(gardenPlotsWidget); + addDrawable(deskButton); } } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java index 54b1cf45a7..4e4af42bb9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/garden/GardenPlotsWidget.java @@ -259,7 +259,7 @@ protected void renderWidget(DrawContext context, int mouseX, int mouseY, float d private void updateInfestedFromTab() { infectedPlots.clear(); - for (int i = 0; i < PlayerListMgr.getSize(); i++) { + for (int i = 0; i < PlayerListMgr.getPlayerStringList().size(); i++) { String string = PlayerListMgr.getPlayerStringList().get(i); if (string.startsWith("Plots:")) { String[] split = string.split(":")[1].split(","); From 53e4fa101e6ffa0ca0045c7dc8179bbd233828a4 Mon Sep 17 00:00:00 2001 From: viciscat <51047087+viciscat@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:39:28 +0100 Subject: [PATCH 10/10] forgot the texture lmao --- .../skyblocker/textures/gui/garden_plots.png | Bin 0 -> 361 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/assets/skyblocker/textures/gui/garden_plots.png diff --git a/src/main/resources/assets/skyblocker/textures/gui/garden_plots.png b/src/main/resources/assets/skyblocker/textures/gui/garden_plots.png new file mode 100644 index 0000000000000000000000000000000000000000..b7d86023492edbbb106391737bc6b7d22219a4bc GIT binary patch literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^89-dm!3-o#1j{!7DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheq5(c3u0Z<#|NqC19SaQ&H8(f!?(PPPq;8%r4W!shg8YJkvOvHf<<0B{ z6yhxKh%9Dc;5!Jyj5{V~zXb}O@^ok+vwz8 zX^z>#H%#<$($?A)AH5Y8AD8~d`}SWu#>3cD!h#yA}lxI`*#6hv*3Ar8q7?y7#Ytt zB%N+KJ7qcZsfLC$2M6N?H;fXEpT2A`Qdl4