类 XpOrbTargetingEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.entity.XpOrbTargetingEvent
public class XpOrbTargetingEvent
extends net.neoforged.bus.api.Event
Event to determine which player an XP Orb should follow.
This is fired once a second when an XP Orbit find itself without a player to move toward.
The default (nearest player within getScanDistance()
) can be overridden with
either a new (Fake)Player or null to cancel the attraction.
Note that providing a player that is more than 8 blocks away does work, but it will cause this event to be fired again after 20 ticks.
See also: PlayerXpEvent.PickupXp
for cancelling the pickup.
This event is fired on both server and client on the NeoForge.EVENT_BUS
.
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明@Nullable Player
The result of the event.double
The maximum distance to scan for players.getXpOrb()
TheExperienceOrb
that's looking for a player to follow.void
setFollowingPlayer
(@Nullable Player newFollowingPlayer) Sets a new result.
-
字段详细资料
-
xpOrb
-
scanDistance
private final double scanDistance -
followingPlayer
-
-
构造器详细资料
-
XpOrbTargetingEvent
-
-
方法详细资料
-
getFollowingPlayer
The result of the event. -
setFollowingPlayer
Sets a new result. Can be null to cancel the default search. -
getXpOrb
TheExperienceOrb
that's looking for a player to follow.You can get the
Level
from this. -
getScanDistance
public double getScanDistance()The maximum distance to scan for players. This is 8 for vanilla orbs.
-