@@ -5,22 +5,39 @@ import { TextDisplay } from '../outliner/textDisplay'
55import { VanillaBlockDisplay } from '../outliner/vanillaBlockDisplay'
66import { VanillaItemDisplay } from '../outliner/vanillaItemDisplay'
77
8- export function getTotalEntityCount ( ) {
9- let count = 1 // Start with 1 for the root entity
10- for ( const node of Outliner . nodes ) {
11- switch ( true ) {
12- case node instanceof Group :
13- if ( node . children . some ( child => child instanceof Cube ) ) count ++
14- break
15- case node instanceof TextDisplay :
16- case node instanceof VanillaBlockDisplay :
17- case node instanceof VanillaItemDisplay :
18- case node instanceof Interaction :
19- case node . type === 'camera' :
20- count ++
21- }
8+ export function getEntityCounts ( ) {
9+ const groupEntities = Group . all . filter (
10+ group => group . export && group . children . some ( child => child instanceof Cube )
11+ ) . length
12+
13+ const displayEntities = [
14+ ...TextDisplay . all ,
15+ ...VanillaBlockDisplay . all ,
16+ ...VanillaItemDisplay . all ,
17+ ] . filter ( display => display . export ) . length
18+
19+ const locatorEntities = Locator . all . filter (
20+ locator => locator . export && locator . config ?. use_entity
21+ ) . length
22+
23+ const cameraEntities = OutlinerElement . types . camera
24+ ? // @ts -expect-error - Camera class isn't typed as a class.
25+ OutlinerElement . types . camera . all . length
26+ : 0
27+
28+ const interactionEntities = Interaction . all . filter ( interaction => interaction . export ) . length
29+
30+ const totalEntities =
31+ 1 + groupEntities + displayEntities + locatorEntities + cameraEntities + interactionEntities
32+
33+ return {
34+ groupEntities,
35+ displayEntities,
36+ locatorEntities,
37+ cameraEntities,
38+ interactionEntities,
39+ totalEntities,
2240 }
23- return count
2441}
2542
2643registerDeletableHandlerPatch ( {
@@ -29,7 +46,7 @@ registerDeletableHandlerPatch({
2946 const widget = new BarText ( `animated_java:toolbar/entity_counter` , {
3047 text : `E: 0` ,
3148 onUpdate ( ) {
32- widget . set ( `E: ${ getTotalEntityCount ( ) } ` )
49+ widget . set ( `E: ${ getEntityCounts ( ) . totalEntities } ` )
3350 } ,
3451 click : openEntityCountDialog ,
3552 } )
0 commit comments