diff options
author | Zachary Jaser <76439587+Zickles@users.noreply.github.com> | 2024-03-06 03:33:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 09:33:07 +0100 |
commit | 82a00ed51d55d2be7d65d24c2e93e797cab33864 (patch) | |
tree | 0deee292d673718086394f82cb336e827166a9bf /src/main/java/at/hannibal2/skyhanni/features/minion | |
parent | 88404bf8dc0f2aa9493000591e9db2e5d2caa369 (diff) | |
download | skyhanni-82a00ed51d55d2be7d65d24c2e93e797cab33864.tar.gz skyhanni-82a00ed51d55d2be7d65d24c2e93e797cab33864.tar.bz2 skyhanni-82a00ed51d55d2be7d65d24c2e93e797cab33864.zip |
[Feat] block player from destroying fuel in inferno minion (#1103)
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/minion')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt new file mode 100644 index 000000000..37593552d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt @@ -0,0 +1,77 @@ +package at.hannibal2.skyhanni.features.minion + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.jsonobjects.repo.InfernoMinionFuelsJson +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.KeyboardManager +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class InfernoMinionFeatures { + private val config get() = SkyHanniMod.feature.minions + private val infernoMinionTitlePattern by RepoPattern.pattern( + "minion.infernominiontitle", + "Inferno Minion .*" + ) + private var fuelItemIds = listOf<NEUInternalName>() + private var inInventory = false + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<InfernoMinionFuelsJson>("InfernoMinionFuels") + fuelItemIds = data.minionFuels + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + inInventory = infernoMinionTitlePattern.matches(event.inventoryName) + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inInventory = false + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.infernoFuelBlocker) return + if (!inInventory) return + + val containsFuel = NEUInternalName.fromItemNameOrNull(event.container.getSlot(19).stack.name.toString()) in fuelItemIds + if (!containsFuel) return + + if (event.slot?.slotNumber == 19 || event.slot?.slotNumber == 53) { + if (KeyboardManager.isModifierKeyDown()) return + event.cancel() + } + } + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent) { + if (!config.infernoFuelBlocker) return + if (!inInventory) return + + val containsFuel = NEUInternalName.fromItemNameOrNull(event.itemStack.name.toString()) in fuelItemIds + if (!containsFuel) return + + if (event.slot.slotNumber == 19) { + event.toolTip.add("") + event.toolTip.add("§c[SkyHanni] is blocking you from taking this out!") + event.toolTip.add(" §7(Bypass by holding the ${KeyboardManager.getModifierKeyName()} key)") + } + if (event.slot.slotNumber == 53) { + event.toolTip.add("") + event.toolTip.add("§c[SkyHanni] is blocking you from picking this minion up!") + event.toolTip.add(" §7(Bypass by holding the ${KeyboardManager.getModifierKeyName()} key)") + } + } +} |