API reference / @jsprismarine/prismarine / PortalContact
Class: PortalContact
Defined in: prismarine/src/entity/PortalContact.ts:48
One entity's running contact with a portal, as Java's PortalProcessor keeps it.
The world calls PortalContact.touch on every tick the entity's box overlaps a portal block, and the entity calls PortalContact.tick once per tick from its own update. The time inside climbs by one per touched tick and drops by four per tick outside, so a player who steps out and back in does not start over, and the entity drops the contact once PortalContact.hasExpired says the time has run back down to zero.
Constructors
Constructor
new PortalContact(
entryPosition):PortalContact
Defined in: prismarine/src/entity/PortalContact.ts:57
Parameters
entryPosition
Where the entity stood when it first touched the portal.
Returns
PortalContact
Methods
getEntryPosition()
getEntryPosition():
Vector3
Defined in: prismarine/src/entity/PortalContact.ts:107
Where the entity most recently stood in the portal.
Returns
getPortal()
getPortal():
PortalBlockRef|undefined
Defined in: prismarine/src/entity/PortalContact.ts:112
The portal block the entity most recently overlapped, or undefined when no touch named one.
Returns
PortalBlockRef | undefined
getPortalTime()
getPortalTime():
number
Defined in: prismarine/src/entity/PortalContact.ts:102
Ticks accumulated inside the portal, after decay.
Returns
number
hasExpired()
hasExpired():
boolean
Defined in: prismarine/src/entity/PortalContact.ts:97
Whether the time inside has run back down to zero, so the contact can be dropped.
Returns
boolean
tick()
tick(
delayTicks):boolean
Defined in: prismarine/src/entity/PortalContact.ts:83
Advances the contact by one tick.
Parameters
delayTicks
number
Ticks inside the portal before the trip starts, from PORTAL_TRANSITION_TICKS. Zero fires on the first tick.
Returns
boolean
true when the time inside has reached delayTicks this tick.
touch()
touch(
entryPosition,portal?):void
Defined in: prismarine/src/entity/PortalContact.ts:70
Records that the entity overlaps a portal block on the current tick.
Several touches in one tick count once. The position is kept so the trip can be resolved from where the entity stood, not from where it was when the contact began.
Parameters
entryPosition
portal?
PortalBlockRef
The portal block the entity overlaps, which the trip is resolved from once the timer runs out. A touch without one leaves the last known block in place.
Returns
void