aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-11-13 23:32:10 -0800
committerAppability <appable@icloud.com>2022-11-13 23:32:10 -0800
commitf290d5285cb92dd427726cdc203156187690f068 (patch)
tree7bc4aa967ea009338fb7a78e75a1eefc678d4943 /src
parentfbcfd07e27fb2f64787c67244bb58730982ec2c1 (diff)
downloadAmbientAddons-f290d5285cb92dd427726cdc203156187690f068.tar.gz
AmbientAddons-f290d5285cb92dd427726cdc203156187690f068.tar.bz2
AmbientAddons-f290d5285cb92dd427726cdc203156187690f068.zip
fix trapper, add cd
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/com/ambientaddons/AmbientAddons.kt2
-rw-r--r--src/main/kotlin/com/ambientaddons/config/Config.kt7
-rw-r--r--src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt5
-rw-r--r--src/main/kotlin/com/ambientaddons/features/misc/Trapper.kt44
4 files changed, 49 insertions, 9 deletions
diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt
index f642c2d..e9c084c 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 = "1.0.0",
+ version = "1.0.1",
useMetadata = true,
clientSideOnly = true
)
diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt
index 22c9f5b..a717008 100644
--- a/src/main/kotlin/com/ambientaddons/config/Config.kt
+++ b/src/main/kotlin/com/ambientaddons/config/Config.kt
@@ -19,6 +19,7 @@ object Config : Vigilant(
var kuudraAlert = false
var autoTrapper = false
var trapperEsp = false
+ var trapperCooldown = 0
var crimsonNotify = false
var crimsonColor = Color.CYAN
@@ -105,6 +106,12 @@ object Config : Vigilant(
name = "Highlight trapper animals",
description = "Highlights trapper quests with a beacon beam and box. Legal, as Hypixel uses the glowing status effect for clients that support it."
)
+ selector(
+ ::trapperCooldown,
+ name = "Show trapper cooldown",
+ description = "Shows trapper cooldown above crosshair.",
+ options = listOf("Off", "Default", "Shadow", "Outline")
+ )
}
subcategory("Fishing features") {
switch(
diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
index f1cd74f..d2790b4 100644
--- a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
+++ b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt
@@ -37,10 +37,11 @@ object AutoBuyChest {
fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
if (SBLocation.area != Area.Dungeon || rewardChest == null) return
if (event.slotId == BUY_SLOT_INDEX) {
- hasOpenedChest = true
- if (rewardChest == RewardChest.Wood) {
+ if (rewardChest == RewardChest.Wood && hasOpenedChest) {
UChat.chat("§cBlocked purchase! You already opened a chest this run.".withModPrefix())
event.isCanceled = true
+ } else {
+ hasOpenedChest = true
}
} else if (event.slotId == KISMET_SLOT_INDEX) {
if (config.blockLowReroll && rewardChest != RewardChest.Bedrock && (rewardChest != RewardChest.Obsidian || SBLocation.dungeonFloor.toString() != "M4")) {
diff --git a/src/main/kotlin/com/ambientaddons/features/misc/Trapper.kt b/src/main/kotlin/com/ambientaddons/features/misc/Trapper.kt
index d3269c2..ce468eb 100644
--- a/src/main/kotlin/com/ambientaddons/features/misc/Trapper.kt
+++ b/src/main/kotlin/com/ambientaddons/features/misc/Trapper.kt
@@ -2,37 +2,56 @@ package com.ambientaddons.features.misc
import AmbientAddons.Companion.config
import AmbientAddons.Companion.mc
+import com.ambientaddons.features.display.WitherShieldOverlay
+import com.ambientaddons.utils.Alignment
import com.ambientaddons.utils.Area
import com.ambientaddons.utils.SBLocation
+import com.ambientaddons.utils.dungeon.TextStyle
import com.ambientaddons.utils.render.EntityUtils
+import com.ambientaddons.utils.render.OverlayUtils
+import net.minecraft.client.gui.ScaledResolution
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.passive.*
import net.minecraftforge.client.event.ClientChatReceivedEvent
+import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color
+import kotlin.math.ceil
+import kotlin.math.roundToInt
object Trapper {
private var color: Color? = null
private val trapperRegex =
Regex("^§e\\[NPC\\] Trevor The Trapper§f: §rYou can find your §(?<color>[0-9a-f])§l\\w+ §fanimal near the §(?<locationColor>[0-9a-f])(?<location>[\\w ]+)§f.§r$")
private val animals =
- listOf(EntityCow::class, EntityPig::class, EntitySheep::class, EntityCow::class, EntityChicken::class, EntityRabbit::class)
+ listOf(
+ EntityCow::class,
+ EntityPig::class,
+ EntitySheep::class,
+ EntityCow::class,
+ EntityChicken::class,
+ EntityRabbit::class,
+ EntityHorse::class
+ )
private val animalHp: List<Float?> = listOf(100F, 200F, 500F, 1000F, 1024F, 2048F)
+ private var cooldownEndTime = 0L
+
fun isTrapperAnimal(entity: Entity): Boolean =
- entity.ticksExisted >= 10 && (entity::class in animals) && animalHp.contains((entity as? EntityLiving)?.maxHealth)
+ entity.ticksExisted >= 20 && (entity::class in animals) && animalHp.contains((entity as? EntityLiving)?.maxHealth)
@SubscribeEvent
fun onChat(event: ClientChatReceivedEvent) {
if (SBLocation.area != Area.FarmingIslands || event.message == null || event.type == 2.toByte()) return
- if (config.autoTrapper) {
- val siblings = event.message.siblings ?: return
- if (siblings.getOrNull(0)?.unformattedText == "Accept the trapper's task to hunt the animal?") {
- val command = siblings.getOrNull(3)?.chatStyle?.chatClickEvent?.value ?: return
+ val siblings = event.message.siblings ?: return
+ if (siblings.getOrNull(0)?.unformattedText == "Accept the trapper's task to hunt the animal?") {
+ val command = siblings.getOrNull(3)?.chatStyle?.chatClickEvent?.value ?: return
+ if (config.autoTrapper) {
mc.thePlayer.sendChatMessage(command)
}
+ cooldownEndTime = System.currentTimeMillis() + 30000
}
val matchResult = event.message.formattedText.let { trapperRegex.find(it) }
if (matchResult != null) {
@@ -47,6 +66,19 @@ object Trapper {
}
@SubscribeEvent
+ fun onRenderOverlay(event: RenderGameOverlayEvent) {
+ if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return
+ if (SBLocation.area != Area.FarmingIslands || config.trapperCooldown == 0) return
+ val diff = ((cooldownEndTime - System.currentTimeMillis()) / 1000.0).takeIf { it >= 0 } ?: return
+ val display = "§a${ceil(diff).roundToInt()}"
+ val resolution = ScaledResolution(mc)
+ val x = resolution.scaledWidth / 2 + 1
+ val y = resolution.scaledHeight / 2 - 20
+ val style = TextStyle.fromInt(config.trapperCooldown - 1) ?: return
+ OverlayUtils.drawString(x, y, display, style, Alignment.Center)
+ }
+
+ @SubscribeEvent
fun onRenderWorld(event: RenderWorldLastEvent) {
if (SBLocation.area != Area.FarmingIslands || !config.trapperEsp) return
mc.theWorld.loadedEntityList.forEach {