diff options
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)") + } + } +} |