Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChestCounter HUD element and StorageESP module list info #568

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.lambda.client.gui.hudgui.elements.world

import com.lambda.client.event.SafeClientEvent
import com.lambda.client.gui.hudgui.LabelHud
import com.lambda.client.manager.managers.ChestCountManager

internal object ChestCounter : LabelHud(
name = "ChestCounter",
category = Category.WORLD,
description = "Displays the number of chests and shulkers currently loaded"
) {
private val dubs by setting("Count Dubs", true, description = "Counts double chests instead of individual chests")
private val shulkers by setting("Count Shulkers", true, description = "Counts shulkers in the world")

override fun SafeClientEvent.updateText() {
if (dubs) {
displayText.add("Dubs:", primaryColor)
displayText.add("${ChestCountManager.dubsCount}", secondaryColor)
displayText.add("Chests:", primaryColor)
displayText.add("${ChestCountManager.chestCount - (ChestCountManager.dubsCount * 2)}", secondaryColor)
} else {
displayText.add("Chests:", primaryColor)
displayText.add("${ChestCountManager.chestCount}", secondaryColor)
}

if (!shulkers) return
displayText.add("Shulkers:", primaryColor)
displayText.add("${ChestCountManager.shulkerCount}", secondaryColor)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.lambda.client.manager.managers

import com.lambda.client.event.SafeClientEvent
import com.lambda.client.gui.hudgui.elements.world.ChestCounter
import com.lambda.client.manager.Manager
import com.lambda.client.module.modules.render.StorageESP
import com.lambda.client.util.TickTimer
import com.lambda.client.util.TimeUnit
import com.lambda.client.util.threads.defaultScope
import com.lambda.client.util.threads.safeListener
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import net.minecraft.tileentity.TileEntityChest
import net.minecraft.tileentity.TileEntityShulkerBox
import net.minecraftforge.fml.common.gameevent.TickEvent

object ChestCountManager : Manager {
private const val SEARCH_DELAY_TICKS = 5L
private val delayTimer: TickTimer = TickTimer(TimeUnit.TICKS)
var chestCount = 0
private set
var dubsCount = 0
private set
var shulkerCount = 0
private set
private var chestCountSearchJob: Job? = null

init {
safeListener<TickEvent.ClientTickEvent> {
if (it.phase != TickEvent.Phase.END) return@safeListener
if (!ChestCounter.visible && !StorageESP.chestCountSetting) return@safeListener
if (chestCountSearchJob?.isActive == true) return@safeListener
if (!delayTimer.tick(SEARCH_DELAY_TICKS)) return@safeListener

chestCountSearchJob = defaultScope.launch {
searchLoadedTileEntities()
delayTimer.reset()
}
}
}

private fun SafeClientEvent.searchLoadedTileEntities() {
val chests = world.loadedTileEntityList.filterIsInstance<TileEntityChest>()

dubsCount = chests.count { it.adjacentChestXPos != null || it.adjacentChestZPos != null }
chestCount = chests.size
shulkerCount = world.loadedTileEntityList.filterIsInstance<TileEntityShulkerBox>().size
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.lambda.client.module.modules.render
import com.lambda.client.event.SafeClientEvent
import com.lambda.client.event.events.RenderWorldEvent
import com.lambda.client.event.listener.listener
import com.lambda.client.manager.managers.ChestCountManager
import com.lambda.client.module.Category
import com.lambda.client.module.Module
import com.lambda.client.util.color.ColorHolder
Expand Down Expand Up @@ -39,7 +40,7 @@ object StorageESP : Module(
private val dispenser by setting("Dispenser", false, { page == Page.TYPE })
private val hopper by setting("Hopper", false, { page == Page.TYPE })
private val cart by setting("Minecart", false, { page == Page.TYPE })
private val infinite by setting("Infinite Range", true) // To avoid a hard to control range slider
private val infinite by setting("Infinite Range", true, { page == Page.TYPE }) // To avoid a hard to control range slider
private val range by setting("Range", 64, 8..512, 1, { page == Page.TYPE && !infinite }, unit = " blocks")

/* Color settings */
Expand All @@ -61,12 +62,18 @@ object StorageESP : Module(
private val aTracer by setting("Tracer Alpha", 200, 0..255, 1, { page == Page.RENDER && tracer })
private val thickness by setting("Line Thickness", 2.0f, 0.25f..5.0f, 0.25f, { page == Page.RENDER })

/* Count settings */
val chestCountSetting by setting("Count", true, { page == Page.COUNT })
private val dubs by setting("Dubs", true, visibility = { chestCountSetting && page == Page.COUNT})

private enum class Page {
TYPE, COLOR, RENDER
TYPE, COLOR, RENDER, COUNT
}

override fun getHudInfo(): String {
return renderer.size.toString()
return if (chestCountSetting)
(if(dubs) "${ChestCountManager.dubsCount}" else "${ChestCountManager.chestCount}")
else ""
}

private var cycler = HueCycler(600)
Expand Down