Package net.neoforged.neoforge.entity
Class 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
.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@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.
-
Field Details
-
xpOrb
-
scanDistance
private final double scanDistance -
followingPlayer
-
-
Constructor Details
-
XpOrbTargetingEvent
-
-
Method Details
-
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.
-