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
FieldsModifier and TypeFieldDescriptionprivate @Nullable Optional
<net.minecraft.world.entity.player.Player> private final double
private final net.minecraft.world.entity.ExperienceOrb
-
Constructor Summary
ConstructorsConstructorDescriptionXpOrbTargetingEvent
(net.minecraft.world.entity.ExperienceOrb xpOrb, double scanDistance) -
Method Summary
Modifier and TypeMethodDescription@Nullable net.minecraft.world.entity.player.Player
The result of the event.double
The maximum distance to scan for players.net.minecraft.world.entity.ExperienceOrb
getXpOrb()
TheExperienceOrb
that's looking for a player to follow.void
setFollowingPlayer
(@Nullable net.minecraft.world.entity.player.Player newFollowingPlayer) Sets a new result.
-
Field Details
-
xpOrb
private final net.minecraft.world.entity.ExperienceOrb xpOrb -
scanDistance
private final double scanDistance -
followingPlayer
-
-
Constructor Details
-
XpOrbTargetingEvent
public XpOrbTargetingEvent(net.minecraft.world.entity.ExperienceOrb xpOrb, double scanDistance)
-
-
Method Details
-
getFollowingPlayer
@Nullable public @Nullable net.minecraft.world.entity.player.Player getFollowingPlayer()The result of the event. -
setFollowingPlayer
public void setFollowingPlayer(@Nullable @Nullable net.minecraft.world.entity.player.Player newFollowingPlayer) Sets a new result. Can be null to cancel the default search. -
getXpOrb
public net.minecraft.world.entity.ExperienceOrb 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.
-