aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt')
-rw-r--r--src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt
index 0c7fcb9..5edde33 100644
--- a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt
+++ b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt
@@ -2,10 +2,13 @@ package dulkirmod.features
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.DulkirConfig
+import dulkirmod.utils.WorldRenderUtils
import net.minecraft.entity.Entity
import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.client.event.RenderLivingEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
+import java.awt.Color
object MemoryLeakFix {
private var lastClear = System.currentTimeMillis()
@@ -39,9 +42,34 @@ object MemoryLeakFix {
val currentEnts = world.loadedEntityList
currentEnts.forEach {
if (it !is EntityArmorStand) return@forEach
- if (it.name != "Armor Stand") return@forEach
+ if (it.hasCustomName()) return@forEach
if (it.inventory.any{slot -> slot != null}) return@forEach
+ if (it.ticksExisted < 1200) return@forEach
world.removeEntityFromWorld(it.entityId)
}
}
+
+ @SubscribeEvent
+ fun displayBlankStands(event: RenderLivingEvent.Post<*>) {
+ if (!DulkirConfig.debugStandRemoval) return
+ if (event.entity !is EntityArmorStand) return
+ if (event.entity.hasCustomName()) return
+ if (event.entity.inventory.any{slot -> slot != null}) return
+ val pos = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z)
+ val x = pos[0]
+ val y = pos[1]
+ val z = pos[2]
+
+ WorldRenderUtils.drawCustomBox(
+ x - .5,
+ 1.0,
+ y - .5,
+ 1.0,
+ z - .5,
+ 1.0,
+ Color(15, 247, 236, 255),
+ 3f,
+ phase = true
+ )
+ }
} \ No newline at end of file