From 370cf58f29a5d32040f83ca17465fd493cc88f61 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 26 Jul 2023 23:59:20 +0200 Subject: Added Horsezooka Hider --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 3 ++- .../skyhanni/config/features/RiftConfig.java | 15 ++++++++++----- .../at/hannibal2/skyhanni/data/MinecraftData.kt | 19 +++++++++++++++++++ .../skyhanni/events/ItemInHandChangeEvent.kt | 5 +++++ .../features/misc/ExpBottleOnGroundHider.kt | 20 -------------------- .../skyhanni/features/misc/ExpOrbsOnGroundHider.kt | 20 ++++++++++++++++++++ .../rift/everywhere/RiftHorsezookaHider.kt | 22 ++++++++++++++++++++++ .../at/hannibal2/skyhanni/utils/InventoryUtils.kt | 3 +++ 8 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ExpBottleOnGroundHider.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 3be3c73db..9519e0146 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -182,7 +182,7 @@ class SkyHanniMod { loadModule(HideNotClickableItems()) loadModule(ItemDisplayOverlayFeatures()) loadModule(CurrentPetDisplay()) - loadModule(ExpBottleOnGroundHider()) + loadModule(ExpOrbsOnGroundHider()) loadModule(DamageIndicatorManager()) loadModule(ItemAbilityCooldown()) loadModule(DungeonHighlightClickedBlocks()) @@ -359,6 +359,7 @@ class SkyHanniMod { loadModule(SlayerBossSpawnSoon()) loadModule(RiftBloodEffigies()) loadModule(RiftWiltedBerberisHelper()) + loadModule(RiftHorsezookaHider()) // diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index 0a7caf5ce..f2b4434ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -600,11 +600,6 @@ public class RiftConfig { } - @Expose - @ConfigOption(name = "Highlight Guide", desc = "Highlight things to do in the Rift Guide.") - @ConfigEditorBoolean - public boolean highlightGuide = true; - @Expose @ConfigOption(name = "Motes Sell Price", desc = "") @Accordion @@ -662,4 +657,14 @@ public class RiftConfig { public boolean hideParticles = false; } + + @Expose + @ConfigOption(name = "Highlight Guide", desc = "Highlight things to do in the Rift Guide.") + @ConfigEditorBoolean + public boolean highlightGuide = true; + + @Expose + @ConfigOption(name = "Horsezooka Hider", desc = "Hide horses while holding the Horsezooka in the hand.") + @ConfigEditorBoolean + public boolean horsezookaHider = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt index c28db9a9d..b9e2b45dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import net.minecraft.client.Minecraft @@ -64,4 +66,21 @@ class MinecraftData { tick++ LorenzTickEvent(tick).postAndCatch() } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + val hand = InventoryUtils.getItemInHand() + val newItem = hand?.getInternalName() ?: "" + if (newItem != InventoryUtils.itemInHandId) { + ItemInHandChangeEvent(newItem, hand).postAndCatch() + InventoryUtils.itemInHandId = newItem + InventoryUtils.latestItemInHand = hand + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + InventoryUtils.itemInHandId = "" + } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt new file mode 100644 index 000000000..121e7d9cd --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +import net.minecraft.item.ItemStack + +class ItemInHandChangeEvent(val internalName: String, val stack: ItemStack?) : LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ExpBottleOnGroundHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ExpBottleOnGroundHider.kt deleted file mode 100644 index b1f47f015..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ExpBottleOnGroundHider.kt +++ /dev/null @@ -1,20 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.entity.item.EntityXPOrb -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class ExpBottleOnGroundHider { - - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.misc.hideExpBottles) return - - if (event.entity is EntityXPOrb) { - event.isCanceled = true - } - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt new file mode 100644 index 000000000..5d1b34564 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.entity.item.EntityXPOrb +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ExpOrbsOnGroundHider { + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!LorenzUtils.inSkyBlock) return + if (!SkyHanniMod.feature.misc.hideExpBottles) return + + if (event.entity is EntityXPOrb) { + event.isCanceled = true + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt new file mode 100644 index 000000000..cab024462 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.features.rift.everywhere + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.utils.InventoryUtils +import net.minecraft.entity.passive.EntityHorse +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class RiftHorsezookaHider { + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!RiftAPI.inRift()) return + if (!SkyHanniMod.feature.rift.horsezookaHider) return + + if (event.entity is EntityHorse) { + if (InventoryUtils.itemInHandId == "HORSEZOOKA") { + event.isCanceled = true + } + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index 9e1ade646..54ea399bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -7,6 +7,9 @@ import net.minecraft.item.ItemStack object InventoryUtils { + var itemInHandId = "" + var latestItemInHand: ItemStack? = null + fun getItemsInOpenChest() = buildList { val guiChest = Minecraft.getMinecraft().currentScreen as GuiChest val inventorySlots = guiChest.inventorySlots.inventorySlots -- cgit