From ec28950b5f49a0cb068be17a48b76d97ca6dcba7 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars <48456413+ItCameFr0mMars@users.noreply.github.com> Date: Mon, 28 Mar 2022 10:38:30 -0400 Subject: [PATCH 01/14] tee hee trollage --- .../kotlin/com/lambda/client/module/modules/player/Timer.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt index 2e75079c7..e23fc62ad 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt @@ -14,7 +14,7 @@ object Timer : Module( modulePriority = 500 ) { private val slow by setting("Slow Mode", false) - private val tickNormal by setting("Tick N", 2.0f, 1f..10f, 0.1f, { !slow }) + private val tickNormal by setting("Tick N", 2.0f, 1f..2000f, 0.1f, { !slow }) private val tickSlow by setting("Tick S", 8f, 1f..10f, 0.1f, { slow }) init { @@ -29,4 +29,4 @@ object Timer : Module( modifyTimer(50.0f / multiplier) } } -} \ No newline at end of file +} From 0ef88d4bf3274c48f57a0d1ec773328c3c237255 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars <48456413+ItCameFr0mMars@users.noreply.github.com> Date: Mon, 28 Mar 2022 10:38:53 -0400 Subject: [PATCH 02/14] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8b93bd42d..c18319d9a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ ![GitHub repo size](https://img.shields.io/github/repo-size/lambda-client/lambda) ![Lines of code](https://img.shields.io/tokei/lines/github/lambda-client/lambda?color=lightcoral&label=lines%20of%20code) +#MARS EDITION + Lambda is a free, open-source, Minecraft 1.12.2 utility mod made for the anarchy experience. A visionary plugin system that allows additional modules to be added, without the need to create a fork! Customize your experience, and improve your efficiency! From 0609fc4613d1c3ebe3a275b2784ca69490ab4462 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars <48456413+ItCameFr0mMars@users.noreply.github.com> Date: Thu, 31 Mar 2022 15:50:47 -0400 Subject: [PATCH 03/14] Update NewChunks.kt --- .../client/module/modules/render/NewChunks.kt | 238 +++++++++++++++++- 1 file changed, 228 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index a8641d4a2..4b06e02e9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -1,5 +1,6 @@ package com.lambda.client.module.modules.render +import com.lambda.client.LambdaMod import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.RenderRadarEvent import com.lambda.client.event.events.RenderWorldEvent @@ -21,13 +22,22 @@ import com.lambda.client.util.threads.safeAsyncListener import com.lambda.client.util.threads.safeListener import com.lambda.client.event.listener.asyncListener import kotlinx.coroutines.runBlocking +import net.minecraft.client.Minecraft import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.network.play.server.SPacketChunkData import net.minecraft.util.math.ChunkPos +import net.minecraft.world.chunk.Chunk import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.fml.common.gameevent.TickEvent +import org.apache.commons.lang3.SystemUtils import org.lwjgl.opengl.GL11.GL_LINE_LOOP import org.lwjgl.opengl.GL11.glLineWidth +import java.io.* +import java.nio.file.Files +import java.nio.file.Path +import java.text.SimpleDateFormat +import java.util.* +import kotlin.collections.LinkedHashSet object NewChunks : Module( name = "NewChunks", @@ -36,6 +46,11 @@ object NewChunks : Module( ) { private val relative by setting("Relative", false, description = "Renders the chunks at relative Y level to player") private val renderMode by setting("Render Mode", RenderMode.BOTH) + private val saveNewChunks by setting("Save New Chunks", false) + val saveOption by setting("SaveOption", saveOption.EXTRA_FOLDER, { saveNewChunks }) + val saveInRegionFolder by setting("InRegion", false, { saveNewChunks }) + val alsoSaveNormalCoords by setting("SaveNormalCoords", false, { saveNewChunks }) + private var closeFile by setting("CloseFile", false, { saveNewChunks}) private val chunkGridColor by setting("Grid Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) private val distantChunkColor by setting("Distant Chunk Color", ColorHolder(100, 100, 100, 100), true, { renderMode != RenderMode.WORLD }, "Chunks that are not in render distance and not in baritone cache") private val newChunkColor by setting("New Chunk Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) @@ -44,13 +59,8 @@ object NewChunks : Module( private val thickness by setting("Thickness", 1.5f, 0.1f..4.0f, 0.1f, description = "Thickness of the highlighting square") private val range by setting("Render Range", 512, 64..2048, 32, description = "Maximum range for chunks to be highlighted") private val autoClear by setting("Auto Clear", false, description = "Clears the new chunks every 10 minutes") - private val removeMode by setting("Remove Mode", RemoveMode.MAX_NUMBER, description = "Mode to use for removing chunks") - private val maxNumber by setting("Max Number", 5000, 1000..10000, 500, { removeMode == RemoveMode.MAX_NUMBER }, description = "Maximum number of chunks to keep") - - @Suppress("unused") - private enum class RemoveMode { - NEVER, UNLOAD, MAX_NUMBER - } + private val removeMode by setting("Remove Mode", removeMode.MAX_NUMBER, description = "Mode to use for removing chunks") + private val maxNumber by setting("Max Number", 5000, 1000..10000, 500, { removeMode == removeMode.MAX_NUMBER }, description = "Maximum number of chunks to keep") enum class RenderMode { WORLD, RADAR, BOTH @@ -58,6 +68,8 @@ object NewChunks : Module( private val timer = TickTimer(TimeUnit.MINUTES) private val chunks = LinkedHashSet() + private var logWriter: PrintWriter? = null + private var lastSetting = LastSetting() init { onEnable { @@ -147,7 +159,7 @@ object NewChunks : Module( onMainThread { if (chunks.add(chunk.pos)) { - if (removeMode == RemoveMode.MAX_NUMBER && chunks.size > maxNumber) { + if (removeMode == removeMode.MAX_NUMBER && chunks.size > maxNumber) { chunks.maxByOrNull { player.distanceTo(it) }?.let { chunks.remove(it) } @@ -158,7 +170,7 @@ object NewChunks : Module( asyncListener { onMainThread { - if (removeMode == RemoveMode.UNLOAD) { + if (removeMode == removeMode.UNLOAD) { chunks.remove(it.chunk.pos) } } @@ -175,4 +187,210 @@ object NewChunks : Module( private fun getChunkPos(x: Int, z: Int, playerOffset: Vec2d, scale: Float): Vec2d { return Vec2d((x shl 4).toDouble(), (z shl 4).toDouble()).minus(playerOffset).div(scale.toDouble()) } -} \ No newline at end of file + private fun saveNewChunk(chunk: Chunk) { + saveNewChunk(testAndGetLogWriter(), getNewChunkInfo(chunk)) + } + + private fun getNewChunkInfo(chunk: Chunk): String { + var rV = String.format("%d,%d,%d", System.currentTimeMillis(), chunk.x, chunk.z) + if (alsoSaveNormalCoords) { + rV += String.format(",%d,%d", chunk.x * 16 + 8, chunk.z * 16 + 8) + } + return rV + } + + private fun testAndGetLogWriter(): PrintWriter? { + if (lastSetting.testChangeAndUpdate()) { + logWriterClose() + logWriterOpen() + } + return logWriter + } + + private fun logWriterClose() { + if (logWriter != null) { + logWriter!!.close() + logWriter = null + lastSetting = LastSetting() // what if the settings stay the same? + } + } + + private fun logWriterOpen() { + val filepath = path.toString() + try { + var logWriter = PrintWriter(BufferedWriter(FileWriter(filepath, true)), true) + var head = "timestamp,ChunkX,ChunkZ" + if (alsoSaveNormalCoords) { + head += ",x coordinate,z coordinate" + } + logWriter!!.println(head) + } catch (e: Exception) { + e.printStackTrace() + LambdaMod.LOG.error(chatName + " some exception happened when trying to start the logging -> " + e.message) + MessageSendHelper.sendErrorMessage(chatName + " onLogStart: " + e.message) + } + } + + private val path: Path + get() { + // code from baritone (https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/cache/WorldProvider.java) + + var file: File? = null + val dimension = mc.player.dimension + + // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file + if (mc.isSingleplayer) { + try { + file = mc.integratedServer?.getWorld(dimension)?.chunkSaveLocation + } catch (e: Exception) { + e.printStackTrace() + LambdaMod.LOG.error("some exception happened when getting canonicalFile -> " + e.message) + MessageSendHelper.sendErrorMessage(chatName + " onGetPath: " + e.message) + } + + // Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world + if (file?.toPath()?.relativize(mc.gameDir.toPath())?.nameCount != 2) { + // subdirectory of the main save directory for this world + file = file?.parentFile + } + } else { // Otherwise, the server must be remote... + file = makeMultiplayerDirectory().toFile() + } + + // We will actually store the world data in a subfolder: "DIM" + if (dimension != 0) { // except if it's the overworld + file = File(file, "DIM$dimension") + } + + // maybe we want to save it in region folder + if (saveInRegionFolder) { + file = File(file, "region") + } + file = File(file, "newChunkLogs") + val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Date()) + file = File(file, mc.getSession().username + "_" + date + ".csv") // maybe dont safe the name actually. But I also dont want to make another option... + val rV = file.toPath() + try { + if (!Files.exists(rV)) { // ovsly always... + Files.createDirectories(rV.parent) + Files.createFile(rV) + } + } catch (e: IOException) { + e.printStackTrace() + LambdaMod.LOG.error("some exception happened when trying to make the file -> " + e.message) + MessageSendHelper.sendErrorMessage(chatName + " onCreateFile: " + e.message) + } + return rV + } + + private fun makeMultiplayerDirectory(): Path { + var rV = Minecraft.getMinecraft().gameDir + var folderName: String + when (saveOption) { + saveOption.LITE_LOADER_WDL -> { + folderName = mc.currentServerData?.serverName ?: "Offline" + rV = File(rV, "saves") + rV = File(rV, folderName) + } + saveOption.NHACK_WDL -> { + folderName = nHackInetName + rV = File(rV, "config") + rV = File(rV, "wdl-saves") + rV = File(rV, folderName) + + // extra because name might be different + if (!rV.exists()) { + MessageSendHelper.sendWarningMessage("$chatName nhack wdl directory doesnt exist: $folderName") + MessageSendHelper.sendWarningMessage("$chatName creating the directory now. It is recommended to update the ip") + } + } + else -> { + folderName = mc.currentServerData?.serverName + "-" + mc.currentServerData?.serverIP + if (SystemUtils.IS_OS_WINDOWS) { + folderName = folderName.replace(":", "_") + } + rV = File(rV, "KAMI_NewChunks") + rV = File(rV, folderName) + } + } + return rV.toPath() + } + + // if there is no port then we have to manually include the standard port.. + private val nHackInetName: String + get() { + var folderName = mc.currentServerData?.serverIP ?: "Offline" + if (SystemUtils.IS_OS_WINDOWS) { + folderName = folderName.replace(":", "_") + } + if (hasNoPort(folderName)) { + folderName += "_25565" // if there is no port then we have to manually include the standard port.. + } + return folderName + } + + private fun hasNoPort(ip: String): Boolean { + if (!ip.contains("_")) { + return true + } + val sp = ip.split("_").toTypedArray() + val ending = sp[sp.size - 1] + // if it is numeric it means it might be a port... + return ending.toIntOrNull() != null + } + + private fun saveNewChunk(log: PrintWriter?, data: String) { + log!!.println(data) + } + + private class LastSetting { + var lastSaveOption: SaveOption? = null + var lastInRegion = false + var lastSaveNormal = false + var dimension = 0 + var ip: String? = null + fun testChangeAndUpdate(): Boolean { + if (testChange()) { + // so we dont have to do this process again next time + update() + return true + } + return false + } + + fun testChange(): Boolean { + // these somehow include the test whether its null + return saveOption != lastSaveOption + || saveInRegionFolder != lastInRegion + || alsoSaveNormalCoords != lastSaveNormal + || dimension != mc.player.dimension + || mc.currentServerData?.serverIP != ip + } + + private fun update() { + lastSaveOption = saveOption as SaveOption + lastInRegion = saveInRegionFolder + lastSaveNormal = alsoSaveNormalCoords + dimension = mc.player.dimension + ip = mc.currentServerData?.serverIP + } + private enum class SaveOption { + EXTRA_FOLDER, LITE_LOADER_WDL, NHACK_WDL + } + + @Suppress("unused") + private enum class RemoveMode { + UNLOAD, MAX_NUM, NEVER + } + + init { + closeFile.settingListener = SettingListeners { + if (closeFile) { + logWriterClose() + MessageSendHelper.sendChatMessage("$chatName Saved file!") + closeFile = false + } + } + } +} +} From 5c652824f2ead0a5155daa6ad83508d06d69dd9d Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars <48456413+ItCameFr0mMars@users.noreply.github.com> Date: Thu, 31 Mar 2022 15:51:38 -0400 Subject: [PATCH 04/14] Update NewChunks.kt --- .../kotlin/com/lambda/client/module/modules/render/NewChunks.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 4b06e02e9..4aee718a5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -384,7 +384,6 @@ object NewChunks : Module( } init { - closeFile.settingListener = SettingListeners { if (closeFile) { logWriterClose() MessageSendHelper.sendChatMessage("$chatName Saved file!") @@ -393,4 +392,3 @@ object NewChunks : Module( } } } -} From df99fa0d491512bfed36e2b415b870fc4df09417 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Thu, 31 Mar 2022 17:39:35 -0400 Subject: [PATCH 05/14] replace imports --- .../lambda/client/module/modules/render/NewChunks.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 4aee718a5..0374d71aa 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -32,11 +32,15 @@ import net.minecraftforge.fml.common.gameevent.TickEvent import org.apache.commons.lang3.SystemUtils import org.lwjgl.opengl.GL11.GL_LINE_LOOP import org.lwjgl.opengl.GL11.glLineWidth -import java.io.* +import java.io.BufferedWriter +import java.io.FileWriter +import java.io.IOException +import java.io.PrintWriter import java.nio.file.Files +import java.io.File import java.nio.file.Path import java.text.SimpleDateFormat -import java.util.* +import java.util.Date import kotlin.collections.LinkedHashSet object NewChunks : Module( @@ -367,8 +371,9 @@ object NewChunks : Module( || mc.currentServerData?.serverIP != ip } + private fun update() { - lastSaveOption = saveOption as SaveOption + lastSaveOption = saveOption lastInRegion = saveInRegionFolder lastSaveNormal = alsoSaveNormalCoords dimension = mc.player.dimension From e3ba4160c38126dd7411ef6bd59fc63db1708552 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Thu, 31 Mar 2022 18:24:32 -0400 Subject: [PATCH 06/14] hopefully working --- .../client/module/modules/render/NewChunks.kt | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 0374d71aa..c9ebc8a88 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -21,6 +21,7 @@ import com.lambda.client.util.threads.onMainThread import com.lambda.client.util.threads.safeAsyncListener import com.lambda.client.util.threads.safeListener import com.lambda.client.event.listener.asyncListener +import com.lambda.client.module.modules.render.NewChunks.saveOption import kotlinx.coroutines.runBlocking import net.minecraft.client.Minecraft import net.minecraft.client.renderer.vertex.DefaultVertexFormats @@ -51,9 +52,9 @@ object NewChunks : Module( private val relative by setting("Relative", false, description = "Renders the chunks at relative Y level to player") private val renderMode by setting("Render Mode", RenderMode.BOTH) private val saveNewChunks by setting("Save New Chunks", false) - val saveOption by setting("SaveOption", saveOption.EXTRA_FOLDER, { saveNewChunks }) - val saveInRegionFolder by setting("InRegion", false, { saveNewChunks }) - val alsoSaveNormalCoords by setting("SaveNormalCoords", false, { saveNewChunks }) + private val saveOption by setting("SaveOption", SaveOption.EXTRA_FOLDER, { saveNewChunks }) + private val saveInRegionFolder by setting("InRegion", false, { saveNewChunks }) + private val alsoSaveNormalCoords by setting("SaveNormalCoords", false, { saveNewChunks }) private var closeFile by setting("CloseFile", false, { saveNewChunks}) private val chunkGridColor by setting("Grid Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) private val distantChunkColor by setting("Distant Chunk Color", ColorHolder(100, 100, 100, 100), true, { renderMode != RenderMode.WORLD }, "Chunks that are not in render distance and not in baritone cache") @@ -63,13 +64,22 @@ object NewChunks : Module( private val thickness by setting("Thickness", 1.5f, 0.1f..4.0f, 0.1f, description = "Thickness of the highlighting square") private val range by setting("Render Range", 512, 64..2048, 32, description = "Maximum range for chunks to be highlighted") private val autoClear by setting("Auto Clear", false, description = "Clears the new chunks every 10 minutes") - private val removeMode by setting("Remove Mode", removeMode.MAX_NUMBER, description = "Mode to use for removing chunks") - private val maxNumber by setting("Max Number", 5000, 1000..10000, 500, { removeMode == removeMode.MAX_NUMBER }, description = "Maximum number of chunks to keep") + private val removeMode by setting("Remove Mode", RemoveMode.MAX_NUM, description = "Mode to use for removing chunks") + private val maxNumber by setting("Max Number", 5000, 1000..10000, 500, { removeMode == RemoveMode.MAX_NUM }, description = "Maximum number of chunks to keep") enum class RenderMode { WORLD, RADAR, BOTH } + private enum class RemoveMode { + UNLOAD, MAX_NUM, NEVER + } + + private enum class SaveOption { + EXTRA_FOLDER, LITE_LOADER_WDL, NHACK_WDL + } + + private val timer = TickTimer(TimeUnit.MINUTES) private val chunks = LinkedHashSet() private var logWriter: PrintWriter? = null @@ -163,7 +173,7 @@ object NewChunks : Module( onMainThread { if (chunks.add(chunk.pos)) { - if (removeMode == removeMode.MAX_NUMBER && chunks.size > maxNumber) { + if (removeMode == RemoveMode.MAX_NUM && chunks.size > maxNumber) { chunks.maxByOrNull { player.distanceTo(it) }?.let { chunks.remove(it) } @@ -174,7 +184,7 @@ object NewChunks : Module( asyncListener { onMainThread { - if (removeMode == removeMode.UNLOAD) { + if (removeMode == RemoveMode.UNLOAD) { chunks.remove(it.chunk.pos) } } @@ -291,12 +301,12 @@ object NewChunks : Module( var rV = Minecraft.getMinecraft().gameDir var folderName: String when (saveOption) { - saveOption.LITE_LOADER_WDL -> { + SaveOption.LITE_LOADER_WDL -> { folderName = mc.currentServerData?.serverName ?: "Offline" rV = File(rV, "saves") rV = File(rV, folderName) } - saveOption.NHACK_WDL -> { + SaveOption.NHACK_WDL -> { folderName = nHackInetName rV = File(rV, "config") rV = File(rV, "wdl-saves") @@ -379,14 +389,6 @@ object NewChunks : Module( dimension = mc.player.dimension ip = mc.currentServerData?.serverIP } - private enum class SaveOption { - EXTRA_FOLDER, LITE_LOADER_WDL, NHACK_WDL - } - - @Suppress("unused") - private enum class RemoveMode { - UNLOAD, MAX_NUM, NEVER - } init { if (closeFile) { From 111ccc747c2ae4f5439e972a552c3c1ffe7a3760 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Thu, 31 Mar 2022 21:01:34 -0400 Subject: [PATCH 07/14] potential working --- .../client/module/modules/render/NewChunks.kt | 19 +++++++++++-------- .../setting/settings/AbstractSetting.kt | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index c9ebc8a88..622f27afb 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -21,7 +21,6 @@ import com.lambda.client.util.threads.onMainThread import com.lambda.client.util.threads.safeAsyncListener import com.lambda.client.util.threads.safeListener import com.lambda.client.event.listener.asyncListener -import com.lambda.client.module.modules.render.NewChunks.saveOption import kotlinx.coroutines.runBlocking import net.minecraft.client.Minecraft import net.minecraft.client.renderer.vertex.DefaultVertexFormats @@ -55,7 +54,7 @@ object NewChunks : Module( private val saveOption by setting("SaveOption", SaveOption.EXTRA_FOLDER, { saveNewChunks }) private val saveInRegionFolder by setting("InRegion", false, { saveNewChunks }) private val alsoSaveNormalCoords by setting("SaveNormalCoords", false, { saveNewChunks }) - private var closeFile by setting("CloseFile", false, { saveNewChunks}) + private val closeFile = setting("CloseFile", false, { saveNewChunks }) private val chunkGridColor by setting("Grid Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) private val distantChunkColor by setting("Distant Chunk Color", ColorHolder(100, 100, 100, 100), true, { renderMode != RenderMode.WORLD }, "Chunks that are not in render distance and not in baritone cache") private val newChunkColor by setting("New Chunk Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) @@ -203,6 +202,7 @@ object NewChunks : Module( } private fun saveNewChunk(chunk: Chunk) { saveNewChunk(testAndGetLogWriter(), getNewChunkInfo(chunk)) + MessageSendHelper.sendChatMessage("saved chunks!") } private fun getNewChunkInfo(chunk: Chunk): String { @@ -237,7 +237,7 @@ object NewChunks : Module( if (alsoSaveNormalCoords) { head += ",x coordinate,z coordinate" } - logWriter!!.println(head) + logWriter.println(head) } catch (e: Exception) { e.printStackTrace() LambdaMod.LOG.error(chatName + " some exception happened when trying to start the logging -> " + e.message) @@ -319,6 +319,7 @@ object NewChunks : Module( } } else -> { + MessageSendHelper.sendChatMessage("made folder") folderName = mc.currentServerData?.serverName + "-" + mc.currentServerData?.serverIP if (SystemUtils.IS_OS_WINDOWS) { folderName = folderName.replace(":", "_") @@ -390,11 +391,13 @@ object NewChunks : Module( ip = mc.currentServerData?.serverIP } - init { - if (closeFile) { - logWriterClose() - MessageSendHelper.sendChatMessage("$chatName Saved file!") - closeFile = false + init { + closeFile.valueListeners.add { _, _ -> + if (closeFile.value) { + logWriterClose() + MessageSendHelper.sendChatMessage("$chatName Saved file!") + closeFile.value = false + } } } } diff --git a/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt b/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt index cfae8629e..7c9d963a5 100644 --- a/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt +++ b/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt @@ -16,7 +16,7 @@ abstract class AbstractSetting : Nameable { abstract val description: String val listeners = ArrayList<() -> Unit>() - val valueListeners = ArrayList<(prev: T, input: T) -> Unit>() + var valueListeners = ArrayList<(prev: T, input: T) -> Unit>() val isVisible get() = visibility() From 51ed169c0a7341eb28f8e8978017911ead8335bf Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Thu, 31 Mar 2022 21:44:38 -0400 Subject: [PATCH 08/14] pls help --- .../com/lambda/client/module/modules/render/NewChunks.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 622f27afb..68c1d12af 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -30,6 +30,7 @@ import net.minecraft.world.chunk.Chunk import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.fml.common.gameevent.TickEvent import org.apache.commons.lang3.SystemUtils +import org.apache.logging.log4j.LogManager import org.lwjgl.opengl.GL11.GL_LINE_LOOP import org.lwjgl.opengl.GL11.glLineWidth import java.io.BufferedWriter @@ -222,6 +223,7 @@ object NewChunks : Module( } private fun logWriterClose() { + LogManager.getLogger("Closed Log Writer") if (logWriter != null) { logWriter!!.close() logWriter = null @@ -230,6 +232,7 @@ object NewChunks : Module( } private fun logWriterOpen() { + LogManager.getLogger("Opened Log Writer") val filepath = path.toString() try { var logWriter = PrintWriter(BufferedWriter(FileWriter(filepath, true)), true) @@ -255,6 +258,7 @@ object NewChunks : Module( // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file if (mc.isSingleplayer) { try { + LogManager.getLogger("Making singleplayer world") file = mc.integratedServer?.getWorld(dimension)?.chunkSaveLocation } catch (e: Exception) { e.printStackTrace() @@ -298,6 +302,7 @@ object NewChunks : Module( } private fun makeMultiplayerDirectory(): Path { + LogManager.getLogger("Making Multiplayer Dir") var rV = Minecraft.getMinecraft().gameDir var folderName: String when (saveOption) { @@ -324,7 +329,7 @@ object NewChunks : Module( if (SystemUtils.IS_OS_WINDOWS) { folderName = folderName.replace(":", "_") } - rV = File(rV, "KAMI_NewChunks") + rV = File(rV, "Lambda_NewChunks") rV = File(rV, folderName) } } From 1e712ca01be41df6f0ece7aee9c112903e4c4ebc Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Fri, 1 Apr 2022 15:04:00 -0400 Subject: [PATCH 09/14] still aint working --- .../com/lambda/client/module/modules/render/NewChunks.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 68c1d12af..e76ff25df 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -152,6 +152,7 @@ object NewChunks : Module( RenderUtils2D.drawRectFilled(it.vertexHelper, pos0, pos1, distantChunkColor) } RenderUtils2D.drawRectOutline(it.vertexHelper, pos0, pos1, 0.3f, chunkGridColor) + if (saveNewChunks) saveNewChunk(chunk) } } } @@ -159,7 +160,6 @@ object NewChunks : Module( for (chunk in chunks) { val pos0 = getChunkPos(chunk.x - player.chunkCoordX, chunk.z - player.chunkCoordZ, playerOffset, it.scale) val pos1 = getChunkPos(chunk.x - player.chunkCoordX + 1, chunk.z - player.chunkCoordZ + 1, playerOffset, it.scale) - if (isSquareInRadius(pos0, pos1, it.radius)) { RenderUtils2D.drawRectFilled(it.vertexHelper, pos0, pos1, newChunkColor) } @@ -257,6 +257,7 @@ object NewChunks : Module( // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file if (mc.isSingleplayer) { + LogManager.getLogger("Making singleplayer world") try { LogManager.getLogger("Making singleplayer world") file = mc.integratedServer?.getWorld(dimension)?.chunkSaveLocation @@ -401,6 +402,7 @@ object NewChunks : Module( if (closeFile.value) { logWriterClose() MessageSendHelper.sendChatMessage("$chatName Saved file!") + MessageSendHelper.sendChatMessage("$path") closeFile.value = false } } From 8d5821db0a7192efb46de0f83ba2e370acdae1fe Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Fri, 1 Apr 2022 17:13:01 -0400 Subject: [PATCH 10/14] fuck this --- .../client/module/modules/render/NewChunks.kt | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index e76ff25df..777faaee8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -25,7 +25,6 @@ import kotlinx.coroutines.runBlocking import net.minecraft.client.Minecraft import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.network.play.server.SPacketChunkData -import net.minecraft.util.math.ChunkPos import net.minecraft.world.chunk.Chunk import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -81,7 +80,7 @@ object NewChunks : Module( private val timer = TickTimer(TimeUnit.MINUTES) - private val chunks = LinkedHashSet() + private val chunks = LinkedHashSet() private var logWriter: PrintWriter? = null private var lastSetting = LastSetting() @@ -115,14 +114,14 @@ object NewChunks : Module( val buffer = LambdaTessellator.buffer - for (chunkPos in chunks) { - if (player.distanceTo(chunkPos) > range) continue + for (chunk in chunks) { + if (player.distanceTo(chunk.pos) > range) continue buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR) - buffer.pos(chunkPos.xStart.toDouble(), y, chunkPos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunkPos.xEnd + 1.0, y, chunkPos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunkPos.xEnd + 1.0, y, chunkPos.zEnd + 1.0).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunkPos.xStart.toDouble(), y, chunkPos.zEnd + 1.0).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunk.pos.xEnd + 1.0, y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunk.pos.xEnd + 1.0, y, chunk.pos.zEnd + 1.0).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zEnd + 1.0).color(color.r, color.g, color.b, color.a).endVertex() LambdaTessellator.render() } @@ -152,12 +151,12 @@ object NewChunks : Module( RenderUtils2D.drawRectFilled(it.vertexHelper, pos0, pos1, distantChunkColor) } RenderUtils2D.drawRectOutline(it.vertexHelper, pos0, pos1, 0.3f, chunkGridColor) - if (saveNewChunks) saveNewChunk(chunk) } } } for (chunk in chunks) { + if (saveNewChunks) saveNewChunk(chunk) val pos0 = getChunkPos(chunk.x - player.chunkCoordX, chunk.z - player.chunkCoordZ, playerOffset, it.scale) val pos1 = getChunkPos(chunk.x - player.chunkCoordX + 1, chunk.z - player.chunkCoordZ + 1, playerOffset, it.scale) if (isSquareInRadius(pos0, pos1, it.radius)) { @@ -170,11 +169,10 @@ object NewChunks : Module( if (event.packet !is SPacketChunkData || event.packet.isFullChunk) return@safeAsyncListener val chunk = world.getChunk(event.packet.chunkX, event.packet.chunkZ) if (chunk.isEmpty) return@safeAsyncListener - onMainThread { - if (chunks.add(chunk.pos)) { + if (chunks.add(chunk)) { if (removeMode == RemoveMode.MAX_NUM && chunks.size > maxNumber) { - chunks.maxByOrNull { player.distanceTo(it) }?.let { + chunks.maxByOrNull { player.distanceTo(chunk.pos) }?.let { chunks.remove(it) } } @@ -185,7 +183,7 @@ object NewChunks : Module( asyncListener { onMainThread { if (removeMode == RemoveMode.UNLOAD) { - chunks.remove(it.chunk.pos) + chunks.remove(it.chunk) } } } @@ -203,7 +201,6 @@ object NewChunks : Module( } private fun saveNewChunk(chunk: Chunk) { saveNewChunk(testAndGetLogWriter(), getNewChunkInfo(chunk)) - MessageSendHelper.sendChatMessage("saved chunks!") } private fun getNewChunkInfo(chunk: Chunk): String { @@ -223,7 +220,6 @@ object NewChunks : Module( } private fun logWriterClose() { - LogManager.getLogger("Closed Log Writer") if (logWriter != null) { logWriter!!.close() logWriter = null @@ -232,15 +228,14 @@ object NewChunks : Module( } private fun logWriterOpen() { - LogManager.getLogger("Opened Log Writer") val filepath = path.toString() try { - var logWriter = PrintWriter(BufferedWriter(FileWriter(filepath, true)), true) + logWriter = PrintWriter(BufferedWriter(FileWriter(filepath, true)), true) var head = "timestamp,ChunkX,ChunkZ" if (alsoSaveNormalCoords) { head += ",x coordinate,z coordinate" } - logWriter.println(head) + logWriter!!.println(head) } catch (e: Exception) { e.printStackTrace() LambdaMod.LOG.error(chatName + " some exception happened when trying to start the logging -> " + e.message) @@ -257,9 +252,7 @@ object NewChunks : Module( // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file if (mc.isSingleplayer) { - LogManager.getLogger("Making singleplayer world") try { - LogManager.getLogger("Making singleplayer world") file = mc.integratedServer?.getWorld(dimension)?.chunkSaveLocation } catch (e: Exception) { e.printStackTrace() @@ -287,7 +280,7 @@ object NewChunks : Module( } file = File(file, "newChunkLogs") val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Date()) - file = File(file, mc.getSession().username + "_" + date + ".csv") // maybe dont safe the name actually. But I also dont want to make another option... + file = File(file, mc.session.username + "_" + date + ".csv") // maybe dont safe the name actually. But I also dont want to make another option... val rV = file.toPath() try { if (!Files.exists(rV)) { // ovsly always... From 537751a3a379aa7b985c6964c472d5d55a99127e Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Fri, 1 Apr 2022 20:59:40 -0400 Subject: [PATCH 11/14] potentially working --- .../client/module/modules/render/NewChunks.kt | 195 ++++++------------ 1 file changed, 68 insertions(+), 127 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 777faaee8..77de4d265 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -2,34 +2,26 @@ package com.lambda.client.module.modules.render import com.lambda.client.LambdaMod import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.events.RenderRadarEvent import com.lambda.client.event.events.RenderWorldEvent import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.EntityUtils.getInterpolatedPos import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.LambdaTessellator -import com.lambda.client.util.graphics.RenderUtils2D -import com.lambda.client.util.math.Vec2d -import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.util.threads.onMainThread -import com.lambda.client.util.threads.safeAsyncListener import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.asyncListener -import kotlinx.coroutines.runBlocking +import com.lambda.client.event.listener.listener +import com.lambda.client.util.Wrapper.world +import com.lambda.client.util.threads.safeAsyncListener import net.minecraft.client.Minecraft -import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.network.play.server.SPacketChunkData import net.minecraft.world.chunk.Chunk import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.fml.common.gameevent.TickEvent import org.apache.commons.lang3.SystemUtils -import org.apache.logging.log4j.LogManager import org.lwjgl.opengl.GL11.GL_LINE_LOOP import org.lwjgl.opengl.GL11.glLineWidth import java.io.BufferedWriter @@ -38,10 +30,10 @@ import java.io.IOException import java.io.PrintWriter import java.nio.file.Files import java.io.File +import java.lang.Math.sqrt import java.nio.file.Path import java.text.SimpleDateFormat import java.util.Date -import kotlin.collections.LinkedHashSet object NewChunks : Module( name = "NewChunks", @@ -66,139 +58,75 @@ object NewChunks : Module( private val removeMode by setting("Remove Mode", RemoveMode.MAX_NUM, description = "Mode to use for removing chunks") private val maxNumber by setting("Max Number", 5000, 1000..10000, 500, { removeMode == RemoveMode.MAX_NUM }, description = "Maximum number of chunks to keep") - enum class RenderMode { - WORLD, RADAR, BOTH - } - - private enum class RemoveMode { - UNLOAD, MAX_NUM, NEVER - } - - private enum class SaveOption { - EXTRA_FOLDER, LITE_LOADER_WDL, NHACK_WDL - } - - - private val timer = TickTimer(TimeUnit.MINUTES) - private val chunks = LinkedHashSet() - private var logWriter: PrintWriter? = null private var lastSetting = LastSetting() + private var logWriter: PrintWriter? = null + private val timer = TickTimer(TimeUnit.MINUTES) + private val chunks = HashSet() init { - onEnable { - timer.reset() + onDisable { + logWriterClose() + chunks.clear() + MessageSendHelper.sendChatMessage("$chatName Saved and cleared chunks!") } - onDisable { - runBlocking { - onMainThread { - chunks.clear() - } - } + onEnable { + timer.reset() } + } - safeListener { + init { + safeListener { if (it.phase == TickEvent.Phase.END && autoClear && timer.tick(10L)) { chunks.clear() MessageSendHelper.sendChatMessage("$chatName Cleared chunks!") } } - safeListener { - if (renderMode == RenderMode.RADAR) return@safeListener - - val y = yOffset.toDouble() + if (relative) getInterpolatedPos(player, LambdaTessellator.pTicks()).y else 0.0 - - glLineWidth(thickness) + listener { + if (renderMode == RenderMode.RADAR) return@listener + val y = yOffset.toDouble() + if (relative) getInterpolatedPos(mc.player, LambdaTessellator.pTicks()).y else 0.0 + glLineWidth(2.0f) GlStateUtils.depth(false) - + val color = chunkGridColor val buffer = LambdaTessellator.buffer - for (chunk in chunks) { - if (player.distanceTo(chunk.pos) > range) continue - - buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR) - buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunk.pos.xEnd + 1.0, y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunk.pos.xEnd + 1.0, y, chunk.pos.zEnd + 1.0).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zEnd + 1.0).color(color.r, color.g, color.b, color.a).endVertex() + if (sqrt(chunk.pos.getDistanceSq(mc.player)) > range) continue + LambdaTessellator.begin(GL_LINE_LOOP) + buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, 255).endVertex() + buffer.pos(chunk.pos.xEnd + 1.toDouble(), y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, 255).endVertex() + buffer.pos(chunk.pos.xEnd + 1.toDouble(), y, chunk.pos.zEnd + 1.toDouble()).color(color.r, color.g, color.b, 255).endVertex() + buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zEnd + 1.toDouble()).color(color.r, color.g, color.b, 255).endVertex() LambdaTessellator.render() } - - glLineWidth(1.0f) GlStateUtils.depth(true) } - safeListener { - if (renderMode == RenderMode.WORLD) return@safeListener - - val playerOffset = Vec2d((player.posX - (player.chunkCoordX shl 4)), (player.posZ - (player.chunkCoordZ shl 4))) - val chunkDist = (it.radius * it.scale).toInt() shr 4 - - for (chunkX in -chunkDist..chunkDist) { - for (chunkZ in -chunkDist..chunkDist) { - val pos0 = getChunkPos(chunkX, chunkZ, playerOffset, it.scale) - val pos1 = getChunkPos(chunkX + 1, chunkZ + 1, playerOffset, it.scale) - - if (isSquareInRadius(pos0, pos1, it.radius)) { - val chunk = world.getChunk(player.chunkCoordX + chunkX, player.chunkCoordZ + chunkZ) - val isCachedChunk = - BaritoneUtils.primary?.worldProvider?.currentWorld?.cachedWorld?.isCached( - (player.chunkCoordX + chunkX) shl 4, (player.chunkCoordZ + chunkZ) shl 4 - ) ?: false - - if (!chunk.isLoaded && !isCachedChunk) { - RenderUtils2D.drawRectFilled(it.vertexHelper, pos0, pos1, distantChunkColor) - } - RenderUtils2D.drawRectOutline(it.vertexHelper, pos0, pos1, 0.3f, chunkGridColor) - } - } - } - - for (chunk in chunks) { - if (saveNewChunks) saveNewChunk(chunk) - val pos0 = getChunkPos(chunk.x - player.chunkCoordX, chunk.z - player.chunkCoordZ, playerOffset, it.scale) - val pos1 = getChunkPos(chunk.x - player.chunkCoordX + 1, chunk.z - player.chunkCoordZ + 1, playerOffset, it.scale) - if (isSquareInRadius(pos0, pos1, it.radius)) { - RenderUtils2D.drawRectFilled(it.vertexHelper, pos0, pos1, newChunkColor) - } - } - } - safeAsyncListener { event -> if (event.packet !is SPacketChunkData || event.packet.isFullChunk) return@safeAsyncListener val chunk = world.getChunk(event.packet.chunkX, event.packet.chunkZ) - if (chunk.isEmpty) return@safeAsyncListener - onMainThread { - if (chunks.add(chunk)) { - if (removeMode == RemoveMode.MAX_NUM && chunks.size > maxNumber) { - chunks.maxByOrNull { player.distanceTo(chunk.pos) }?.let { - chunks.remove(it) - } + if (saveNewChunks) saveNewChunk(chunk) + if (removeMode == RemoveMode.MAX_NUM && chunks.size > maxNumber) { + var removeChunk = chunks.first() + var maxDist = Double.MIN_VALUE + chunks.forEach { c -> + if (c.pos.getDistanceSq(mc.player) > maxDist) { + maxDist = c.pos.getDistanceSq(mc.player) + removeChunk = c } } + chunks.remove(removeChunk) } } - asyncListener { - onMainThread { - if (removeMode == RemoveMode.UNLOAD) { - chunks.remove(it.chunk) - } - } - } - } - // p2.x > p1.x and p2.y > p1.y is assumed - private fun isSquareInRadius(p1: Vec2d, p2: Vec2d, radius: Float): Boolean { - val x = if (p1.x + p2.x > 0) p2.x else p1.x - val y = if (p1.y + p2.y > 0) p2.y else p1.y - return Vec2d(x, y).length() < radius + safeListener { + if (removeMode == RemoveMode.UNLOAD) + chunks.remove(it.chunk) + } } - private fun getChunkPos(x: Int, z: Int, playerOffset: Vec2d, scale: Float): Vec2d { - return Vec2d((x shl 4).toDouble(), (z shl 4).toDouble()).minus(playerOffset).div(scale.toDouble()) - } + // needs to be synchronized so no data gets lost private fun saveNewChunk(chunk: Chunk) { saveNewChunk(testAndGetLogWriter(), getNewChunkInfo(chunk)) } @@ -280,7 +208,7 @@ object NewChunks : Module( } file = File(file, "newChunkLogs") val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Date()) - file = File(file, mc.session.username + "_" + date + ".csv") // maybe dont safe the name actually. But I also dont want to make another option... + file = File(file, mc.getSession().username + "_" + date + ".csv") // maybe dont safe the name actually. But I also dont want to make another option... val rV = file.toPath() try { if (!Files.exists(rV)) { // ovsly always... @@ -296,7 +224,6 @@ object NewChunks : Module( } private fun makeMultiplayerDirectory(): Path { - LogManager.getLogger("Making Multiplayer Dir") var rV = Minecraft.getMinecraft().gameDir var folderName: String when (saveOption) { @@ -318,7 +245,6 @@ object NewChunks : Module( } } else -> { - MessageSendHelper.sendChatMessage("made folder") folderName = mc.currentServerData?.serverName + "-" + mc.currentServerData?.serverIP if (SystemUtils.IS_OS_WINDOWS) { folderName = folderName.replace(":", "_") @@ -357,6 +283,22 @@ object NewChunks : Module( log!!.println(data) } + private enum class SaveOption { + EXTRA_FOLDER, LITE_LOADER_WDL, NHACK_WDL + } + + @Suppress("unused") + private enum class RemoveMode { + UNLOAD, MAX_NUM, NEVER + } + + enum class RenderMode { + WORLD, RADAR, BOTH + } + + val isRadarMode get() = renderMode == RenderMode.BOTH || renderMode == RenderMode.RADAR + private val isWorldMode get() = renderMode == RenderMode.BOTH || renderMode == RenderMode.WORLD + private class LastSetting { var lastSaveOption: SaveOption? = null var lastInRegion = false @@ -381,24 +323,23 @@ object NewChunks : Module( || mc.currentServerData?.serverIP != ip } - private fun update() { - lastSaveOption = saveOption + lastSaveOption = saveOption as SaveOption lastInRegion = saveInRegionFolder lastSaveNormal = alsoSaveNormalCoords dimension = mc.player.dimension ip = mc.currentServerData?.serverIP } + } - init { - closeFile.valueListeners.add { _, _ -> - if (closeFile.value) { - logWriterClose() - MessageSendHelper.sendChatMessage("$chatName Saved file!") - MessageSendHelper.sendChatMessage("$path") - closeFile.value = false - } + init { + closeFile.valueListeners.add { _, _ -> + if (closeFile.value) { + logWriterClose() + MessageSendHelper.sendChatMessage("$chatName Saved file!") + MessageSendHelper.sendChatMessage("$path") + closeFile.value = false } } } -} +} \ No newline at end of file From 885d3585cb0eadecf06653ba1ca282d7e8080890 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars Date: Fri, 1 Apr 2022 21:49:54 -0400 Subject: [PATCH 12/14] actually working, todo fix rendinering --- .../client/module/modules/render/NewChunks.kt | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 77de4d265..d2469d813 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -13,10 +13,10 @@ import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener -import com.lambda.client.util.Wrapper.world +import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.threads.safeAsyncListener import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.network.play.server.SPacketChunkData import net.minecraft.world.chunk.Chunk import net.minecraftforge.event.world.ChunkEvent @@ -30,7 +30,6 @@ import java.io.IOException import java.io.PrintWriter import java.nio.file.Files import java.io.File -import java.lang.Math.sqrt import java.nio.file.Path import java.text.SimpleDateFormat import java.util.Date @@ -47,9 +46,6 @@ object NewChunks : Module( private val saveInRegionFolder by setting("InRegion", false, { saveNewChunks }) private val alsoSaveNormalCoords by setting("SaveNormalCoords", false, { saveNewChunks }) private val closeFile = setting("CloseFile", false, { saveNewChunks }) - private val chunkGridColor by setting("Grid Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) - private val distantChunkColor by setting("Distant Chunk Color", ColorHolder(100, 100, 100, 100), true, { renderMode != RenderMode.WORLD }, "Chunks that are not in render distance and not in baritone cache") - private val newChunkColor by setting("New Chunk Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) private val yOffset by setting("Y Offset", 0, -256..256, 4, fineStep = 1, description = "Render offset in Y axis") private val color by setting("Color", ColorHolder(255, 64, 64, 200), description = "Highlighting color") private val thickness by setting("Thickness", 1.5f, 0.1f..4.0f, 0.1f, description = "Thickness of the highlighting square") @@ -83,22 +79,28 @@ object NewChunks : Module( } } - listener { - if (renderMode == RenderMode.RADAR) return@listener - val y = yOffset.toDouble() + if (relative) getInterpolatedPos(mc.player, LambdaTessellator.pTicks()).y else 0.0 - glLineWidth(2.0f) + safeListener { + if (renderMode == RenderMode.RADAR) return@safeListener + + val y = yOffset.toDouble() + if (relative) getInterpolatedPos(player, LambdaTessellator.pTicks()).y else 0.0 + + glLineWidth(thickness) GlStateUtils.depth(false) - val color = chunkGridColor + val buffer = LambdaTessellator.buffer + for (chunk in chunks) { - if (sqrt(chunk.pos.getDistanceSq(mc.player)) > range) continue - LambdaTessellator.begin(GL_LINE_LOOP) - buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, 255).endVertex() - buffer.pos(chunk.pos.xEnd + 1.toDouble(), y, chunk.pos.zStart.toDouble()).color(color.r, color.g, color.b, 255).endVertex() - buffer.pos(chunk.pos.xEnd + 1.toDouble(), y, chunk.pos.zEnd + 1.toDouble()).color(color.r, color.g, color.b, 255).endVertex() - buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zEnd + 1.toDouble()).color(color.r, color.g, color.b, 255).endVertex() + if (player.distanceTo(chunk.pos) > range) continue + + buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR) + buffer.pos(chunk.pos.xEnd.toDouble(), y, chunk.pos.zEnd.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunk.pos.xEnd.toDouble() + 1.0, y, chunk.pos.z.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunk.pos.xEnd.toDouble() + 1.0, y, chunk.pos.zEnd.toDouble() + 1.0).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zEnd.toDouble() + 1.0).color(color.r, color.g, color.b, color.a).endVertex() LambdaTessellator.render() } + + glLineWidth(1.0f) GlStateUtils.depth(true) } @@ -296,9 +298,6 @@ object NewChunks : Module( WORLD, RADAR, BOTH } - val isRadarMode get() = renderMode == RenderMode.BOTH || renderMode == RenderMode.RADAR - private val isWorldMode get() = renderMode == RenderMode.BOTH || renderMode == RenderMode.WORLD - private class LastSetting { var lastSaveOption: SaveOption? = null var lastInRegion = false @@ -324,7 +323,7 @@ object NewChunks : Module( } private fun update() { - lastSaveOption = saveOption as SaveOption + lastSaveOption = saveOption lastInRegion = saveInRegionFolder lastSaveNormal = alsoSaveNormalCoords dimension = mc.player.dimension From d85a389b52b1336963f5358975d40eb572f50247 Mon Sep 17 00:00:00 2001 From: ItCameFr0mMars <48456413+ItCameFr0mMars@users.noreply.github.com> Date: Fri, 1 Apr 2022 21:50:45 -0400 Subject: [PATCH 13/14] Update Timer.kt --- .../kotlin/com/lambda/client/module/modules/player/Timer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt index e23fc62ad..6fec4e46b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt @@ -14,7 +14,7 @@ object Timer : Module( modulePriority = 500 ) { private val slow by setting("Slow Mode", false) - private val tickNormal by setting("Tick N", 2.0f, 1f..2000f, 0.1f, { !slow }) + private val tickNormal by setting("Tick N", 2.0f, 1f..10f, 0.1f, { !slow }) private val tickSlow by setting("Tick S", 8f, 1f..10f, 0.1f, { slow }) init { From e7f65206ac07a76bfee0633206d8c5227b2c73cc Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 2 May 2022 15:39:57 +0200 Subject: [PATCH 14/14] Refactor --- README.md | 2 - .../client/module/modules/player/Timer.kt | 2 +- .../client/module/modules/render/NewChunks.kt | 155 +++++++++--------- .../setting/settings/AbstractSetting.kt | 2 +- .../com/lambda/client/util/FolderUtils.kt | 4 + 5 files changed, 85 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index c18319d9a..8b93bd42d 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ ![GitHub repo size](https://img.shields.io/github/repo-size/lambda-client/lambda) ![Lines of code](https://img.shields.io/tokei/lines/github/lambda-client/lambda?color=lightcoral&label=lines%20of%20code) -#MARS EDITION - Lambda is a free, open-source, Minecraft 1.12.2 utility mod made for the anarchy experience. A visionary plugin system that allows additional modules to be added, without the need to create a fork! Customize your experience, and improve your efficiency! diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt index 6fec4e46b..2e75079c7 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt @@ -29,4 +29,4 @@ object Timer : Module( modifyTimer(50.0f / multiplier) } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index d2469d813..068571bae 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -1,11 +1,13 @@ package com.lambda.client.module.modules.render import com.lambda.client.LambdaMod +import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.RenderWorldEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.getInterpolatedPos +import com.lambda.client.util.FolderUtils import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.color.ColorHolder @@ -14,11 +16,10 @@ import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener import com.lambda.client.util.math.VectorUtils.distanceTo -import com.lambda.client.util.threads.safeAsyncListener import net.minecraft.client.Minecraft import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.network.play.server.SPacketChunkData -import net.minecraft.world.chunk.Chunk +import net.minecraft.util.math.ChunkPos import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.fml.common.gameevent.TickEvent import org.apache.commons.lang3.SystemUtils @@ -33,6 +34,7 @@ import java.io.File import java.nio.file.Path import java.text.SimpleDateFormat import java.util.Date +import java.util.concurrent.ConcurrentHashMap object NewChunks : Module( name = "NewChunks", @@ -42,22 +44,21 @@ object NewChunks : Module( private val relative by setting("Relative", false, description = "Renders the chunks at relative Y level to player") private val renderMode by setting("Render Mode", RenderMode.BOTH) private val saveNewChunks by setting("Save New Chunks", false) - private val saveOption by setting("SaveOption", SaveOption.EXTRA_FOLDER, { saveNewChunks }) - private val saveInRegionFolder by setting("InRegion", false, { saveNewChunks }) - private val alsoSaveNormalCoords by setting("SaveNormalCoords", false, { saveNewChunks }) + private val saveOption by setting("Save Option", SaveOption.EXTRA_FOLDER, { saveNewChunks }) + private val saveInRegionFolder by setting("In Region", false, { saveNewChunks }) + private val alsoSaveNormalCoords by setting("Save Normal Coords", false, { saveNewChunks }) private val closeFile = setting("CloseFile", false, { saveNewChunks }) private val yOffset by setting("Y Offset", 0, -256..256, 4, fineStep = 1, description = "Render offset in Y axis") private val color by setting("Color", ColorHolder(255, 64, 64, 200), description = "Highlighting color") private val thickness by setting("Thickness", 1.5f, 0.1f..4.0f, 0.1f, description = "Thickness of the highlighting square") private val range by setting("Render Range", 512, 64..2048, 32, description = "Maximum range for chunks to be highlighted") - private val autoClear by setting("Auto Clear", false, description = "Clears the new chunks every 10 minutes") - private val removeMode by setting("Remove Mode", RemoveMode.MAX_NUM, description = "Mode to use for removing chunks") - private val maxNumber by setting("Max Number", 5000, 1000..10000, 500, { removeMode == RemoveMode.MAX_NUM }, description = "Maximum number of chunks to keep") + private val removeMode by setting("Remove Mode", RemoveMode.AGE, description = "Mode to use for removing chunks") + private val maxAge by setting("Max age in minutes", 10, 1..600, 1, { removeMode == RemoveMode.AGE }, description = "Maximum age of chunks since recording") private var lastSetting = LastSetting() private var logWriter: PrintWriter? = null - private val timer = TickTimer(TimeUnit.MINUTES) - private val chunks = HashSet() + private val chunks = ConcurrentHashMap() + private val timer = TickTimer(TimeUnit.SECONDS) init { onDisable { @@ -72,10 +73,13 @@ object NewChunks : Module( } init { - safeListener { - if (it.phase == TickEvent.Phase.END && autoClear && timer.tick(10L)) { - chunks.clear() - MessageSendHelper.sendChatMessage("$chatName Cleared chunks!") + safeListener { + if (it.phase == TickEvent.Phase.END + && removeMode == RemoveMode.AGE + && timer.tick(5) + ) { + val currentTime = System.currentTimeMillis() + chunks.values.removeIf { chunkAge -> currentTime - chunkAge > maxAge * 60 * 1000 } } } @@ -89,14 +93,12 @@ object NewChunks : Module( val buffer = LambdaTessellator.buffer - for (chunk in chunks) { - if (player.distanceTo(chunk.pos) > range) continue - + chunks.filter { player.distanceTo(it.key) < range }.keys.forEach { chunkPos -> buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR) - buffer.pos(chunk.pos.xEnd.toDouble(), y, chunk.pos.zEnd.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunk.pos.xEnd.toDouble() + 1.0, y, chunk.pos.z.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunk.pos.xEnd.toDouble() + 1.0, y, chunk.pos.zEnd.toDouble() + 1.0).color(color.r, color.g, color.b, color.a).endVertex() - buffer.pos(chunk.pos.xStart.toDouble(), y, chunk.pos.zEnd.toDouble() + 1.0).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunkPos.xStart.toDouble(), y, chunkPos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunkPos.xEnd + 1.toDouble(), y, chunkPos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunkPos.xEnd + 1.toDouble(), y, chunkPos.zEnd + 1.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() + buffer.pos(chunkPos.xStart.toDouble(), y, chunkPos.zEnd + 1.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() LambdaTessellator.render() } @@ -104,45 +106,37 @@ object NewChunks : Module( GlStateUtils.depth(true) } - safeAsyncListener { event -> - if (event.packet !is SPacketChunkData || event.packet.isFullChunk) return@safeAsyncListener - val chunk = world.getChunk(event.packet.chunkX, event.packet.chunkZ) - if (saveNewChunks) saveNewChunk(chunk) - if (removeMode == RemoveMode.MAX_NUM && chunks.size > maxNumber) { - var removeChunk = chunks.first() - var maxDist = Double.MIN_VALUE - chunks.forEach { c -> - if (c.pos.getDistanceSq(mc.player) > maxDist) { - maxDist = c.pos.getDistanceSq(mc.player) - removeChunk = c - } - } - chunks.remove(removeChunk) + safeListener { event -> + if (event.packet is SPacketChunkData + && !event.packet.isFullChunk + ) { + val chunkPos = ChunkPos(event.packet.chunkX, event.packet.chunkZ) + chunks[chunkPos] = System.currentTimeMillis() + if (saveNewChunks) saveNewChunk(chunkPos) } } - safeListener { if (removeMode == RemoveMode.UNLOAD) - chunks.remove(it.chunk) + chunks.remove(it.chunk.pos) } } // needs to be synchronized so no data gets lost - private fun saveNewChunk(chunk: Chunk) { + private fun SafeClientEvent.saveNewChunk(chunk: ChunkPos) { saveNewChunk(testAndGetLogWriter(), getNewChunkInfo(chunk)) } - private fun getNewChunkInfo(chunk: Chunk): String { - var rV = String.format("%d,%d,%d", System.currentTimeMillis(), chunk.x, chunk.z) + private fun getNewChunkInfo(chunk: ChunkPos): String { + var chunkInfo = String.format("%d,%d,%d", System.currentTimeMillis(), chunk.x, chunk.z) if (alsoSaveNormalCoords) { - rV += String.format(",%d,%d", chunk.x * 16 + 8, chunk.z * 16 + 8) + chunkInfo += String.format(",%d,%d", chunk.x * 16 + 8, chunk.z * 16 + 8) } - return rV + return chunkInfo } - private fun testAndGetLogWriter(): PrintWriter? { - if (lastSetting.testChangeAndUpdate()) { + private fun SafeClientEvent.testAndGetLogWriter(): PrintWriter? { + if (lastSetting.testChangeAndUpdate(this)) { logWriterClose() logWriterOpen() } @@ -158,18 +152,25 @@ object NewChunks : Module( } private fun logWriterOpen() { - val filepath = path.toString() - try { - logWriter = PrintWriter(BufferedWriter(FileWriter(filepath, true)), true) + val fileWriter = try { + FileWriter(path.toString(), true) + } catch (e: IOException) { + e.printStackTrace() + LambdaMod.LOG.error(chatName + " some exception happened when trying to start the logging -> " + e.message) + MessageSendHelper.sendErrorMessage("$chatName Can't access $path") + disable() + return + } + + PrintWriter(BufferedWriter(fileWriter), true).let { + logWriter = it + var head = "timestamp,ChunkX,ChunkZ" if (alsoSaveNormalCoords) { - head += ",x coordinate,z coordinate" + head += ",x,z" } - logWriter!!.println(head) - } catch (e: Exception) { - e.printStackTrace() - LambdaMod.LOG.error(chatName + " some exception happened when trying to start the logging -> " + e.message) - MessageSendHelper.sendErrorMessage(chatName + " onLogStart: " + e.message) + + it.println(head) } } @@ -188,9 +189,10 @@ object NewChunks : Module( e.printStackTrace() LambdaMod.LOG.error("some exception happened when getting canonicalFile -> " + e.message) MessageSendHelper.sendErrorMessage(chatName + " onGetPath: " + e.message) + disable() } - // Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world + // Gets the "depth" of this directory relative to the game's run directory, 2 is the location of the world if (file?.toPath()?.relativize(mc.gameDir.toPath())?.nameCount != 2) { // subdirectory of the main save directory for this world file = file?.parentFile @@ -210,25 +212,34 @@ object NewChunks : Module( } file = File(file, "newChunkLogs") val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Date()) - file = File(file, mc.getSession().username + "_" + date + ".csv") // maybe dont safe the name actually. But I also dont want to make another option... - val rV = file.toPath() + file = File(file, mc.session.username + "_" + date + ".csv") // maybe don't safe the name, actually. But I also don't want to make another option... + val filePath = file.toPath() try { - if (!Files.exists(rV)) { // ovsly always... - Files.createDirectories(rV.parent) - Files.createFile(rV) + if (!Files.exists(filePath)) { + Files.createDirectories(filePath.parent) + Files.createFile(filePath) } } catch (e: IOException) { e.printStackTrace() LambdaMod.LOG.error("some exception happened when trying to make the file -> " + e.message) MessageSendHelper.sendErrorMessage(chatName + " onCreateFile: " + e.message) + disable() } - return rV + return filePath } private fun makeMultiplayerDirectory(): Path { var rV = Minecraft.getMinecraft().gameDir var folderName: String when (saveOption) { + SaveOption.EXTRA_FOLDER -> { + folderName = mc.currentServerData?.serverName + "-" + mc.currentServerData?.serverIP + if (SystemUtils.IS_OS_WINDOWS) { + folderName = folderName.replace(":", "_") + } + rV = File(FolderUtils.newChunksFolder) + rV = File(rV, folderName) + } SaveOption.LITE_LOADER_WDL -> { folderName = mc.currentServerData?.serverName ?: "Offline" rV = File(rV, "saves") @@ -246,14 +257,6 @@ object NewChunks : Module( MessageSendHelper.sendWarningMessage("$chatName creating the directory now. It is recommended to update the ip") } } - else -> { - folderName = mc.currentServerData?.serverName + "-" + mc.currentServerData?.serverIP - if (SystemUtils.IS_OS_WINDOWS) { - folderName = folderName.replace(":", "_") - } - rV = File(rV, "Lambda_NewChunks") - rV = File(rV, folderName) - } } return rV.toPath() } @@ -291,7 +294,7 @@ object NewChunks : Module( @Suppress("unused") private enum class RemoveMode { - UNLOAD, MAX_NUM, NEVER + UNLOAD, AGE, NEVER } enum class RenderMode { @@ -304,29 +307,29 @@ object NewChunks : Module( var lastSaveNormal = false var dimension = 0 var ip: String? = null - fun testChangeAndUpdate(): Boolean { - if (testChange()) { + fun testChangeAndUpdate(event: SafeClientEvent): Boolean { + if (testChange(event)) { // so we dont have to do this process again next time - update() + update(event) return true } return false } - fun testChange(): Boolean { + fun testChange(event: SafeClientEvent): Boolean { // these somehow include the test whether its null return saveOption != lastSaveOption || saveInRegionFolder != lastInRegion || alsoSaveNormalCoords != lastSaveNormal - || dimension != mc.player.dimension + || dimension != event.player.dimension || mc.currentServerData?.serverIP != ip } - private fun update() { + private fun update(event: SafeClientEvent) { lastSaveOption = saveOption lastInRegion = saveInRegionFolder lastSaveNormal = alsoSaveNormalCoords - dimension = mc.player.dimension + dimension = event.player.dimension ip = mc.currentServerData?.serverIP } } diff --git a/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt b/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt index 7c9d963a5..cfae8629e 100644 --- a/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt +++ b/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt @@ -16,7 +16,7 @@ abstract class AbstractSetting : Nameable { abstract val description: String val listeners = ArrayList<() -> Unit>() - var valueListeners = ArrayList<(prev: T, input: T) -> Unit>() + val valueListeners = ArrayList<(prev: T, input: T) -> Unit>() val isVisible get() = visibility() diff --git a/src/main/kotlin/com/lambda/client/util/FolderUtils.kt b/src/main/kotlin/com/lambda/client/util/FolderUtils.kt index 3cbea595e..a477eaf46 100644 --- a/src/main/kotlin/com/lambda/client/util/FolderUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/FolderUtils.kt @@ -42,6 +42,10 @@ object FolderUtils { val songFolder get() = "${lambdaFolder}songs${File.separator}" + @JvmStatic + val newChunksFolder + get() = "${lambdaFolder}newChunks${File.separator}" + /** * Opens the given path using the right library based on OS */