API reference / @jsprismarine/prismarine / blockentity/BlockEntities / MobSpawner
Class: MobSpawner
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:313
A monster spawner.
The mob and the rates are read as written and written back with vanilla's defaults filled in, so a spawner a feature placed with nothing but its mob leaves the server as the one vanilla would have saved, which is also the one the client knows how to draw.
Extends
Properties
constructor
constructor: typeof
BlockEntity
Defined in: packages/prismarine/src/blockentity/BlockEntity.ts:23
TypeScript types this.constructor as Function. Declaring it as the class itself lets BlockEntity.getId read the static ID the subclass set. Emits nothing.
Inherited from
position
readonlyposition:Vector3
Defined in: packages/prismarine/src/blockentity/BlockEntity.ts:28
Inherited from
ID
readonlystaticID:"MobSpawner"='MobSpawner'
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:314
Vanilla's id string - Chest, Sign, Furnace. Not a namespaced identifier.
Overrides
Methods
canReuseSerialization()
canReuseSerialization():
boolean
Defined in: packages/prismarine/src/blockentity/BlockEntity.ts:53
Whether a caller can safely reuse a previously serialized form of this block entity. Mutable getters and setters disable reuse because their changes cannot be observed here.
Returns
boolean
Inherited from
BlockEntity.canReuseSerialization
getDelay()
getDelay():
number
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:327
Ticks until the next spawn cycle.
Returns
number
getEntityIdentifier()
getEntityIdentifier():
string
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:322
The mob it spawns, as a Bedrock identifier, or the empty string for a spawner with none.
Returns
string
getId()
getId():
string
Defined in: packages/prismarine/src/blockentity/BlockEntity.ts:41
Returns
string
Inherited from
getMaxNearbyEntities()
getMaxNearbyEntities():
number
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:347
How many of its mob may stand within MobSpawner.getSpawnRange before a cycle waits.
Returns
number
getMaxSpawnDelay()
getMaxSpawnDelay():
number
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:337
The longest wait a cycle sets for the next, in ticks.
Returns
number
getMinSpawnDelay()
getMinSpawnDelay():
number
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:332
The shortest wait a cycle sets for the next, in ticks.
Returns
number
getPosition()
getPosition():
Vector3
Defined in: packages/prismarine/src/blockentity/BlockEntity.ts:45
Returns
Inherited from
getRequiredPlayerRange()
getRequiredPlayerRange():
number
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:352
How close a player has to be for the spawner to run at all, in blocks.
Returns
number
getSpawnCount()
getSpawnCount():
number
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:342
How many spawns a cycle attempts.
Returns
number
getSpawnRange()
getSpawnRange():
number
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:357
How far out a spawn may land, horizontally, in blocks.
Returns
number
isMovable()
isMovable():
boolean
Defined in: packages/prismarine/src/blockentity/BlockEntity.ts:63
Whether a piston may push this. Vanilla stores it on every block entity.
Returns
boolean
Inherited from
toNBT()
toNBT():
NBTTagCompound
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:365
The compound to write back, with vanilla's rates filled in where the spawner carries none and, for one with a mob, the three fields the client draws it by.
Returns
Overrides
fromNBT()
staticfromNBT(nbt):MobSpawner
Defined in: packages/prismarine/src/blockentity/BlockEntities.ts:316
Parameters
nbt
Returns
MobSpawner