diff options
-rw-r--r-- | build.gradle.kts | 2 | ||||
-rw-r--r-- | src/main/kotlin/com/ambientaddons/AmbientAddons.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/com/ambientaddons/config/Config.kt | 7 | ||||
-rw-r--r-- | src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt | 5 | ||||
-rw-r--r-- | src/main/kotlin/com/ambientaddons/features/misc/Trapper.kt | 44 |
5 files changed, 50 insertions, 10 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 08bf84c..6e5905d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,7 @@ plugins { } group = "AmbientAddons" -version = "1.0.0" +version = "1.0.1" java { toolchain.languageVersion.set(JavaLanguageVersion.of(8)) 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 { |