Cancellable
EntityTargetLivingEntityEvent
public class EntityTargetEvent extends EntityEvent implements Cancellable
Modifier and Type | Class | Description |
---|---|---|
static class |
EntityTargetEvent.TargetReason |
An enum to specify the reason for the targeting
|
Event.Result
entity
Constructor | Description |
---|---|
EntityTargetEvent(@NotNull Entity entity,
@Nullable Entity target,
@NotNull EntityTargetEvent.TargetReason reason) |
Modifier and Type | Method | Description |
---|---|---|
static @NotNull HandlerList |
getHandlerList() |
|
@NotNull HandlerList |
getHandlers() |
|
@NotNull EntityTargetEvent.TargetReason |
getReason() |
Returns the reason for the targeting
|
@Nullable Entity |
getTarget() |
Get the entity that this is targeting.
|
boolean |
isCancelled() |
Gets the cancellation state of this event.
|
void |
setCancelled(boolean cancel) |
Sets the cancellation state of this event.
|
void |
setTarget(@Nullable Entity target) |
Set the entity that you want the mob to target instead.
|
getEntity, getEntityType
callEvent, getEventName, isAsynchronous
public EntityTargetEvent(@NotNull @NotNull Entity entity, @Nullable @Nullable Entity target, @NotNull @NotNull EntityTargetEvent.TargetReason reason)
public boolean isCancelled()
Cancellable
isCancelled
in interface Cancellable
public void setCancelled(boolean cancel)
Cancellable
setCancelled
in interface Cancellable
cancel
- true if you wish to cancel this event@NotNull public @NotNull EntityTargetEvent.TargetReason getReason()
@Nullable public @Nullable Entity getTarget()
This will be null in the case that the event is called when the mob forgets its target.
public void setTarget(@Nullable @Nullable Entity target)
It is possible to be null, null will cause the entity to be target-less.
This is different from cancelling the event. Cancelling the event will cause the entity to keep an original target, while setting to be null will cause the entity to be reset.
target
- The entity to target@NotNull public @NotNull HandlerList getHandlers()
getHandlers
in class Event
@NotNull public static @NotNull HandlerList getHandlerList()
Copyright © 2020. All rights reserved.