API reference / @jsprismarine/prismarine / entity/data/entityIndex / EntityIndex
Class: EntityIndex
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:103
The live entities of one dimension, indexed by where they stand.
Constructors
Constructor
new EntityIndex():
EntityIndex
Returns
EntityIndex
Properties
chunkChanged
chunkChanged: ((
chunkX,chunkZ) =>void) |undefined
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:148
Hears each chunk a store entity other than a player enters, leaves or moves within, a dropped stack's each time it changes two-block cell. A cell is sixteen blocks wide and aligned to the chunks, so the cell an entity is filed under is the chunk it stands in. The world marks the chunk changed, so a save writes the chunk an entity left as well as the one it entered, and a chunk does not leave the world with an entity that moved since the chunk was saved.
Accessors
occupiedCells
Get Signature
get occupiedCells():
number
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:170
How many cell lists hold anything, across every layer. Zero once the index is empty.
Returns
number
size
Get Signature
get size():
number
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:165
How many entities the index holds.
Returns
number
Methods
add()
add(
entity):void
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:177
Puts one entity in the index, at the position it stands at now.
Parameters
entity
Returns
void
blastWithin()
blastWithin(
x,z,radius):DataEntity[]
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:265
Every entity of the store within a horizontal radius of a point, dropped stacks included, in ascending runtime id order. What a blast catches: Java's ServerExplosion hurts every entity in range, and a stack it hurts is gone. Horizontal, as the blast applies its own exact reach.
Parameters
x
number
z
number
radius
number
Returns
candidatesExamined()
candidatesExamined():
number
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:160
How many candidates the queries so far have read out of cells, counted from the index's creation.
A query reads every entity in each cell it touches and no other, so the difference across one query is the cost of that query.
Returns
number
itemsInChunk()
itemsInChunk(
chunkX,chunkZ):DataEntity[]
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:249
The dropped stacks of the store that lie in one chunk, in ascending runtime id order, which a chunk that leaves the world takes with it beside EntityIndex.storeInChunk.
Parameters
chunkX
number
chunkZ
number
Returns
itemsWithin()
itemsWithin(
x,z,radius):DataEntity[]
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:210
Dropped items within a horizontal radius of a point, in ascending runtime id order.
Horizontal only, as item merge and pickup ask: each applies its own exact distance to what comes back.
Parameters
x
number
z
number
radius
number
Returns
refile()
refile(
entity):void
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:318
Moves one entity to the cell it stands in now, which a position write calls.
Parameters
entity
Returns
void
refreshBox()
refreshBox(
entity):void
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:490
Refreshes the size index after a live component set changes.
Parameters
entity
Returns
void
refreshFamilies()
refreshFamilies(
entity):void
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:350
Updates the family index after an entity applies its data-driven events.
Parameters
entity
Returns
void
remove()
remove(
entity):void
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:188
Takes one entity out of the index.
Parameters
entity
Returns
void
storeInChunk()
storeInChunk(
chunkX,chunkZ):DataEntity[]
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:240
The store's entities other than dropped stacks that stand in one chunk, in ascending runtime id order, which is what a chunk that leaves the world takes with it.
Parameters
chunkX
number
chunkZ
number
Returns
storeWithin()
storeWithin(
x,z,radius):DataEntity[]
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:273
The store's entities other than dropped stacks within a horizontal radius of a point, in ascending runtime id order. Horizontal, as a blast asks: it applies its own exact reach.
Parameters
x
number
z
number
radius
number
Returns
within()
within(
center,radius,families?):DataEntity[]
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:378
Every entity within a radius of a position, in ascending runtime id order.
The order is the contract, not the cells: goalWorld.mobs breaks a tie in distance by it, which decides who a zombie picks out of a crowd standing together, and a cell's list is in whatever order moves left it.
Parameters
center
radius
number
families?
readonly string[]
Returns
withinBox()
withinBox(
min,max):DataEntity[]
Defined in: packages/prismarine/src/entity/data/entityIndex.ts:454
Entities whose Java collision boxes strictly intersect an axis-aligned box, in ascending runtime id order.