diff options
6 files changed, 77 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index a5dab1a48..596ea7d9c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -66,6 +66,7 @@ import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.PacketTest import at.hannibal2.skyhanni.test.SkyHanniTestCommand import at.hannibal2.skyhanni.test.TestBingo +import at.hannibal2.skyhanni.test.command.CopyNearbyParticlesCommand import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded import at.hannibal2.skyhanni.utils.TabListData @@ -265,6 +266,7 @@ class SkyHanniMod { loadModule(ChumBucketHider()) loadModule(GardenRecentTeleportPadsDisplay()) loadModule(InquisitorWaypointShare) + loadModule(CopyNearbyParticlesCommand) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 985692b57..9c5e3e04e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -49,6 +49,7 @@ object Commands { registerCommand("shcopytablist") { CopyTabListCommand.command(it) } registerCommand("shcopyscoreboard") { CopyScoreboardCommand.command(it) } registerCommand("shcopyitem") { CopyItemCommand.command(it) } + registerCommand("shcopyparticles") { CopyNearbyParticlesCommand.command(it) } registerCommand("shconfigsave") { SkyHanniMod.configManager.saveConfig("manual-command") } registerCommand("shmarkplayer") { MarkedPlayerManager.command(it) } registerCommand("shtestpacket") { PacketTest.toggle() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index cfcb4244a..ced9a3a5b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -214,7 +214,3 @@ class GriffinBurrowParticleFinder { // } } } - -private fun S2APacketParticles.toLorenzVec(): LorenzVec { - return LorenzVec(xCoordinate, yCoordinate, zCoordinate) -} diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyParticlesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyParticlesCommand.kt new file mode 100644 index 000000000..8e4290434 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyParticlesCommand.kt @@ -0,0 +1,67 @@ +package at.hannibal2.skyhanni.test.command + +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.LorenzUtils.round +import net.minecraft.network.play.server.S2APacketParticles +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +// note: Each particle is copied anywhere between 1-3 times. Different each time. Should not affect using this for debugging or developing +object CopyNearbyParticlesCommand { + private var searchRadius = 0 + private var saveNextTick = false + private var searchTime: Long = 0 + private val resultList = mutableListOf<String>() + private var tickTime: Long = 0 + private var counter = 0 + + fun command(args: Array<String>) { + searchRadius = 10 + if (args.size == 1) { + searchRadius = args[0].toInt() + } + saveNextTick = true + searchTime = System.currentTimeMillis() + resultList.clear() + counter = 0 + tickTime = 0L + } + + @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) + fun onChatPacket(event: PacketEvent.ReceiveEvent) { + if (!saveNextTick) return + // command was sent in or around a tick so skipping the tick + if (System.currentTimeMillis() <= searchTime + 5) return + + if (resultList.isEmpty() && tickTime == 0L) tickTime = System.currentTimeMillis() + + if (System.currentTimeMillis() > tickTime + 30) { + if (counter == 0) LorenzUtils.chat("§e[SkyHanni] No particles found nearby, try a larger search radius") else { + val string = resultList.joinToString("\n") + OSUtils.copyToClipboard(string) + LorenzUtils.chat("§e[SkyHanni] $counter particles copied into the clipboard!") + } + saveNextTick = false + return + } + + val packet = event.packet + if (packet is S2APacketParticles) { + val location = packet.toLorenzVec().round(2) + if (LocationUtils.playerLocation().distance(location) > searchRadius) return + val offset = LorenzVec(packet.xOffset, packet.yOffset, packet.zOffset).round(2) + resultList.add("particle type: ${packet.particleType}") + resultList.add("particle location: $location") + resultList.add("distance from player: ${LocationUtils.playerLocation().distance(location).round(2)}") + resultList.add("particle offset: $offset") + resultList.add("is long distance: ${packet.isLongDistance}") + resultList.add("particle count: ${packet.particleCount}") + resultList.add("particle speed: ${packet.particleSpeed}") + resultList.add("particle arguments: ${packet.particleArgs.asList()}") + resultList.add("") + resultList.add("") + counter ++ + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt index 65ec85d37..177b92b7d 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt @@ -12,7 +12,7 @@ object CopyTabListCommand { val noColor = args.size == 1 && args[0] == "true" for (line in TabListData.getTabList()) { val tabListLine = if (noColor) line.removeColor() else line - resultList.add("'$tabListLine'") + if (tabListLine != "") resultList.add("'$tabListLine'") } val string = resultList.joinToString("\n") OSUtils.copyToClipboard(string) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index 4c110cb6c..8ac086718 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.utils.LorenzUtils.round import net.minecraft.entity.Entity +import net.minecraft.network.play.server.S2APacketParticles import net.minecraft.util.BlockPos import net.minecraft.util.Rotations import net.minecraft.util.Vec3 @@ -92,6 +94,8 @@ data class LorenzVec( fun equalsIgnoreY(other: LorenzVec) = x == other.x && z == other.z + fun round(decimals: Int) = LorenzVec(x.round(decimals), y.round(decimals), z.round(decimals)) + companion object { fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec { val yaw: Double = (yaw + 90) * Math.PI / 180 @@ -127,6 +131,8 @@ fun Vec3.toLorenzVec(): LorenzVec = LorenzVec(xCoord, yCoord, zCoord) fun Rotations.toLorenzVec(): LorenzVec = LorenzVec(x, y, z) +fun S2APacketParticles.toLorenzVec() = LorenzVec(xCoordinate, yCoordinate, zCoordinate) + fun Array<Double>.toLorenzVec(): LorenzVec { return LorenzVec(this[0], this[1], this[2]) }
\ No newline at end of file |