diff --git a/src/main/kotlin/com/lambda/client/command/commands/BlackListCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/BlackListCommand.kt new file mode 100644 index 000000000..f6d2fdb65 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/commands/BlackListCommand.kt @@ -0,0 +1,65 @@ +package com.lambda.client.command.commands + +import com.lambda.client.command.ClientCommand +import com.lambda.client.module.modules.player.ChestStealer +import com.lambda.client.util.text.MessageSendHelper + +// TODO: Remove once GUI has List +object BlackListCommand : ClientCommand( + name = "blackList", + description = "Modify blackList items for ChestStealer module" +) { + init { + literal("add", "+") { + item("item") { itemArg -> + execute("Add an item to the BlackList") { + val itemName = itemArg.value.registryName!!.toString() + + if (ChestStealer.blackList.contains(itemName)) { + MessageSendHelper.sendErrorMessage("&c$itemName is already added to the BlackList") + } else { + ChestStealer.blackList.add(itemName) + MessageSendHelper.sendChatMessage("$itemName has been added to the BlackList") + } + } + } + } + + literal("del", "remove", "-") { + item("item") { itemArg -> + execute("Remove an item from the BlackList") { + val itemName = itemArg.value.registryName!!.toString() + + if (!ChestStealer.blackList.contains(itemName)) { + MessageSendHelper.sendErrorMessage("&c$itemName is not in the BlackList") + } else { + ChestStealer.blackList.remove(itemName) + MessageSendHelper.sendChatMessage("$itemName has been removed from the BlackList") + } + } + } + } + + literal("list") { + execute("List items in the BlackList") { + var list = ChestStealer.blackList.joinToString() + if (list.isEmpty()) list = "&cNo items!" + MessageSendHelper.sendChatMessage("BlackList:\n$list") + } + } + + literal("reset", "default") { + execute("Reset the BlackList to defaults") { + ChestStealer.blackList.resetValue() + MessageSendHelper.sendChatMessage("BlackList to defaults") + } + } + + literal("clear") { + execute("Set the BlackList to nothing") { + ChestStealer.blackList.clear() + MessageSendHelper.sendChatMessage("BlackList was cleared") + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/command/commands/VanishCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/VanishCommand.kt index 270ab6302..dca832814 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/VanishCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/VanishCommand.kt @@ -17,16 +17,16 @@ object VanishCommand : ClientCommand( vehicle = player.ridingEntity?.also { player.dismountRidingEntity() world.removeEntityFromWorld(it.entityId) - sendChatMessage("Vehicle " + formatValue(it.name) + " removed") + sendChatMessage("Vehicle " + formatValue(it.name) + " ID: " + formatValue(it.entityId) + " dismounted and removed.") } } else { vehicle?.let { it.isDead = false world.addEntityToWorld(it.entityId, it) player.startRiding(it, true) - sendChatMessage("Vehicle " + formatValue(it.name) + " created") vehicle = null - } ?: sendChatMessage("Not riding any vehicles") + sendChatMessage("Vehicle " + formatValue(it.name) + " ID: " + formatValue(it.entityId) + " created and mounted.") + } ?: sendChatMessage("Not riding any vehicles.") } } } diff --git a/src/main/kotlin/com/lambda/client/command/commands/VanishNoKillCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/VanishNoKillCommand.kt new file mode 100644 index 000000000..de9a8339f --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/commands/VanishNoKillCommand.kt @@ -0,0 +1,31 @@ +package com.lambda.client.command.commands + +import com.lambda.client.command.ClientCommand +import com.lambda.client.util.text.MessageSendHelper.sendChatMessage +import com.lambda.client.util.text.formatValue +import net.minecraft.entity.Entity + +object VanishNoKillCommand : ClientCommand( + name = "vanishNoKill", + description = "Allows you to vanish using an entity, without killing the entity off." +) { + private var vehicle: Entity? = null + + init { + executeSafe { + if (player.ridingEntity != null && vehicle == null) { + vehicle = player.ridingEntity?.also { + player.dismountRidingEntity() + sendChatMessage("Vehicle " + formatValue(it.name) + " ID: " + formatValue(it.entityId) + " dismounted.") + } + } else { + vehicle?.let { + it.isDead = false + player.startRiding(it, true) + sendChatMessage("Vehicle " + formatValue(it.name) + " ID: " + formatValue(it.entityId) + " mounted.") + vehicle = null + } ?: sendChatMessage("Not riding any vehicles.") + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/command/commands/WhiteListCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/WhiteListCommand.kt new file mode 100644 index 000000000..94e4d9152 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/commands/WhiteListCommand.kt @@ -0,0 +1,65 @@ +package com.lambda.client.command.commands + +import com.lambda.client.command.ClientCommand +import com.lambda.client.module.modules.player.ChestStealer +import com.lambda.client.util.text.MessageSendHelper + +// TODO: Remove once GUI has List +object WhiteListCommand : ClientCommand( + name = "whiteList", + description = "Modify whiteList items for ChestStealer module" +) { + init { + literal("add", "+") { + item("item") { itemArg -> + execute("Add an item to the WhiteList") { + val itemName = itemArg.value.registryName!!.toString() + + if (ChestStealer.whiteList.contains(itemName)) { + MessageSendHelper.sendErrorMessage("&c$itemName is already added to the WhiteList") + } else { + ChestStealer.whiteList.add(itemName) + MessageSendHelper.sendChatMessage("$itemName has been added to the WhiteList") + } + } + } + } + + literal("del", "remove", "-") { + item("item") { itemArg -> + execute("Remove an item from the WhiteList") { + val itemName = itemArg.value.registryName!!.toString() + + if (!ChestStealer.whiteList.contains(itemName)) { + MessageSendHelper.sendErrorMessage("&c$itemName is not in the WhiteList") + } else { + ChestStealer.whiteList.remove(itemName) + MessageSendHelper.sendChatMessage("$itemName has been removed from the WhiteList") + } + } + } + } + + literal("list") { + execute("List items in the WhiteList") { + var list = ChestStealer.whiteList.joinToString() + if (list.isEmpty()) list = "&cNo items!" + MessageSendHelper.sendChatMessage("WhiteList:\n$list") + } + } + + literal("reset", "default") { + execute("Reset the WhiteList to defaults") { + ChestStealer.whiteList.resetValue() + MessageSendHelper.sendChatMessage("WhiteList to defaults") + } + } + + literal("clear") { + execute("Set the WhiteList to nothing") { + ChestStealer.whiteList.clear() + MessageSendHelper.sendChatMessage("WhiteList was cleared") + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt index 08bb4f8b6..17721783e 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt @@ -5,7 +5,6 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.RenderRadarEvent import com.lambda.client.gui.hudgui.HudElement import com.lambda.client.manager.managers.FriendManager -import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.util.EntityUtils import com.lambda.client.util.EntityUtils.isNeutral import com.lambda.client.util.EntityUtils.isPassive @@ -28,7 +27,8 @@ internal object Radar : HudElement( description = "Shows entities and new chunks" ) { private val zoom by setting("Zoom", 3f, 1f..10f, 0.1f) - private val chunkLines by setting("Chunk Lines", true) + private val chunkLines by setting("Chunk Lines", true, description = "Causes performance loss on high zoom.") + private val radarBackground by setting("Radar Background Color", ColorHolder(31, 10, 18, 235)) private val players = setting("Players", true) private val passive = setting("Passive Mobs", false) @@ -54,7 +54,7 @@ internal object Radar : HudElement( private fun SafeClientEvent.drawBorder(vertexHelper: VertexHelper) { glTranslated(radius.toDouble(), radius.toDouble(), 0.0) - drawCircleFilled(vertexHelper, radius = radius.toDouble(), color = GuiColors.backGround) + drawCircleFilled(vertexHelper, radius = radius.toDouble(), color = radarBackground) drawCircleOutline(vertexHelper, radius = radius.toDouble(), lineWidth = 1.8f, color = primaryColor) glRotatef(player.rotationYaw + 180, 0f, 0f, -1f) } diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt index 404e62dba..b47bd0f0e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt @@ -3,6 +3,7 @@ package com.lambda.client.module.modules.player import com.lambda.client.event.SafeClientEvent import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.setting.settings.impl.collection.CollectionSetting import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.items.* @@ -23,11 +24,20 @@ object ChestStealer : Module( description = "Automatically steal or store items from containers", category = Category.PLAYER ) { + + private val defaultWhiteList = linkedSetOf( + "minecraft:cobblestone" + ) + private val defaultBlackList = linkedSetOf( + "minecraft:cobblestone" + ) + val mode by setting("Mode", Mode.TOGGLE) private val movingMode by setting("Moving Mode", MovingMode.QUICK_MOVE) - private val ignoreEjectItem by setting("Ignores Eject Item", false, description = "Ignore AutoEject items in InventoryManager") private val delay by setting("Delay", 5, 0..20, 1, description = "Move stack delay", unit = " ticks") - private val onlyShulkers by setting("Only Shulkers", false, description = "Only move shulker boxes") + private val selectionMode by setting("Item Selection Mode", SelectionMode.ANY, description = "Items to move.") + val whiteList = setting(CollectionSetting("WhiteList", defaultWhiteList)) + val blackList = setting(CollectionSetting("BlackList", defaultBlackList)) enum class Mode { ALWAYS, TOGGLE, MANUAL @@ -37,6 +47,10 @@ object ChestStealer : Module( QUICK_MOVE, PICKUP, THROW } + private enum class SelectionMode { + ANY, SHULKERS, WHITELIST, BLACKLIST, EJECT_IGNORE + } + private enum class ContainerMode(val offset: Int) { STEAL(36), STORE(0) } @@ -137,12 +151,14 @@ object ChestStealer : Module( for (slot in 0 until getContainerSlotSize()) { val item = container[slot].item if (item == Items.AIR) continue - if (ignoreEjectItem && InventoryManager.ejectList.contains(item.registryName.toString())) continue - if (!onlyShulkers || item is ItemShulkerBox) { - return slot + when (selectionMode){ + SelectionMode.ANY -> return slot + SelectionMode.SHULKERS -> if (item is ItemShulkerBox) return slot + SelectionMode.WHITELIST -> if (whiteList.contains(item.registryName.toString())) return slot + SelectionMode.BLACKLIST -> if (blackList.contains(item.registryName.toString())) return slot + SelectionMode.EJECT_IGNORE -> if (!InventoryManager.ejectList.contains(item.registryName.toString())) return slot } } - return null } @@ -154,11 +170,14 @@ object ChestStealer : Module( val item = container[slot].item if (item == Items.AIR) continue if (player.openContainer is ContainerShulkerBox && item is ItemShulkerBox) continue - if (!onlyShulkers || item is ItemShulkerBox) { - return slot + when (selectionMode){ + SelectionMode.ANY -> return slot + SelectionMode.SHULKERS -> if (item is ItemShulkerBox) return slot + SelectionMode.WHITELIST -> if (whiteList.contains(item.registryName.toString())) return slot + SelectionMode.BLACKLIST -> if (blackList.contains(item.registryName.toString())) return slot + SelectionMode.EJECT_IGNORE -> if (!InventoryManager.ejectList.contains(item.registryName.toString())) return slot } } - return null } 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 1ea57074d..ca6ee9843 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 @@ -43,38 +43,44 @@ 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 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 chunkGridColor by setting("Grid Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }, description = "Might cause performance issues on high zoom. Disable @ Client>HudEditor>Radar>Chunk Lines") + private val oldChunkColor by setting("Old Chunk Color", ColorHolder(100, 100, 100, 100), true, { renderMode != RenderMode.WORLD }, description = "Old chunks. (Baritone cache + Fullchunk() = True). Some distant Chunks might be false positives.") private val newChunkColor by setting("New Chunk Color", ColorHolder(255, 0, 0, 100), true, { renderMode != RenderMode.WORLD }) - private val saveNewChunks by setting("Save New Chunks", false) - 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 by setting("Close file", false, { saveNewChunks }, consumer = { _, _ -> + private val saveChunks by setting("Save Chunks", false) + private val saveOption by setting("Save Option", SaveOption.EXTRA_FOLDER, { saveChunks }) + private val alsoSaveNormalCoords by setting("Save Normal Coords", false, { saveChunks }) + private val saveMode by setting("Save Mode", SaveMode.OLD, { saveChunks }, description = "Save old / new chunks") + + private val closeFile by setting("Close file", false, { saveChunks }, consumer = { _, _ -> logWriterClose() MessageSendHelper.sendChatMessage("$chatName Saved file to $path!") false }) - private val openNewChunksFolder by setting("Open NewChunks Folder...", false, { saveNewChunks }, consumer = { _, _ -> + private val openNewChunksFolder by setting("Open NewChunks Folder...", false, { saveChunks }, consumer = { _, _ -> FolderUtils.openFolder(FolderUtils.newChunksFolder) false }) 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 color by setting("Color", ColorHolder(255, 64, 64, 200), description = "World 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 removeMode by setting("Remove Mode", RemoveMode.AGE, description = "Mode to use for removing chunks") + private val range by setting("Render Range", 512, 64..2048, 32,{ renderMode != RenderMode.RADAR }, description = "Maximum range for chunks to be highlighted in the world.") + private val removeMode by setting("Remove Mode", RemoveMode.AGE, description = "Mode to use for removing chunks. Unload might generate bad data on saving feature and never will cause performance issues eventually.") private val maxAge by setting("Max age", 10, 1..600, 1, { removeMode == RemoveMode.AGE }, description = "Maximum age of chunks since recording", unit = "m") + private val maxDist by setting("Max Distance", 10000, 1000..100000, 1000, { removeMode == RemoveMode.DIST }, description = "Maximum distance to chunks until unload.", unit = "Meter / Blocks") private var lastSetting = LastSetting() private var logWriter: PrintWriter? = null - private val chunks = ConcurrentHashMap() + private val newChunks = ConcurrentHashMap() + private val oldChunks = ConcurrentHashMap() + private val savedChunks = ConcurrentHashMap() private val timer = TickTimer(TimeUnit.SECONDS) init { onDisable { logWriterClose() - chunks.clear() + oldChunks.clear() + newChunks.clear() + savedChunks.clear() MessageSendHelper.sendChatMessage("$chatName Saved and cleared chunks!") } @@ -90,13 +96,22 @@ object NewChunks : Module( && timer.tick(5) ) { val currentTime = System.currentTimeMillis() - chunks.values.removeIf { chunkAge -> currentTime - chunkAge > maxAge * 60 * 1000 } + newChunks.values.removeIf { chunkAge -> currentTime - chunkAge > maxAge * 60 * 1000 } + oldChunks.values.removeIf { chunkAge -> currentTime - chunkAge > maxAge * 60 * 1000 } + savedChunks.values.removeIf { chunkAge -> currentTime - chunkAge > maxAge * 60 * 1000 } + } + else if (it.phase == TickEvent.Phase.END + && removeMode == RemoveMode.DIST + && timer.tick(5) + ){ + newChunks.keys.removeIf { chunkKey -> player.distanceTo(chunkKey) > maxDist } + oldChunks.keys.removeIf { chunkKey -> player.distanceTo(chunkKey) > maxDist } + savedChunks.keys.removeIf { chunkKey -> player.distanceTo(chunkKey) > maxDist } } } safeListener { if (renderMode == RenderMode.RADAR) return@safeListener - val y = yOffset.toDouble() + if (relative) getInterpolatedPos(player, LambdaTessellator.pTicks()).y else 0.0 glLineWidth(thickness) @@ -104,7 +119,7 @@ object NewChunks : Module( val buffer = LambdaTessellator.buffer - chunks.filter { player.distanceTo(it.key) < range }.keys.forEach { chunkPos -> + newChunks.filter { player.distanceTo(it.key) < range }.keys.forEach { chunkPos -> 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.toDouble(), y, chunkPos.zStart.toDouble()).color(color.r, color.g, color.b, color.a).endVertex() @@ -118,65 +133,80 @@ object NewChunks : Module( } 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 + val newChunkRects: MutableList> = mutableListOf() // at high zooms (further zoomed out) there will be thousands of rects being rendered // buffering rects here to reduce GL calls and improve FPS - val distantChunkRects: MutableList> = mutableListOf() + val oldChunkRects: MutableList> = mutableListOf() val chunkGridRects: MutableList> = mutableListOf() 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 chunkPos = ChunkPos((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) { - distantChunkRects.add(Pair(pos0, pos1)) + if (newChunks.containsKey(chunkPos)){ + newChunkRects.add(Pair(pos0, pos1)) + } + else if (!chunk.isLoaded && isCachedChunk){ + oldChunkRects.add(Pair(pos0, pos1)) } - chunkGridRects.add(Pair(pos0, pos1)) + else if (chunk.isLoaded) { + oldChunkRects.add(Pair(pos0, pos1)) + } + if (it.chunkLines) chunkGridRects.add(Pair(pos0, pos1)) } } } - if (distantChunkRects.isNotEmpty()) RenderUtils2D.drawRectFilledList(it.vertexHelper, distantChunkRects, distantChunkColor) + if (oldChunkRects.isNotEmpty()) RenderUtils2D.drawRectFilledList(it.vertexHelper, oldChunkRects, oldChunkColor) if (it.chunkLines && chunkGridRects.isNotEmpty()) RenderUtils2D.drawRectOutlineList(it.vertexHelper, chunkGridRects, 0.3f, chunkGridColor) - - val newChunkRects: MutableList> = mutableListOf() - chunks.keys.forEach { 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)) { - newChunkRects.add(Pair(pos0, pos1)) - } - } if (newChunkRects.isNotEmpty()) RenderUtils2D.drawRectFilledList(it.vertexHelper, newChunkRects, newChunkColor) } 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) + if (!event.packet.isFullChunk) { + oldChunks.remove(chunkPos) + newChunks.putIfAbsent(chunkPos, System.currentTimeMillis()) + } + else if (!newChunks.containsKey(chunkPos)){ + oldChunks.putIfAbsent(chunkPos, System.currentTimeMillis()) + } } } safeListener { - if (removeMode == RemoveMode.UNLOAD) - chunks.remove(it.chunk.pos) + if (removeMode == RemoveMode.UNLOAD) { + newChunks.remove(it.chunk.pos) + oldChunks.remove(it.chunk.pos) + savedChunks.remove(it.chunk.pos) + } + if (saveChunks && !savedChunks.containsKey(it.chunk.pos)) { + if (saveMode == SaveMode.OLD && oldChunks.containsKey(it.chunk.pos)) { + saveChunk(it.chunk.pos) + savedChunks[it.chunk.pos] = System.currentTimeMillis() + } + else if (saveMode == SaveMode.NEW && newChunks.containsKey(it.chunk.pos)) { + saveChunk(it.chunk.pos) + savedChunks[it.chunk.pos] = System.currentTimeMillis() + } + } } } // needs to be synchronized so no data gets lost - private fun SafeClientEvent.saveNewChunk(chunk: ChunkPos) { - saveNewChunk(testAndGetLogWriter(), getNewChunkInfo(chunk)) + private fun SafeClientEvent.saveChunk(chunk: ChunkPos) { + saveChunk(testAndGetLogWriter(), getNewChunkInfo(chunk)) } private fun getNewChunkInfo(chunk: ChunkPos): String { @@ -258,11 +288,6 @@ object NewChunks : Module( file = File(file, "DIM$dimension") } - // maybe we want to save it in region folder - if (saveInRegionFolder) { - file = File(file, "region") - } - file = File(file, "logs") val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Date()) 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... @@ -313,7 +338,7 @@ object NewChunks : Module( return Vec2d((x shl 4).toDouble(), (z shl 4).toDouble()).minus(playerOffset).div(scale.toDouble()) } - private fun saveNewChunk(log: PrintWriter?, data: String) { + private fun saveChunk(log: PrintWriter?, data: String) { log!!.println(data) } @@ -323,16 +348,19 @@ object NewChunks : Module( @Suppress("unused") private enum class RemoveMode { - UNLOAD, AGE, NEVER + UNLOAD, AGE, DIST, NEVER } enum class RenderMode { WORLD, RADAR, BOTH } + enum class SaveMode { + NEW, OLD + } + private class LastSetting { var lastSaveOption: SaveOption? = null - var lastInRegion = false var lastSaveNormal = false var dimension = 0 var ip: String? = null @@ -348,15 +376,13 @@ object NewChunks : Module( fun testChange(event: SafeClientEvent): Boolean { // these somehow include the test whether its null return saveOption != lastSaveOption - || saveInRegionFolder != lastInRegion - || alsoSaveNormalCoords != lastSaveNormal + || (alsoSaveNormalCoords && alsoSaveNormalCoords != lastSaveNormal) || dimension != event.player.dimension || mc.currentServerData?.serverIP != ip } private fun update(event: SafeClientEvent) { lastSaveOption = saveOption - lastInRegion = saveInRegionFolder lastSaveNormal = alsoSaveNormalCoords dimension = event.player.dimension ip = mc.currentServerData?.serverIP