Package dev.polv.taleapi.event.entity
Interface EntityMoveCallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Called when an entity moves from one location to another.
This event fires for ALL entities, including players. To check if the
moving entity is a player, use entity instanceof TalePlayer.
This event is cancellable. If cancelled, the entity's movement will be reverted to the original location.
Example Usage
// Log all entity movements
EntityMoveCallback.EVENT.register((entity, from, to) -> {
System.out.println(entity.getUniqueId() + " moved from " + from + " to " + to);
return EventResult.PASS;
});
// Prevent entities from entering a restricted area
EntityMoveCallback.EVENT.register(EventPriority.HIGH, (entity, from, to) -> {
if (isRestrictedArea(to)) {
return EventResult.CANCEL; // Block the movement
}
return EventResult.PASS;
});
// Player-specific movement handling
EntityMoveCallback.EVENT.register((entity, from, to) -> {
if (entity instanceof TalePlayer player) {
// Handle player-specific movement logic
updatePlayerChunks(player, from, to);
}
return EventResult.PASS;
});
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiononEntityMove(TaleEntity entity, Location from, Location to) Called when an entity moves from one location to another.
-
Field Details
-
EVENT
The event instance. Use this to register listeners and fire the event.
-
-
Method Details
-
onEntityMove
Called when an entity moves from one location to another.- Parameters:
entity- the entity that is movingfrom- the location the entity is moving fromto- the location the entity is moving to- Returns:
- the event result -
EventResult.CANCELto prevent the movement
-