aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-03-23 18:45:05 +0100
committerGitHub <noreply@github.com>2024-03-23 18:45:05 +0100
commit7839e0f489b48468f7ce4dc71400523581f03c1a (patch)
tree2b2371024ebcca5fb0b84f34a0a6a296cceb5e0c /src/main/java/at/hannibal2
parentc03d6b26f0d5a8e1d99b5e8f49de0d3aa87969a9 (diff)
downloadskyhanni-7839e0f489b48468f7ce4dc71400523581f03c1a.tar.gz
skyhanni-7839e0f489b48468f7ce4dc71400523581f03c1a.tar.bz2
skyhanni-7839e0f489b48468f7ce4dc71400523581f03c1a.zip
Backend: Removal of Neu's SlotClickEvent (#1206)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenPlotIcon.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt10
9 files changed, 34 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenPlotIcon.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenPlotIcon.kt
index b1ae273fa..6b7389079 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenPlotIcon.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenPlotIcon.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.garden.inventory
+import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
@@ -9,7 +10,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.player.inventory.ContainerLocalMenu
import net.minecraft.init.Items
@@ -84,7 +84,7 @@ object GardenPlotIcon {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onStackClick(event: SlotClickEvent) {
+ fun onStackClick(event: GuiContainerEvent.SlotClickEvent) {
if (!isEnabled()) return
lastClickedSlotId = event.slotId
if (event.slotId == 53) {
@@ -105,7 +105,7 @@ object GardenPlotIcon {
if (editMode != 0) {
if (event.slotId in 54..89) {
event.isCanceled = true
- copyStack = event.slot.stack?.copy()?.also {
+ copyStack = event.slot?.stack?.copy()?.also {
it.stackSize = 1
} ?: return
// TODO different format, not bold or show not in chat at all.
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
index f372b723e..b5f7dc87c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden.visitor
import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig
import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
+import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiKeyPressEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
@@ -24,7 +25,6 @@ import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.entity.item.EntityArmorStand
@@ -34,7 +34,6 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.input.Keyboard
-
class VisitorListener {
private val config get() = VisitorAPI.config
@@ -129,14 +128,14 @@ class VisitorListener {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onStackClick(event: SlotClickEvent) {
+ fun onStackClick(event: GuiContainerEvent.SlotClickEvent) {
if (!VisitorAPI.inInventory) return
if (event.clickType != 0) return
val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return
if (event.slotId == VISITOR_REFUSE_ITEM_SLOT) {
- if (event.slot.stack?.name != "§cRefuse Offer") return
+ if (event.slot?.stack?.name != "§cRefuse Offer") return
visitor.hasReward()?.let {
if (config.rewardWarning.preventRefusing) {
@@ -161,7 +160,7 @@ class VisitorListener {
VisitorAPI.changeStatus(visitor, VisitorStatus.REFUSED, "refused")
return
}
- if (event.slotId == VISITOR_ACCEPT_ITEM_SLOT && event.slot.stack?.getLore()
+ if (event.slotId == VISITOR_ACCEPT_ITEM_SLOT && event.slot?.stack?.getLore()
?.any { it == "§eClick to give!" } == true
) {
VisitorAPI.changeStatus(visitor, VisitorStatus.ACCEPTED, "accepted")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt
index 3a22672b6..5dbcde99e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.inventory.bazaar
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.BazaarOpenedProductEvent
+import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarDataOrError
import at.hannibal2.skyhanni.utils.InventoryUtils.getAmountInInventory
@@ -11,7 +12,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import net.minecraft.item.ItemStack
import net.minecraftforge.client.event.GuiScreenEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -72,7 +72,7 @@ class BazaarBestSellMethod {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onStackClick(event: SlotClickEvent) {
+ fun onStackClick(event: GuiContainerEvent.SlotClickEvent) {
lastClickedItem = event.slot?.stack
nextCloseWillResetItem = false
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt
index 218345ec6..77178c41a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt
@@ -1,13 +1,13 @@
package at.hannibal2.skyhanni.features.inventory.bazaar
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.entity.player.InventoryPlayer
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -42,7 +42,7 @@ class BazaarOpenPriceWebsite {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onStackClick(event: SlotClickEvent) {
+ fun onStackClick(event: GuiContainerEvent.SlotClickEvent) {
if (!isEnabled()) return
val lastItem = BazaarApi.currentlyOpenedProduct ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt
index ca1db4ff4..f00476d78 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson
import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
@@ -18,7 +19,6 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.ParkourHelper
import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.player.inventory.ContainerLocalMenu
import net.minecraftforge.fml.common.eventhandler.EventPriority
@@ -126,7 +126,7 @@ class DeepCavernsParkour {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onStackClick(event: SlotClickEvent) {
+ fun onStackClick(event: GuiContainerEvent.SlotClickEvent) {
if (showStartIcon && event.slotId == 40) {
event.isCanceled = true
ChatUtils.chat("Manually enabled Deep Caverns Parkour.")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt
index 8c931dfab..26addd367 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt
@@ -2,12 +2,12 @@ package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.features.commands.WikiManager
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -21,7 +21,7 @@ class BetterWikiFromMenus {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onSlotClick(event: SlotClickEvent) {
+ fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!isEnabled()) return
@@ -29,7 +29,7 @@ class BetterWikiFromMenus {
if (chestName.isEmpty()) return
- val itemClickedStack = event.slot.stack ?: return
+ val itemClickedStack = event.slot?.stack ?: return
val itemClickedName = itemClickedStack.displayName
val isWiki = event.slotId == 11 && itemClickedName.contains("Wiki Command")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
index 4ecfa459c..92e7dcd43 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt
@@ -16,11 +16,11 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils.makePickblock
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -110,9 +110,9 @@ class KloonHacking {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onSlotClick(event: SlotClickEvent) {
+ fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (!inTerminalInventory || !RiftAPI.inRift()) return
- event.usePickblockInstead()
+ event.makePickblock()
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt
index cc489c777..754914190 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt
@@ -14,13 +14,13 @@ import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils.makePickblock
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent
-import io.github.moulberry.notenoughupdates.events.SlotClickEvent
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.player.inventory.ContainerLocalMenu
@@ -80,11 +80,11 @@ object EnigmaSoulWaypoints {
}
@SubscribeEvent(priority = EventPriority.HIGH)
- fun onSlotClick(event: SlotClickEvent) {
+ fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (!inInventory || !isEnabled()) return
if (event.slotId == 31 && inventoryUnfound.isNotEmpty()) {
- event.usePickblockInstead()
+ event.makePickblock()
if (adding) {
trackedSouls.addAll(inventoryUnfound)
adding = false
@@ -94,10 +94,10 @@ object EnigmaSoulWaypoints {
}
}
- if (event.slot.stack == null) return
+ if (event.slot?.stack == null) return
val split = event.slot.stack.displayName.split("Enigma: ")
if (split.size == 2) {
- event.usePickblockInstead()
+ event.makePickblock()
if (soulLocations.contains(split.last())) {
if (!trackedSouls.contains(split.last())) {
ChatUtils.chat("§5Tracking the ${split.last()} Enigma Soul!", prefixColor = "§5")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 0c267e6c0..269b543ba 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -282,6 +282,16 @@ object LorenzUtils {
}
}
+ fun GuiContainerEvent.SlotClickEvent.makePickblock() {
+ if (this.clickedButton == 2 && this.clickType == 3) return
+ slot?.slotNumber?.let { slotNumber ->
+ Minecraft.getMinecraft().playerController.windowClick(
+ container.windowId, slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer
+ )
+ isCanceled = true
+ }
+ }
+
private val recalculateDerpy =
RecalculatingValue(1.seconds) { Perk.DOUBLE_MOBS_HP.isActive }