From fcd49c8b59f9c76008b5112a2e296c164b168842 Mon Sep 17 00:00:00 2001 From: Appability Date: Mon, 17 Oct 2022 16:11:40 -0700 Subject: trapper esp --- .../kotlin/com/ambientaddons/utils/SBLocation.kt | 89 ++++++++++++++++++++ .../kotlin/com/ambientaddons/utils/SkyBlock.kt | 90 --------------------- .../ambientaddons/utils/dungeon/DungeonPlayers.kt | 4 +- .../com/ambientaddons/utils/render/EntityUtils.kt | 94 ++++++++++++++++++++++ 4 files changed, 185 insertions(+), 92 deletions(-) create mode 100644 src/main/kotlin/com/ambientaddons/utils/SBLocation.kt delete mode 100644 src/main/kotlin/com/ambientaddons/utils/SkyBlock.kt (limited to 'src/main/kotlin/com/ambientaddons/utils') diff --git a/src/main/kotlin/com/ambientaddons/utils/SBLocation.kt b/src/main/kotlin/com/ambientaddons/utils/SBLocation.kt new file mode 100644 index 0000000..bfd35eb --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/SBLocation.kt @@ -0,0 +1,89 @@ +package com.ambientaddons.utils + +import AmbientAddons.Companion.mc +import com.ambientaddons.utils.DungeonFloor.Companion.toDungeonFloor +import com.ambientaddons.utils.Extensions.cleanSB +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.Extensions.substringBetween +import com.ambientaddons.utils.TabListUtils.fetchTabEntries +import net.minecraft.scoreboard.Score +import net.minecraft.scoreboard.ScorePlayerTeam +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.network.FMLNetworkEvent + +object SBLocation { + private var areaRegex = Regex("^(?:Area|Dungeon): ([\\w ].+)\$") + var onHypixel = false + var inSkyblock = false + var area: Area? = null + private var areaString: String? = null + var dungeonFloor: DungeonFloor? = null + var ticks = 0 + + @SubscribeEvent + fun onWorldUnload(event: WorldEvent.Unload) { + inSkyblock = false + dungeonFloor = null + area = null + } + + @SubscribeEvent + fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) { + onHypixel = mc.runCatching { + !event.isLocal && ((thePlayer?.clientBrand?.lowercase()?.contains("hypixel") + ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel")) == true) + }.getOrDefault(false) + } + + @SubscribeEvent + fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + onHypixel = false + } + + // from Skytils, under AGPL 3.0 + fun fetchScoreboardLines(): List { + val scoreboard = mc.theWorld?.scoreboard ?: return emptyList() + val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return emptyList() + val scores = scoreboard.getSortedScores(objective).filter { input: Score? -> + input != null && input.playerName != null && !input.playerName + .startsWith("#") + }.take(15) + return scores.map { + ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName).cleanSB() + }.asReversed() + } + + // modified from Harry282/Skyblock-Client, under AGPL 3.0 + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (!onHypixel || event.phase != TickEvent.Phase.START) return + if (ticks % 10 == 0) { + val title = mc.theWorld?.scoreboard?.getObjectiveInDisplaySlot(1)?.displayName?.cleanSB() + if (!inSkyblock) { + inSkyblock = title?.contains("SKYBLOCK") == true + } + if (inSkyblock) { + if (areaString == null) { + val tab = fetchTabEntries() + val areaString = tab.firstNotNullOfOrNull { areaRegex.find(it.text.stripControlCodes()) }?.let { + it.groupValues.getOrNull(1) + } + area = Area.fromString(areaString) + } + if (area == Area.Dungeon && dungeonFloor == null) { + val dungeonLine = fetchScoreboardLines().find { + it.run { contains("The Catacombs (") && !contains("Queue") } + } + dungeonFloor = dungeonLine?.substringBetween("(", ")")?.toDungeonFloor() + } + } + } + ticks++ + } + + override fun toString(): String = + "onHypixel: $onHypixel, inSkyblock: $inSkyblock, location: $area, floor: $dungeonFloor" + +} \ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/utils/SkyBlock.kt b/src/main/kotlin/com/ambientaddons/utils/SkyBlock.kt deleted file mode 100644 index a6bbd57..0000000 --- a/src/main/kotlin/com/ambientaddons/utils/SkyBlock.kt +++ /dev/null @@ -1,90 +0,0 @@ -package com.ambientaddons.utils - -import AmbientAddons.Companion.mc -import com.ambientaddons.utils.DungeonFloor.Companion.toDungeonFloor -import com.ambientaddons.utils.Extensions.cleanSB -import com.ambientaddons.utils.Extensions.stripControlCodes -import com.ambientaddons.utils.Extensions.substringBetween -import com.ambientaddons.utils.TabListUtils.fetchTabEntries -import gg.essential.universal.UChat -import net.minecraft.scoreboard.Score -import net.minecraft.scoreboard.ScorePlayerTeam -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.network.FMLNetworkEvent - -object SkyBlock { - private var areaRegex = Regex("^(?:Area|Dungeon): ([\\w ].+)\$") - var onHypixel = false - var inSkyblock = false - var area: Area? = null - private var areaString: String? = null - var dungeonFloor: DungeonFloor? = null - var ticks = 0 - - @SubscribeEvent - fun onWorldUnload(event: WorldEvent.Unload) { - inSkyblock = false - dungeonFloor = null - area = null - } - - @SubscribeEvent - fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) { - onHypixel = mc.runCatching { - !event.isLocal && ((thePlayer?.clientBrand?.lowercase()?.contains("hypixel") - ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel")) == true) - }.getOrDefault(false) - } - - @SubscribeEvent - fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { - onHypixel = false - } - - // from Skytils, under AGPL 3.0 - fun fetchScoreboardLines(): List { - val scoreboard = mc.theWorld?.scoreboard ?: return emptyList() - val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return emptyList() - val scores = scoreboard.getSortedScores(objective).filter { input: Score? -> - input != null && input.playerName != null && !input.playerName - .startsWith("#") - }.take(15) - return scores.map { - ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName).cleanSB() - }.asReversed() - } - - // modified from Harry282/Skyblock-Client, under AGPL 3.0 - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!onHypixel || event.phase != TickEvent.Phase.START) return - if (ticks % 10 == 0) { - val title = mc.theWorld?.scoreboard?.getObjectiveInDisplaySlot(1)?.displayName?.cleanSB() - if (!inSkyblock) { - inSkyblock = title?.contains("SKYBLOCK") == true - } - if (inSkyblock) { - if (areaString == null) { - val tab = fetchTabEntries() - val areaString = tab.firstNotNullOfOrNull { areaRegex.find(it.text.stripControlCodes()) }?.let { - it.groupValues.getOrNull(1) - } - area = Area.fromString(areaString) - } - if (area == Area.Dungeon && dungeonFloor == null) { - val dungeonLine = fetchScoreboardLines().find { - it.run { contains("The Catacombs (") && !contains("Queue") } - } - dungeonFloor = dungeonLine?.substringBetween("(", ")")?.toDungeonFloor() - } - } - } - ticks++ - } - - override fun toString(): String = - "onHypixel: $onHypixel, inSkyblock: $inSkyblock, location: $area, floor: $dungeonFloor" - -} \ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/utils/dungeon/DungeonPlayers.kt b/src/main/kotlin/com/ambientaddons/utils/dungeon/DungeonPlayers.kt index e57443d..b10c58a 100644 --- a/src/main/kotlin/com/ambientaddons/utils/dungeon/DungeonPlayers.kt +++ b/src/main/kotlin/com/ambientaddons/utils/dungeon/DungeonPlayers.kt @@ -2,7 +2,7 @@ package com.ambientaddons.utils.dungeon 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.TabListUtils import com.ambientaddons.utils.text import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -16,7 +16,7 @@ object DungeonPlayers { @SubscribeEvent fun onTick(event: ClientTickEvent) { - if (SkyBlock.area != Area.Dungeon) return + if (SBLocation.area != Area.Dungeon) return if (ticks % 10 == 0) { val rawPlayers = TabListUtils.fetchTabEntries().let { tabEntries -> playerSlots.map { tabEntries[it].text.stripControlCodes() } diff --git a/src/main/kotlin/com/ambientaddons/utils/render/EntityUtils.kt b/src/main/kotlin/com/ambientaddons/utils/render/EntityUtils.kt index b3abbcf..c5bc2e9 100644 --- a/src/main/kotlin/com/ambientaddons/utils/render/EntityUtils.kt +++ b/src/main/kotlin/com/ambientaddons/utils/render/EntityUtils.kt @@ -1,14 +1,21 @@ package com.ambientaddons.utils.render import AmbientAddons.Companion.mc +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.entity.Entity import net.minecraft.entity.player.EntityPlayer import net.minecraft.util.AxisAlignedBB import net.minecraft.util.BlockPos +import net.minecraft.util.MathHelper +import net.minecraft.util.ResourceLocation import org.lwjgl.opengl.GL11.* import java.awt.Color +import kotlin.math.cos +import kotlin.math.sin + // diretly stolen from Harry282/Skyblock-Client object EntityUtils { @@ -145,6 +152,93 @@ object EntityUtils { glPopMatrix() } + private val beaconBeam = ResourceLocation("textures/entity/beacon_beam.png") + + // from Moulberry/NotEnoughUpdates under LGPL 3.0, presumably from Mojang + fun renderBeaconBeam( + x: Double, y: Double, z: Double, color: Color, alpha: Float, + partialTicks: Float, esp: Boolean + ) { + val rgb = color.rgb + val height = 300 + val bottomOffset = 0 + val topOffset = bottomOffset + height + val tessellator = Tessellator.getInstance() + val worldrenderer = tessellator.worldRenderer + if (esp) { + GlStateManager.disableDepth() + } + Minecraft.getMinecraft().textureManager.bindTexture(beaconBeam) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT.toFloat()) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT.toFloat()) + GlStateManager.disableLighting() + GlStateManager.enableCull() + GlStateManager.enableTexture2D() + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ZERO) + GlStateManager.enableBlend() + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO) + val time = Minecraft.getMinecraft().theWorld.totalWorldTime + partialTicks.toDouble() + val d1 = MathHelper.func_181162_h(-time * 0.2 - MathHelper.floor_double(-time * 0.1).toDouble()) + val r = (rgb shr 16 and 0xFF) / 255f + val g = (rgb shr 8 and 0xFF) / 255f + val b = (rgb and 0xFF) / 255f + val d2 = time * 0.025 * -1.5 + val d4 = 0.5 + cos(d2 + 2.356194490192345) * 0.2 + val d5 = 0.5 + sin(d2 + 2.356194490192345) * 0.2 + val d6 = 0.5 + cos(d2 + Math.PI / 4.0) * 0.2 + val d7 = 0.5 + sin(d2 + Math.PI / 4.0) * 0.2 + val d8 = 0.5 + cos(d2 + 3.9269908169872414) * 0.2 + val d9 = 0.5 + sin(d2 + 3.9269908169872414) * 0.2 + val d10 = 0.5 + cos(d2 + 5.497787143782138) * 0.2 + val d11 = 0.5 + sin(d2 + 5.497787143782138) * 0.2 + val d14 = -1.0 + d1 + val d15 = height.toDouble() * 2.5 + d14 + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR) + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0, d14).color(r, g, b, 1.0f).endVertex() + worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0, d15).color(r, g, b, 1.0f * alpha).endVertex() + tessellator.draw() + GlStateManager.disableCull() + val d12 = -1.0 + d1 + val d13 = height + d12 + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR) + worldrenderer.pos(x + 0.2, y + topOffset, z + 0.2).tex(1.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.2).tex(1.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.2).tex(0.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.8, y + topOffset, z + 0.2).tex(0.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + worldrenderer.pos(x + 0.8, y + topOffset, z + 0.8).tex(1.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.8).tex(1.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.8).tex(0.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.2, y + topOffset, z + 0.8).tex(0.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + worldrenderer.pos(x + 0.8, y + topOffset, z + 0.2).tex(1.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.2).tex(1.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.8).tex(0.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.8, y + topOffset, z + 0.8).tex(0.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + worldrenderer.pos(x + 0.2, y + topOffset, z + 0.8).tex(1.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.8).tex(1.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.2).tex(0.0, d12).color(r, g, b, 0.25f).endVertex() + worldrenderer.pos(x + 0.2, y + topOffset, z + 0.2).tex(0.0, d13).color(r, g, b, 0.25f * alpha).endVertex() + tessellator.draw() + GlStateManager.disableLighting() + GlStateManager.enableTexture2D() + if (esp) { + GlStateManager.enableDepth() + } + } + fun drawEntityBox(entity: Entity, color: Color, outline: Boolean, fill: Boolean, esp: Boolean, partialTicks: Float) { if (!outline && !fill) return val renderManager = mc.renderManager -- cgit