diff options
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/features')
13 files changed, 106 insertions, 40 deletions
diff --git a/src/main/kotlin/com/ambientaddons/features/Trapper.kt b/src/main/kotlin/com/ambientaddons/features/Trapper.kt new file mode 100644 index 0000000..184358a --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/Trapper.kt @@ -0,0 +1,71 @@ +package com.ambientaddons.features + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import com.ambientaddons.utils.Area +import com.ambientaddons.utils.SBLocation +import com.ambientaddons.utils.render.EntityUtils +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.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color + +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])\\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) + private val animalHp: List<Float?> = listOf(100F, 200F, 500F, 1000F, 1024F, 2048F) + + fun isTrapperAnimal(entity: Entity): Boolean = + entity.ticksExisted >= 10 && (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 + mc.thePlayer.sendChatMessage(command) + } + } + val matchResult = event.message.formattedText.let { trapperRegex.find(it) } + if (matchResult != null) { + val colorCode = (matchResult.groups as? MatchNamedGroupCollection)?.get("color")?.value ?: return + color = Color(mc.fontRendererObj.getColorCode(colorCode.single())) + } else if ( + event.message.formattedText.startsWith("§r§aKilling the animal rewarded you ") || + event.message.formattedText.startsWith("§r§aYour mob died randomly, you are rewarded ") + ) { + color = null + } + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (SBLocation.area != Area.FarmingIslands || !config.trapperEsp) return + mc.theWorld.loadedEntityList.forEach { + if (color != null && isTrapperAnimal(it)) { + val renderManager = mc.renderManager + val x = it.lastTickPosX + (it.posX - it.lastTickPosX) * event.partialTicks - renderManager.viewerPosX - 0.5 + val y = it.lastTickPosY + (it.posY - it.lastTickPosY) * event.partialTicks - renderManager.viewerPosY + val z = it.lastTickPosZ + (it.posZ - it.lastTickPosZ) * event.partialTicks - renderManager.viewerPosZ - 0.5 + val entityHeight = it.entityBoundingBox.maxY - it.entityBoundingBox.minY + EntityUtils.drawEntityBox( + it, + color!!, + outline = true, + fill = true, + partialTicks = event.partialTicks, + esp = true + ) + EntityUtils.renderBeaconBeam(x, y + entityHeight, z, color!!, 1F, event.partialTicks, true) + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/display/WitherShieldOverlay.kt b/src/main/kotlin/com/ambientaddons/features/display/WitherShieldOverlay.kt index fa210aa..85801aa 100644 --- a/src/main/kotlin/com/ambientaddons/features/display/WitherShieldOverlay.kt +++ b/src/main/kotlin/com/ambientaddons/features/display/WitherShieldOverlay.kt @@ -4,7 +4,7 @@ import AmbientAddons.Companion.config import AmbientAddons.Companion.mc import com.ambientaddons.utils.Alignment import com.ambientaddons.utils.render.OverlayUtils -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import com.ambientaddons.utils.dungeon.TextStyle import net.minecraft.client.gui.ScaledResolution import net.minecraftforge.client.event.ClientChatReceivedEvent @@ -19,7 +19,7 @@ object WitherShieldOverlay { @SubscribeEvent fun onRenderOverlay(event: RenderGameOverlayEvent) { if (event.type != RenderGameOverlayEvent.ElementType.TEXT) return - if (!SkyBlock.inSkyblock || config.witherShieldDisplay == 0) return + if (!SBLocation.inSkyblock || config.witherShieldDisplay == 0) return val diff = ((witherImpactEndTime - System.currentTimeMillis()) / 1000.0).takeIf { it >= 0 } ?: return val display = ceil(diff).roundToInt().toString() val resolution = ScaledResolution(mc) @@ -31,7 +31,7 @@ object WitherShieldOverlay { @SubscribeEvent fun onChat(event: ClientChatReceivedEvent) { - if (!SkyBlock.inSkyblock || config.witherShieldDisplay == 0) return + if (!SBLocation.inSkyblock || config.witherShieldDisplay == 0) return if (event.type == 2.toByte() && event.message.unformattedText.contains("Wither Impact")) { if (((witherImpactEndTime - System.currentTimeMillis()) / 1000.0) < 0) { witherImpactEndTime = System.currentTimeMillis() + 5000 diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt index 279402d..f1cd74f 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt @@ -12,7 +12,7 @@ import com.ambientaddons.utils.Extensions.skyblockID import com.ambientaddons.utils.Extensions.stripControlCodes import com.ambientaddons.utils.Extensions.withModPrefix import com.ambientaddons.utils.Area -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import gg.essential.universal.UChat import net.minecraft.inventory.ContainerChest import net.minecraft.item.ItemStack @@ -35,7 +35,7 @@ object AutoBuyChest { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { - if (SkyBlock.area != Area.Dungeon || rewardChest == null) return + if (SBLocation.area != Area.Dungeon || rewardChest == null) return if (event.slotId == BUY_SLOT_INDEX) { hasOpenedChest = true if (rewardChest == RewardChest.Wood) { @@ -43,7 +43,7 @@ object AutoBuyChest { event.isCanceled = true } } else if (event.slotId == KISMET_SLOT_INDEX) { - if (config.blockLowReroll && rewardChest != RewardChest.Bedrock && (rewardChest != RewardChest.Obsidian || SkyBlock.dungeonFloor.toString() != "M4")) { + if (config.blockLowReroll && rewardChest != RewardChest.Bedrock && (rewardChest != RewardChest.Obsidian || SBLocation.dungeonFloor.toString() != "M4")) { UChat.chat("§cBlocked reroll! This low-tier chest should not be rerolled.".withModPrefix()) event.isCanceled = true return @@ -58,11 +58,9 @@ object AutoBuyChest { } } - - @SubscribeEvent fun onGuiOpen(event: GuiOpenEvent) { - if (SkyBlock.area != Area.Dungeon) return + if (SBLocation.area != Area.Dungeon) return if (event.gui == null) return val chest = event.gui.chest val chestName = chest?.lowerChestInventory?.name @@ -82,7 +80,7 @@ object AutoBuyChest { @SubscribeEvent fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { - if (SkyBlock.area != Area.Dungeon || config.autoBuyChest != 2 || rewardChest == null || hasLookedAtChest) return + if (SBLocation.area != Area.Dungeon || config.autoBuyChest != 2 || rewardChest == null || hasLookedAtChest) return val chest = event.gui?.chest ?: return if (rewardChest == RewardChest.Wood) { if (!hasOpenedChest) openChest(chest) diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt index 571cd7f..0e996e1 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/CloseChest.kt @@ -4,7 +4,7 @@ import AmbientAddons.Companion.config import AmbientAddons.Companion.mc import com.ambientaddons.events.ReceivePacketEvent import com.ambientaddons.utils.Area -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import net.minecraft.network.play.client.C0DPacketCloseWindow import net.minecraft.network.play.server.S2DPacketOpenWindow import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object CloseChest { @SubscribeEvent fun onOpenWindow(event: ReceivePacketEvent) { - if (!config.closeSecretChests || SkyBlock.area != Area.Dungeon) return + if (!config.closeSecretChests || SBLocation.area != Area.Dungeon) return if (event.packet !is S2DPacketOpenWindow) return if (event.packet.windowTitle.unformattedText == "Chest") { mc.netHandler.networkManager.sendPacket(C0DPacketCloseWindow(event.packet.windowId)) diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt index 258d799..5019151 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonHighlights.kt @@ -4,9 +4,8 @@ import AmbientAddons.Companion.config import AmbientAddons.Companion.mc import com.ambientaddons.utils.Area import com.ambientaddons.utils.Extensions.skyblockID -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import com.ambientaddons.utils.render.EntityUtils -import gg.essential.universal.UChat import net.minecraft.entity.Entity import net.minecraft.entity.boss.EntityWither import net.minecraft.entity.item.EntityArmorStand @@ -25,20 +24,20 @@ import java.util.* object DungeonHighlights { private val markedArmorStands = mutableSetOf<EntityArmorStand>() private val starredMobs = mutableSetOf<Entity>() - private var nearIdkmansry = false + private var nearIdkmansry = false private val idkmansry = UUID.fromString("93ce1cad-833f-46ff-a124-b66d2b99c4fd") @SubscribeEvent fun onWorldUnload(event: WorldEvent.Unload) { markedArmorStands.clear() starredMobs.clear() + nearIdkmansry = false } @SubscribeEvent fun onRenderWorld(event: RenderWorldLastEvent) { - if (SkyBlock.area != Area.Dungeon) return - nearIdkmansry = false + if (SBLocation.area != Area.Dungeon) return mc.theWorld.loadedEntityList.forEach { entity -> if (entity is EntityArmorStand && entity.customNameTag.contains("✯") && !markedArmorStands.contains(entity)) { if (config.starredHighlight == 0) return@forEach diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt index 3defe7c..76488b1 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/DungeonReady.kt @@ -6,9 +6,8 @@ import com.ambientaddons.utils.Extensions.chest import com.ambientaddons.utils.Extensions.items import com.ambientaddons.utils.Extensions.stripControlCodes import com.ambientaddons.utils.Area -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import com.ambientaddons.utils.dungeon.DungeonPlayers -import gg.essential.universal.UChat import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -28,7 +27,7 @@ object DungeonReady { @SubscribeEvent fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { - if (config.autoReady == 0 || SkyBlock.area != Area.Dungeon) return + if (config.autoReady == 0 || SBLocation.area != Area.Dungeon) return val chest = event.gui?.chest ?: return val chestName = chest.lowerChestInventory.name if (chestName == "Start Dungeon?" && !hasClickedStart) { diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt index 6f2281e..438ad67 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/IgnoreCarpet.kt @@ -1,11 +1,11 @@ package com.ambientaddons.features.dungeon import AmbientAddons.Companion.config -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation object IgnoreCarpet { fun shouldIgnoreCarpet(): Boolean { - if (!SkyBlock.inSkyblock) return false + if (!SBLocation.inSkyblock) return false return if (AmbientAddons.isInitialized()) config.ignoreCarpet else false } }
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt index 9ff5d48..7cce15d 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/ShortbowClicker.kt @@ -3,7 +3,7 @@ package com.ambientaddons.features.dungeon import AmbientAddons.Companion.config import AmbientAddons.Companion.mc import com.ambientaddons.utils.Extensions.skyblockID -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.roundToLong @@ -15,7 +15,7 @@ object ShortbowClicker { @SubscribeEvent fun onRender(event: RenderWorldLastEvent) { - if (!SkyBlock.inSkyblock) return + if (!SBLocation.inSkyblock) return if (config.terminatorCps == 0) return if (!mc.gameSettings.keyBindUseItem.isKeyDown) return val itemStack = mc.thePlayer?.inventory?.getCurrentItem() diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt index 74b23e7..f867b3f 100644 --- a/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/terminals/MelodyHelper.kt @@ -6,7 +6,7 @@ import com.ambientaddons.events.GuiContainerEvent import com.ambientaddons.utils.Extensions.chest import com.ambientaddons.utils.Extensions.items import com.ambientaddons.utils.Extensions.stripControlCodes -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.client.event.GuiOpenEvent import net.minecraftforge.event.world.WorldEvent @@ -27,7 +27,7 @@ object MelodyHelper { @SubscribeEvent fun onChat(event: ClientChatReceivedEvent) { - if (SkyBlock.dungeonFloor?.floor != 7) return + if (SBLocation.dungeonFloor?.floor != 7) return val unformatted = event.message.unformattedText.stripControlCodes() if (completedStageRegex.matches(unformatted)) { hasSaidMeowlody = false @@ -44,7 +44,7 @@ object MelodyHelper { @SubscribeEvent fun onGuiOpen(event: GuiOpenEvent) { - if (SkyBlock.dungeonFloor?.floor != 7) return + if (SBLocation.dungeonFloor?.floor != 7) return if (event.gui == null) return if (event.gui.chest?.lowerChestInventory?.name == "Click the button on time!") { if (!hasSaidMeowlody && config.melodyAnnouncement.isNotBlank()) { @@ -56,7 +56,7 @@ object MelodyHelper { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { - if (SkyBlock.dungeonFloor?.floor != 7) return + if (SBLocation.dungeonFloor?.floor != 7) return val chest = event.gui.chest?.lowerChestInventory if (chest?.name != "Click the button on time!" || isThrottled) return val colors = chest.items.map { it?.itemDamage } diff --git a/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt b/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt index b7e5fad..9a0a4f9 100644 --- a/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt +++ b/src/main/kotlin/com/ambientaddons/features/keybinds/SendLastMessageKeybind.kt @@ -3,7 +3,7 @@ package com.ambientaddons.features.keybinds import AmbientAddons.Companion.keyBinds import AmbientAddons.Companion.mc import com.ambientaddons.events.MessageSentEvent -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent @@ -12,7 +12,7 @@ object SendLastMessageKeybind { @SubscribeEvent fun onSendChat(event: MessageSentEvent) { - if (!SkyBlock.onHypixel) return + if (!SBLocation.onHypixel) return if (event.message.startsWith("/pc", ignoreCase = true)) { lastMessage = event.message.runCatching { substring(4 until event.message.length) @@ -24,7 +24,7 @@ object SendLastMessageKeybind { @SubscribeEvent fun onKey(event: InputEvent.KeyInputEvent) { - if (!SkyBlock.onHypixel) return + if (!SBLocation.onHypixel) return if (keyBinds["spamKey"]!!.isPressed && lastMessage != null) { mc.thePlayer.sendChatMessage("/pc $lastMessage") } diff --git a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt index b0689c4..2e8be9e 100644 --- a/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt +++ b/src/main/kotlin/com/ambientaddons/features/misc/BonzoMask.kt @@ -5,7 +5,7 @@ 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.SBLocation import com.ambientaddons.utils.render.OverlayUtils import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -21,7 +21,7 @@ object BonzoMask { @SubscribeEvent fun onChat(event: ClientChatReceivedEvent) { - if (!SkyBlock.inSkyblock) return + if (!SBLocation.inSkyblock) return val didMaskProc = when (event.message.unformattedText.stripControlCodes()) { secondWindString -> { spiritMaskProc = System.currentTimeMillis() @@ -44,7 +44,7 @@ object BonzoMask { @SubscribeEvent fun onRenderItemOverlay(event: ItemOverlayEvent) { - if (!SkyBlock.inSkyblock) return + if (!SBLocation.inSkyblock) return val durability = when (event.item?.skyblockID) { "BONZO_MASK" -> (System.currentTimeMillis() - bonzoMaskProc) / 180000.0 "STARRED_BONZO_MASK" -> (System.currentTimeMillis() - fraggedBonzoMaskProc) / 180000.0 diff --git a/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt b/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt index 60f0f8f..3deff17 100644 --- a/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt +++ b/src/main/kotlin/com/ambientaddons/features/misc/CancelInteractions.kt @@ -3,7 +3,7 @@ package com.ambientaddons.features.misc import AmbientAddons.Companion.config import AmbientAddons.Companion.mc import com.ambientaddons.utils.Area -import com.ambientaddons.utils.SkyBlock +import com.ambientaddons.utils.SBLocation import net.minecraft.init.Blocks import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -11,8 +11,8 @@ 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 (!SBLocation.inSkyblock) return + if (!config.cancelInteractions || SBLocation.area == Area.PrivateIsland) return if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { if (mc.theWorld?.getBlockState(event.pos)?.block == Blocks.hopper) { event.isCanceled = true diff --git a/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt b/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt index 469d6fe..d9be1dd 100644 --- a/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt +++ b/src/main/kotlin/com/ambientaddons/features/misc/KuudraReady.kt @@ -7,8 +7,7 @@ import com.ambientaddons.utils.Extensions.chest import com.ambientaddons.utils.Extensions.items import com.ambientaddons.utils.Extensions.lore import com.ambientaddons.utils.Extensions.stripControlCodes -import com.ambientaddons.utils.SkyBlock -import com.ambientaddons.utils.dungeon.DungeonPlayers +import com.ambientaddons.utils.SBLocation import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -23,7 +22,7 @@ object KuudraReady { @SubscribeEvent fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { - if (!config.kuudraReady || SkyBlock.area != Area.Kuudra) return + if (!config.kuudraReady || SBLocation.area != Area.Kuudra) return val chest = event.gui?.chest ?: return val chestName = chest.lowerChestInventory.name if (chestName == "Ready Up" && !hasClickedReady) { |