From 7558c19e799f0ccb4efd12652dfa45020f00bc55 Mon Sep 17 00:00:00 2001 From: Obsidian <108832807+Obsidianninja11@users.noreply.github.com> Date: Tue, 30 Apr 2024 02:33:44 -0800 Subject: Fix: VisitorRewardWarning only blocking normal clicks (#1595) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../at/hannibal2/skyhanni/events/GuiContainerEvent.kt | 17 ++++++++++++++++- .../features/garden/visitor/VisitorRewardWarning.kt | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt index b11f75733..814f53d68 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt @@ -56,11 +56,13 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: val slot: Slot?, val slotId: Int, val clickedButton: Int, + @Deprecated("old", ReplaceWith("clickTypeEnum")) val clickType: Int, + val clickTypeEnum: ClickType? = ClickType.getTypeById(clickType), ) : GuiContainerEvent(gui, container) { fun makePickblock() { - if (this.clickedButton == 2 && this.clickType == 3) return + if (this.clickedButton == 2 && this.clickTypeEnum == ClickType.HOTBAR) return slot?.slotNumber?.let { slotNumber -> Minecraft.getMinecraft().playerController.windowClick( container.windowId, slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer @@ -69,4 +71,17 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: } } } + + enum class ClickType(val id: Int) { + NORMAL(1), + SHIFT(2), + HOTBAR(3), + MIDDLE(4), + DROP(5), + ; + + companion object { + fun getTypeById(id: Int) = entries.firstOrNull { it.id == id } + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt index ba56595bd..c66faf0f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt @@ -52,7 +52,6 @@ class VisitorRewardWarning { fun onStackClick(event: GuiContainerEvent.SlotClickEvent) { if (!VisitorAPI.inInventory) return val stack = event.slot?.stack ?: return - if (event.clickType != 0) return val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return val blockReason = visitor.blockReason @@ -66,6 +65,8 @@ class VisitorRewardWarning { return } + // clicktypes 0, 2, 3, and 4 work for interacting with visitor, but not 1 + if (event.clickTypeEnum == GuiContainerEvent.ClickType.NORMAL) return if (isRefuseSlot) { VisitorAPI.changeStatus(visitor, VisitorAPI.VisitorStatus.REFUSED, "refused") return -- cgit