From c599ee0d78ed8bc17488636f2d9b9b1d5b6dd4a8 Mon Sep 17 00:00:00 2001 From: Appability Date: Wed, 12 Oct 2022 20:48:51 -0700 Subject: uh a lot of things --- .../com/ambientaddons/features/misc/BonzoMask.kt | 60 ++++++++++++++++++++++ .../features/misc/CancelInteractions.kt | 22 ++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt create mode 100644 src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt (limited to 'src/main/kotlin/com/ambientaddons/features/misc') diff --git a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt new file mode 100644 index 0000000..db45e93 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt @@ -0,0 +1,60 @@ +package com.ambientaddons.features.misc + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.events.ItemOverlayEvent +import com.ambientaddons.utils.Extensions.skyblockID +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.RenderUtils +import net.minecraftforge.client.event.ClientChatReceivedEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object BonzoMask { + private var spiritMaskProc = 0L + private var bonzoMaskProc = 0L + private var fraggedBonzoMaskProc = 0L + + private const val secondWindString = "Second Wind Activated! Your Spirit Mask saved your life!" + private const val bonzoString = "Your Bonzo's Mask saved your life!" + private const val fraggedBonzoString = "Your ⚚ Bonzo's Mask saved your life!" + + @SubscribeEvent + fun onChat(event: ClientChatReceivedEvent) { + if (!SkyBlock.inSkyblock) return + val didMaskProc = when (event.message.unformattedText.stripControlCodes()) { + secondWindString -> { + spiritMaskProc = System.currentTimeMillis() + true + } + bonzoString -> { + bonzoMaskProc = System.currentTimeMillis() + true + } + fraggedBonzoString -> { + fraggedBonzoMaskProc = System.currentTimeMillis() + true + } + else -> false + } + if (config.maskWarning && didMaskProc) { + mc.ingameGUI.displayTitle("§cMask!", null, 5, 20, 5) + } + } + + @SubscribeEvent + fun onRenderItemOverlay(event: ItemOverlayEvent) { + if (!SkyBlock.inSkyblock) return + val durability = when (event.item?.skyblockID) { + "BONZO_MASK" -> (System.currentTimeMillis() - bonzoMaskProc) / 180000.0 + "STARRED_BONZO_MASK" -> (System.currentTimeMillis() - fraggedBonzoMaskProc) / 180000.0 + "SPIRIT_MASK" -> (System.currentTimeMillis() - spiritMaskProc) / 30000.0 + else -> 1.0 + } + if (durability < 1.0) { + RenderUtils.renderDurabilityBar(event.x, event.y, durability) + } + } + + +} \ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt b/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt new file mode 100644 index 0000000..60f0f8f --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt @@ -0,0 +1,22 @@ +package com.ambientaddons.features.misc + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.utils.Area +import com.ambientaddons.utils.SkyBlock +import net.minecraft.init.Blocks +import net.minecraftforge.event.entity.player.PlayerInteractEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object CancelInteractions { + @SubscribeEvent + fun onPlayerInteract(event: PlayerInteractEvent) { + if (!SkyBlock.inSkyblock) return + if (!config.cancelInteractions || SkyBlock.area == Area.PrivateIsland) return + if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + if (mc.theWorld?.getBlockState(event.pos)?.block == Blocks.hopper) { + event.isCanceled = true + } + } + } +} \ No newline at end of file -- cgit