aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-11-12 14:35:15 -0800
committerAppability <appable@icloud.com>2022-11-12 14:35:15 -0800
commitde601769d8a1b5fc7543d5b0b4a95596db926416 (patch)
tree3fea24e9e4d55f93e00553e2a2ca9f6ecb1ef713 /src
parent2b21d3a18b412ec8c205beacf403f0147dc04618 (diff)
downloadAmbientAddons-de601769d8a1b5fc7543d5b0b4a95596db926416.tar.gz
AmbientAddons-de601769d8a1b5fc7543d5b0b4a95596db926416.tar.bz2
AmbientAddons-de601769d8a1b5fc7543d5b0b4a95596db926416.zip
placeholder custom end info, farming qol, thunder warning
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/com/ambientaddons/AmbientAddons.kt7
-rw-r--r--src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt2
-rw-r--r--src/main/kotlin/com/ambientaddons/config/Config.kt33
-rw-r--r--src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt2
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/CustomEndInfo.kt45
-rw-r--r--src/main/kotlin/com/ambientaddons/features/misc/Farming.kt85
-rw-r--r--src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt5
-rw-r--r--src/main/kotlin/com/ambientaddons/features/misc/ThunderWarning.kt41
8 files changed, 210 insertions, 10 deletions
diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt
index ed2d072..5de2222 100644
--- a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt
+++ b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt
@@ -34,7 +34,7 @@ import java.io.File
@Mod(
modid = "ambientaddons",
name = "AmbientAddons",
- version = "0.1",
+ version = "1.0-rc.1",
useMetadata = true,
clientSideOnly = true
)
@@ -78,7 +78,10 @@ class AmbientAddons {
PingOverlay,
ThornOverlay,
KuudraFeatures,
- Salvage
+ Salvage,
+ Farming,
+ ThunderWarning,
+ CustomEndInfo
).forEach(MinecraftForge.EVENT_BUS::register)
keyBinds.values.forEach(ClientRegistry::registerKeyBinding)
guiElements = listOf(
diff --git a/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt
index 9ba1988..ff86228 100644
--- a/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt
+++ b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt
@@ -11,7 +11,7 @@ import net.minecraft.command.ICommandSender
class AmbientCommand : CommandBase() {
override fun getCommandName() = "ambientaddons"
- override fun getCommandAliases() = listOf("aa")
+ override fun getCommandAliases() = listOf("aa", "ambient")
override fun getCommandUsage(sender: ICommandSender?) = "/$commandName"
diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt
index 6e5bfc8..47bc085 100644
--- a/src/main/kotlin/com/ambientaddons/config/Config.kt
+++ b/src/main/kotlin/com/ambientaddons/config/Config.kt
@@ -10,6 +10,7 @@ import java.io.File
object Config : Vigilant(
File(AmbientAddons.configDirectory, "config.toml"), AmbientAddons.metadata.name
) {
+ var farmingBlockMisclicks = false
var salvageMode = 0
var topQualityStrategy = false
@@ -35,8 +36,10 @@ object Config : Vigilant(
var blockLowReroll = false
var autoBuyChest = 0
var autoReady = 0
+ var customEndInfo = 0
var maskWarning = false
+ var thunderWarning = false
var cat = true
var witherShieldDisplay = 0
var spiritBowTimer = 0
@@ -56,6 +59,11 @@ object Config : Vigilant(
init {
category("Misc") {
+ switch(
+ ::farmingBlockMisclicks,
+ name = "Block crop misclicks",
+ description = "Intelligent crop misclick prevention for stems, tall crops, crops without replenish, and mushrooms (using the two common mushroom layouts). Bypass with fist."
+ )
subcategory("Salvaging") {
selector(
::salvageMode,
@@ -196,8 +204,18 @@ object Config : Vigilant(
)
}
-
-
+ category("Notifications") {
+ switch(
+ ::maskWarning,
+ name = "Mask proc warning",
+ description = "Displays a title when a spirit mask or bonzo mask procs."
+ )
+ switch(
+ ::thunderWarning,
+ name = "Thunder bottle warning",
+ description = "Displays a title when a thunder bottle is fully charged. Re-activates on entering new worlds."
+ )
+ }
category("Displays") {
button(
name = "Move GUI elements",
@@ -206,11 +224,6 @@ object Config : Vigilant(
currentGui = MoveGui()
}
switch(
- ::maskWarning,
- name = "Mask proc warning",
- description = "Displays a title when a spirit mask or bonzo mask procs."
- )
- switch(
::cat,
name = "Cat",
description = "Show catplague's awesome cat upgrade! Disabling is a crime.",
@@ -245,6 +258,12 @@ object Config : Vigilant(
}
category("Dungeon") {
+ selector(
+ ::customEndInfo,
+ name = "Custom end info",
+ description = "Work-in-progress; currently will only show extra stats at the end of a run.",
+ options = listOf("Off", "Extra Stats", "Custom End Info")
+ )
subcategory("Miscellaneous QOL") {
slider(
::terminatorCps,
diff --git a/src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt b/src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt
index 256fbe1..c1c8d53 100644
--- a/src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt
+++ b/src/main/kotlin/com/ambientaddons/events/HitBlockEvent.kt
@@ -2,6 +2,8 @@ package com.ambientaddons.events
import net.minecraft.util.BlockPos
import net.minecraft.util.EnumFacing
+import net.minecraftforge.fml.common.eventhandler.Cancelable
import net.minecraftforge.fml.common.eventhandler.Event
+@Cancelable
class HitBlockEvent(val blockPos: BlockPos, val face: EnumFacing) : Event() \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/CustomEndInfo.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/CustomEndInfo.kt
new file mode 100644
index 0000000..f67590a
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/CustomEndInfo.kt
@@ -0,0 +1,45 @@
+package com.ambientaddons.features.dungeon
+
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+import com.ambientaddons.utils.Area
+import com.ambientaddons.utils.Extensions.stripControlCodes
+import com.ambientaddons.utils.SBLocation
+import gg.essential.universal.UChat
+import net.minecraftforge.client.event.ClientChatReceivedEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
+
+object CustomEndInfo {
+ private var ticks = 0
+ private var showExtraStatsTime = -1
+ private var hasShownExtraStats = false
+
+ @SubscribeEvent
+ fun onWorldUnload(event: WorldEvent.Unload) {
+ hasShownExtraStats = false
+ }
+
+ @SubscribeEvent(receiveCanceled = true)
+ fun onChatReceived(event: ClientChatReceivedEvent) {
+ if (SBLocation.area != Area.Dungeon || config.customEndInfo == 0) return
+ val stripped = event.message.unformattedText.stripControlCodes().trim().replace(",", "")
+ if (!hasShownExtraStats && listOf("Master Mode Catacombs - ", "The Catacombs - ").any { stripped.startsWith(it) }) {
+ showExtraStatsTime = ticks + 10
+ hasShownExtraStats = true
+ }
+ }
+
+ @SubscribeEvent
+ fun onTick(event: ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START) return
+ if (ticks == showExtraStatsTime) {
+ mc.thePlayer?.sendChatMessage("/showextrastats")
+ }
+ ticks++
+ }
+
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/misc/Farming.kt b/src/main/kotlin/com/ambientaddons/features/misc/Farming.kt
index c90de6e..caa1285 100644
--- a/src/main/kotlin/com/ambientaddons/features/misc/Farming.kt
+++ b/src/main/kotlin/com/ambientaddons/features/misc/Farming.kt
@@ -1,7 +1,92 @@
package com.ambientaddons.features.misc
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+import com.ambientaddons.events.HitBlockEvent
+import com.ambientaddons.utils.Area
+import com.ambientaddons.utils.Extensions.enchants
+import com.ambientaddons.utils.Extensions.withModPrefix
+import com.ambientaddons.utils.SBLocation
+import gg.essential.universal.UChat
+import net.minecraft.block.Block
+import net.minecraft.init.Blocks
+import net.minecraft.init.Items
+import net.minecraft.util.BlockPos
+import net.minecraftforge.client.event.GuiOpenEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object Farming {
+ private val stems: Set<Block> = setOf(Blocks.melon_stem, Blocks.pumpkin_stem)
+ private val crops: Set<Block> = setOf(Blocks.wheat, Blocks.carrots, Blocks.potatoes, Blocks.cocoa, Blocks.nether_wart)
+ private val talls: Set<Block> = setOf(Blocks.cactus, Blocks.reeds)
+ private val shrooms: Set<Block> = setOf(Blocks.brown_mushroom, Blocks.red_mushroom)
+ private val dirts: Set<Block> = setOf(Blocks.dirt, Blocks.mycelium)
+
+ private val whitelist = setOf(Items.melon_seeds, Items.pumpkin_seeds)
+
+ private var lastHeldItemIndex = -1
+ private var hasReplenish = false
+ private var nextWarningTime = System.currentTimeMillis()
+
+ @SubscribeEvent
+ fun onGuiOpen(event: GuiOpenEvent) {
+ if (!config.farmingBlockMisclicks) return
+ lastHeldItemIndex = -1
+ }
+
+ @SubscribeEvent
+ fun onBlockHit(event: HitBlockEvent) {
+ if (!config.farmingBlockMisclicks || SBLocation.area != Area.PrivateIsland) return
+ val hitBlock = mc.theWorld?.getBlockState(event.blockPos)?.block ?: return
+ val currentItem = mc.thePlayer?.inventory?.getCurrentItem()
+ if (currentItem == null || whitelist.contains(currentItem.item)) return
+ if (lastHeldItemIndex != heldItemIndex) {
+ hasReplenish = currentItem.enchants?.get("replenish") != null
+ lastHeldItemIndex = heldItemIndex
+ }
+ when {
+ stems.contains(hitBlock) -> cancelAndWarn(event, "Blocked breaking a stem!")
+ crops.contains(hitBlock) -> {
+ if (!hasReplenish) cancelAndWarn(event, "Blocked breaking a crop without Replenish!")
+ }
+ talls.contains(hitBlock) -> {
+ if (mc.theWorld?.getBlockState(event.blockPos.down())?.block != hitBlock) {
+ cancelAndWarn(event, "Blocked breaking the bottom block of a tall crop!")
+ }
+ }
+ shrooms.contains(hitBlock) -> {
+ val belowPos = event.blockPos.down()
+ val nw = isBlockDirt(belowPos.north().west())
+ val n = isBlockDirt(belowPos.north())
+ val ne = isBlockDirt(belowPos.north().east())
+ val sw = isBlockDirt(belowPos.south().west())
+ val s = isBlockDirt(belowPos.south())
+ val se = isBlockDirt(belowPos.south().east())
+ val w = isBlockDirt(belowPos.west())
+ val e = isBlockDirt(belowPos.east())
+ val isRowNorth = nw && n && ne
+ val isRowSouth = sw && s && se
+ val isRowWest = nw && w && sw
+ val isRowEast = ne && e && se
+ if (isRowNorth || isRowSouth || isRowWest || isRowEast) {
+ cancelAndWarn(event, "Blocked breaking a source mushroom!")
+ }
+ }
+ }
+ }
+
+ private fun isBlockDirt(pos: BlockPos): Boolean = dirts.contains(mc.theWorld?.getBlockState(pos)?.block)
+
+ private fun cancelAndWarn(event: HitBlockEvent, message: String) {
+ if ((System.currentTimeMillis() - nextWarningTime) >= 0) {
+ UChat.chat("§c${message}".withModPrefix())
+ mc.thePlayer?.playSound("random.pop", 1f, 0f)
+ nextWarningTime = System.currentTimeMillis() + 500
+ }
+ event.isCanceled = true
+ }
+
+ private val heldItemIndex: Int
+ get() = mc.thePlayer?.inventory?.currentItem ?: -1
} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt b/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt
index 914870f..a1ee583 100644
--- a/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt
+++ b/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt
@@ -8,6 +8,7 @@ import com.ambientaddons.utils.Extensions.itemQuality
import com.ambientaddons.utils.Extensions.items
import com.ambientaddons.utils.Extensions.skyblockID
import com.ambientaddons.utils.Extensions.stars
+import com.ambientaddons.utils.SBLocation
import com.ambientaddons.utils.SalvageStrategy
import com.ambientaddons.utils.render.OverlayUtils
import net.minecraft.client.gui.inventory.GuiContainer
@@ -30,6 +31,7 @@ object Salvage {
@SubscribeEvent
fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) {
+ if (!SBLocation.inSkyblock) return
val chest = event.gui?.chest ?: return
if (config.salvageMode < 3 || chest.lowerChestInventory.name != "Salvage Item") return
val color = chest.lowerChestInventory.items.last()?.itemDamage
@@ -65,12 +67,14 @@ object Salvage {
@SubscribeEvent
fun onContainerOpen(event: GuiOpenEvent) {
+ if (!SBLocation.inSkyblock) return
if (event.gui?.chest == null) return
status = SalvageStatus.Idle
}
@SubscribeEvent
fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
+ if (!SBLocation.inSkyblock) return
if (config.salvageMode < 2 || event.slot == null) return
if (!isSlotInInventory(event.gui, event.slot)) return
if (status != SalvageStatus.Idle
@@ -91,6 +95,7 @@ object Salvage {
@SubscribeEvent
fun onDrawSlot(event: GuiContainerEvent.DrawSlotEvent) {
+ if (!SBLocation.inSkyblock) return
if (config.salvageMode == 0 || !isSlotInInventory(event.gui, event.slot)) return
val color = when (getSalvageStrategy(event.slot.stack ?: return)) {
SalvageStrategy.Always -> Color.GREEN
diff --git a/src/main/kotlin/com/ambientaddons/features/misc/ThunderWarning.kt b/src/main/kotlin/com/ambientaddons/features/misc/ThunderWarning.kt
new file mode 100644
index 0000000..fb16c43
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/features/misc/ThunderWarning.kt
@@ -0,0 +1,41 @@
+package com.ambientaddons.features.misc
+
+import AmbientAddons.Companion.config
+import AmbientAddons.Companion.mc
+import com.ambientaddons.utils.Extensions.items
+import com.ambientaddons.utils.Extensions.skyblockID
+import com.ambientaddons.utils.SBLocation
+import gg.essential.universal.UChat
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
+
+object ThunderWarning {
+ private var hadChargedThunderBottle = false
+ private var ticks = 0
+
+ @SubscribeEvent
+ fun onWorldLoad(event: WorldEvent.Load) {
+ hadChargedThunderBottle = false
+ }
+
+ @SubscribeEvent
+ fun onTick(event: ClientTickEvent) {
+ if (!config.thunderWarning || !SBLocation.inSkyblock || event.phase != TickEvent.Phase.START) return
+ if (ticks % 10 == 0) {
+ if (hasChargedThunderBottle() && !hadChargedThunderBottle) {
+ mc.ingameGUI.displayTitle("§dThunder charged!", null, 5, 40, 5)
+ mc.ingameGUI.displayTitle(null, "", 5, 40, 5)
+ mc.ingameGUI.displayTitle(null, null, 5, 40, 5)
+ mc.thePlayer.playSound("random.orb", 1f, 0.5f)
+ }
+ hadChargedThunderBottle = hasChargedThunderBottle()
+ }
+ ticks++
+ }
+
+ private fun hasChargedThunderBottle(): Boolean =
+ mc.thePlayer?.inventory?.items?.any { it?.skyblockID == "THUNDER_IN_A_BOTTLE" } == true
+
+} \ No newline at end of file