@@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer
14
14
import net.minecraft.entity.projectile.EntityEgg
15
15
import net.minecraft.entity.projectile.EntitySnowball
16
16
import net.minecraft.entity.projectile.EntityWitherSkull
17
+ import net.minecraft.tileentity.TileEntityLockable
17
18
import java.util.*
18
19
19
20
internal object EntityList : LabelHud(
@@ -26,10 +27,15 @@ internal object EntityList : LabelHud(
26
27
private val passive by setting(" Passive Mobs" , true )
27
28
private val neutral by setting(" Neutral Mobs" , true )
28
29
private val hostile by setting(" Hostile Mobs" , true )
30
+ private val tileEntities by setting(" Tile Entities" , true )
31
+ private val onlyContainer by setting(" Only Containers" , true , { tileEntities })
29
32
private val maxEntries by setting(" Max Entries" , 8 , 4 .. 32 , 1 )
30
33
private val range by setting(" Range" , 64 , 16 .. 256 , 16 , fineStep = 1 )
31
34
32
- private val cacheMap by AsyncCachedValue (50L ) {
35
+ private var remainingEntriesEntity = 0
36
+ private var remainingEntriesTileEntity = 0
37
+
38
+ private val entityCacheMap by AsyncCachedValue (50L ) {
33
39
val map = TreeMap <String , Int >()
34
40
35
41
runSafe {
@@ -54,18 +60,46 @@ internal object EntityList : LabelHud(
54
60
}
55
61
}
56
62
57
- remainingEntries = map.size - maxEntries
63
+ remainingEntriesEntity = map.size - maxEntries
64
+ map.entries.take(maxEntries)
65
+ }
66
+
67
+ private val tileEntityCacheMap by AsyncCachedValue (50L ) {
68
+ val map = TreeMap <String , Int >()
69
+
70
+ runSafe {
71
+ if (tileEntities) world.loadedTileEntityList.filter {
72
+ if (onlyContainer) it is TileEntityLockable else true
73
+ }.mapNotNull {
74
+ map[it.blockType.localizedName] = map.getOrDefault(it.blockType.localizedName, 0 ) + 1
75
+ }
76
+ }
77
+
78
+ remainingEntriesTileEntity = map.size - maxEntries
58
79
map.entries.take(maxEntries)
59
80
}
60
- private var remainingEntries = 0
61
81
62
82
override fun SafeClientEvent.updateText () {
63
- for ((name, count) in cacheMap) {
64
- displayText.add(name, primaryColor)
65
- displayText.addLine(" x$count " , secondaryColor)
83
+ if (entityCacheMap.isNotEmpty()) {
84
+ if (tileEntities) displayText.addLine(" Entities" , secondaryColor)
85
+ for ((name, count) in entityCacheMap) {
86
+ displayText.add(name, primaryColor)
87
+ displayText.addLine(" x$count " , secondaryColor)
88
+ }
89
+ if (remainingEntriesEntity > 0 ) {
90
+ displayText.addLine(" ...and $remainingEntriesEntity more" )
91
+ }
66
92
}
67
- if (remainingEntries > 0 ) {
68
- displayText.addLine(" ...and $remainingEntries more" )
93
+
94
+ if (tileEntityCacheMap.isNotEmpty()) {
95
+ displayText.addLine(" TileEntities" , secondaryColor)
96
+ for ((name, count) in tileEntityCacheMap) {
97
+ displayText.add(name, primaryColor)
98
+ displayText.addLine(" x$count " , secondaryColor)
99
+ }
100
+ if (remainingEntriesTileEntity > 0 ) {
101
+ displayText.addLine(" ...and $remainingEntriesTileEntity more" )
102
+ }
69
103
}
70
104
}
71
105
0 commit comments