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.kt12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt
index dcb46ef..0bf768f 100644
--- a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt
+++ b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt
@@ -3,6 +3,7 @@ package dulkirmod.features
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.DulkirConfig
import net.minecraft.entity.Entity
+import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -31,4 +32,15 @@ object MemoryLeakFix {
private fun isNullVec(entity: Entity): Boolean {
return entity.posX == 0.0 && entity.posY == 0.0 && entity.posZ == 0.0
}
+
+ fun clearBlankStands() {
+ val world = mc.theWorld ?: return
+ val currentEnts = world.loadedEntityList
+ currentEnts.forEach {
+ if (it !is EntityArmorStand) return
+ if (it.name != "Armor Stand") return
+ if (it.inventory.any{slot -> slot != null}) return
+ world.removeEntityFromWorld(it.entityId)
+ }
+ }
} \ No newline at end of file