API reference / @jsprismarine/entity-brains / TestWorld
Class: TestWorld
Defined in: testWorld.ts:263
A BrainWorld backed by plain data.
Implements
Constructors
Constructor
new TestWorld(
options?):TestWorld
Defined in: testWorld.ts:301
Parameters
options?
TestWorldOptions = {}
Returns
TestWorld
Properties
blocks
readonlyblocks:Map<string,string>
Defined in: testWorld.ts:272
Block ids by x,y,z. Anything unset is minecraft:air.
blockTags
readonlyblockTags:Map<string,Set<string>>
Defined in: testWorld.ts:274
Block tags by x,y,z.
canBreed
canBreed:
boolean=false
Defined in: testWorld.ts:559
Whether the host says two villagers may breed.
dayTimeTicks
dayTimeTicks:
number
Defined in: testWorld.ts:267
dimension
readonlydimension:string
Defined in: testWorld.ts:264
The dimension id, used to qualify a GlobalPos.
Implementation of
entities
readonlyentities:TestEntity[] =[]
Defined in: testWorld.ts:269
Every entity in the world, including the mobs.
farmSpot
farmSpot:
BlockPos|undefined
Defined in: testWorld.ts:553
Where the farmer's next piece of farming is, which a test sets.
gameEvents
readonlygameEvents:object[] =[]
Defined in: testWorld.ts:279
Every emitGameEvent call, in order.
event
event:
string
pos
pos:
Vec3
source?
optionalsource?:BrainEntity
hero
hero:
boolean=false
Defined in: testWorld.ts:557
Whether the host counts a player as a hero.
items
readonlyitems:TestItemEntity[] =[]
Defined in: testWorld.ts:270
nextRandomPos
nextRandomPos:
Vec3|undefined=undefined
Defined in: testWorld.ts:292
What TestWorld.randomPos returns. A test sets it to make a wander deterministic; undefined means the draw found nothing, which is a real outcome in Java too.
pois
readonlypois: (PoiRecord&object)[] =[]
Defined in: testWorld.ts:275
snifferSeedDrops
readonlysnifferSeedDrops:string[] =[]
Defined in: testWorld.ts:281
Sniffer seed-drop callbacks, in the order they fired.
sonicBooms
readonlysonicBooms:object[] =[]
Defined in: testWorld.ts:283
Warden sonic-boom callbacks, in the order they fired.
source
source:
string
target
target:
string
sounds
readonlysounds:object[] =[]
Defined in: testWorld.ts:277
Every playSound call, in order.
pos
pos:
Vec3
sound
sound:
string
time
time:
number
Defined in: testWorld.ts:266
Advance with TestWorld.advance.
villagerRaidEffects
readonlyvillagerRaidEffects:object[] =[]
Defined in: testWorld.ts:285
Villager raid effects, in the order the host received them.
body
body:
string
effect
effect:
VillagerRaidEffect
villagerRestocks
readonlyvillagerRestocks:string[] =[]
Defined in: testWorld.ts:287
Villagers that were asked to restock, in order.
villagerShown
readonlyvillagerShown:boolean[] =[]
Defined in: testWorld.ts:573
What a villager was showing, in order; undefined is an emptied hand.
villagerTasks
readonlyvillagerTasks:object[] =[]
Defined in: testWorld.ts:555
Every villager task the host was asked to carry out, in order.
body
body:
string
target?
optionaltarget?:BlockPos|BrainEntity
task
task:
VillagerTask
Methods
addPoi()
addPoi(
pos,type):void
Defined in: testWorld.ts:340
Adds a point of interest with a free ticket.
Parameters
pos
type
string
Returns
void
advance()
advance(
ticks?):void
Defined in: testWorld.ts:345
Advances the game time, and the time of day with it.
Parameters
ticks?
number = 1
Returns
void
blockAt()
blockAt(
pos):string
Defined in: testWorld.ts:424
The block a test placed at the position, or minecraft:air.
Parameters
pos
Returns
string
Implementation of
blockTagsAt()
blockTagsAt(
pos):ReadonlySet<string>
Defined in: testWorld.ts:435
The tags a test placed at the position, or an empty set.
Parameters
pos
Returns
ReadonlySet<string>
Implementation of
canSee()
canSee(
body,target):boolean
Defined in: testWorld.ts:404
Defers to the line-of-sight predicate a test passed in, which is true for everything by default.
Parameters
body
target
Returns
boolean
Implementation of
canStandAt()
canStandAt(
position):boolean
Defined in: testWorld.ts:454
Treats air over a placed block as an empty, supported standing position.
Parameters
position
Returns
boolean
Implementation of
claimPoi()
claimPoi(
pos,claimant):boolean
Defined in: testWorld.ts:493
Takes the ticket at the position, and reports false when there is no record or no space left.
Parameters
pos
claimant
Returns
boolean
Implementation of
dayTime()
dayTime():
number
Defined in: testWorld.ts:356
Time of day in ticks, wrapped at 24000.
Returns
number
Implementation of
drop()
drop(
item,position,count?):TestItemEntity
Defined in: testWorld.ts:327
Drops an item stack.
Parameters
item
position
count?
number = 1
Returns
dropSnifferSeed()
dropSnifferSeed(
body):void
Defined in: testWorld.ts:528
Records the point at which the sniffer's host would roll its loot table.
Parameters
body
Returns
void
Implementation of
emitGameEvent()
emitGameEvent(
event,pos,source?):void
Defined in: testWorld.ts:518
Records the vibration in gameEvents, which is what the warden's sensor reads in a test.
Parameters
event
string
pos
source?
Returns
void
Implementation of
findBlock()
findBlock(
center,xzRange,yRange,test):BlockPos|undefined
Defined in: testWorld.ts:440
The matching block nearest the center by Manhattan distance, searched over the box a test filled.
Parameters
center
xzRange
number
yRange
number
test
(block, tags, position) => boolean
Returns
BlockPos | undefined
Implementation of
gameTime()
gameTime():
number
Defined in: testWorld.ts:351
Ticks since the world was built, which TestWorld.advance moves.
Returns
number
Implementation of
isAttackable()
isAttackable(
body,target):boolean
Defined in: testWorld.ts:414
Targetable, and allowed by the attackable predicate a test passed in.
Parameters
body
target
Returns
boolean
Implementation of
isTargetable()
isTargetable(
body,target):boolean
Defined in: testWorld.ts:409
True for a living, non-spectator target the body can see.
Parameters
body
target
Returns
boolean
Implementation of
isVillageHero()
isVillageHero(
_player):boolean
Defined in: testWorld.ts:581
Returns TestWorld.hero.
Parameters
_player
Returns
boolean
Implementation of
isWaterAt()
isWaterAt(
pos):boolean
Defined in: testWorld.ts:429
Whether the block at a position carries Java's water fluid tag.
Parameters
pos
Returns
boolean
Implementation of
isWithinMeleeRange()
isWithinMeleeRange(
body,target):boolean
Defined in: testWorld.ts:419
Compares the straight-line distance against the melee range a test set.
Parameters
body
target
Returns
boolean
Implementation of
itemEntitiesNear()
itemEntitiesNear(
center,xzRange,yRange): readonlyBrainItemEntity[]
Defined in: testWorld.ts:394
Item entities inside the box, which is how Java bounds an item search rather than by radius.
Parameters
center
xzRange
number
yRange
number
Returns
readonly BrainItemEntity[]
Implementation of
livingEntitiesNear()
livingEntitiesNear(
center,radius,exclude,excludeDimensions?): readonlyBrainEntity[]
Defined in: testWorld.ts:373
Every non-item entity whose box intersects the excluded entity's inflated box.
Parameters
center
radius
number
exclude
excludeDimensions?
EntityDimensions = ...
Returns
readonly BrainEntity[]
Implementation of
place()
place(
type,position,options?):TestEntity
Defined in: testWorld.ts:320
Places a non-mob entity, such as a player or a target.
Parameters
type
string
position
options?
TestEntityOptions = {}
Returns
players()
players(): readonly
BrainEntity[]
Defined in: testWorld.ts:389
Every entity a test spawned as minecraft:player, at any distance.
Returns
readonly BrainEntity[]
Implementation of
playSound()
playSound(
sound,pos):void
Defined in: testWorld.ts:513
Records the sound and where it played in sounds.
Parameters
sound
string
pos
Returns
void
Implementation of
pointsOfInterest()
pointsOfInterest(
center,radius,type): readonlyPoiRecord[]
Defined in: testWorld.ts:475
Matching points of interest inside the box, nearest first by horizontal distance.
Parameters
center
radius
number
type
(type) => boolean
Returns
readonly PoiRecord[]
Implementation of
random()
random():
number
Defined in: testWorld.ts:361
The next scripted draw. The last value repeats once the script runs out.
Returns
number
Implementation of
randomInt()
randomInt(
bound):number
Defined in: testWorld.ts:368
The next scripted draw scaled into [0, bound), and 0 when the bound is not positive.
Parameters
bound
number
Returns
number
Implementation of
randomPos()
randomPos(
_body,_request):Vec3|undefined
Defined in: testWorld.ts:470
The position a test parked in nextRandomPos, so a wander target is a fact of the test.
Parameters
_body
_request
Returns
Vec3 | undefined
Implementation of
releasePoi()
releasePoi(
pos,_claimant):void
Defined in: testWorld.ts:504
Frees the ticket at the position. Releasing an unknown position does nothing.
Parameters
pos
_claimant
Returns
void
Implementation of
setBlock()
setBlock(
pos,block,tags?):void
Defined in: testWorld.ts:334
Sets a block and, optionally, its tags.
Parameters
pos
block
string
tags?
readonly string[] = []
Returns
void
snifferDigPosition()
snifferDigPosition(
body):BlockPos
Defined in: testWorld.ts:523
Uses the body's block as the stand-in dig target for brain-only tests.
Parameters
body
Returns
Implementation of
sonicBoom()
sonicBoom(
body,target):void
Defined in: testWorld.ts:533
Records a sonic boom for tests; the data-driven runtime applies its real damage.
Parameters
body
target
Returns
void
Implementation of
spawn()
spawn(
type,position,options?):TestMob
Defined in: testWorld.ts:313
Places a mob and registers it as an entity.
Parameters
type
string
position
options?
TestEntityOptions = {}
Returns
villagerCanBreed()
villagerCanBreed(
_body,_partner):boolean
Defined in: testWorld.ts:586
Returns TestWorld.canBreed.
Parameters
_body
_partner
Returns
boolean
Implementation of
villagerRaidEffect()
villagerRaidEffect(
body,effect):void
Defined in: testWorld.ts:543
Records a world-owned effect requested by a villager brain.
Parameters
body
effect
Returns
void
Implementation of
villagerRaidState()
villagerRaidState(
_body):VillagerRaidState|undefined
Defined in: testWorld.ts:538
Returns the raid state supplied to this test world.
Parameters
_body
Returns
VillagerRaidState | undefined
Implementation of
villagerRestock()
villagerRestock(
body):void
Defined in: testWorld.ts:548
Records the villagers that were asked to restock their trades.
Parameters
body
Returns
void
Implementation of
villagerShowTrade()
villagerShowTrade(
_body,shown):void
Defined in: testWorld.ts:576
Records the change.
Parameters
_body
shown
boolean
Returns
void
Implementation of
villagerTask()
villagerTask(
body,task,target?):boolean
Defined in: testWorld.ts:567
Records the task.
Parameters
body
task
target?
Returns
boolean
Implementation of
villagerWorkSpot()
villagerWorkSpot(
_body,_task):BlockPos|undefined
Defined in: testWorld.ts:562
Returns TestWorld.farmSpot.
Parameters
_body
_task
"harvest_farmland" | "use_bonemeal"
Returns
BlockPos | undefined