mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Slime Pathfinder Events
This commit is contained in:
parent
8170ae9d64
commit
b589db2d90
6 changed files with 186 additions and 0 deletions
|
@ -0,0 +1,41 @@
|
|||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to change its facing direction.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to change direction.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeChangeDirectionEvent extends SlimePathfindEvent {
|
||||
|
||||
private float yaw;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeChangeDirectionEvent(final Slime slime, final float yaw) {
|
||||
super(slime);
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the new chosen yaw
|
||||
*
|
||||
* @return Chosen yaw
|
||||
*/
|
||||
public float getNewYaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the new chosen yaw
|
||||
*
|
||||
* @param yaw Chosen yaw
|
||||
*/
|
||||
public void setNewYaw(final float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to start pathfinding.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start moving.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimePathfindEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimePathfindEvent(final Slime slime) {
|
||||
super(slime);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Slime that is pathfinding.
|
||||
*
|
||||
* @return The Slime that is pathfinding.
|
||||
*/
|
||||
@Override
|
||||
public Slime getEntity() {
|
||||
return (Slime) super.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to start jumping while swimming in water/lava.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start jumping.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeSwimEvent extends SlimeWanderEvent {
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeSwimEvent(final Slime slime) {
|
||||
super(slime);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to change direction to target a LivingEntity.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start moving.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent {
|
||||
|
||||
private final LivingEntity target;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeTargetLivingEntityEvent(final Slime slime, final LivingEntity target) {
|
||||
super(slime);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the targeted entity
|
||||
*
|
||||
* @return Targeted entity
|
||||
*/
|
||||
public LivingEntity getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to start wandering.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start moving.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeWanderEvent extends SlimePathfindEvent {
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeWanderEvent(final Slime slime) {
|
||||
super(slime);
|
||||
}
|
||||
}
|
|
@ -24,4 +24,20 @@ public interface Slime extends Mob, Enemy {
|
|||
* @param sz The new size of the slime.
|
||||
*/
|
||||
public void setSize(int sz);
|
||||
|
||||
// Paper start
|
||||
/**
|
||||
* Get whether this slime can randomly wander/jump around on its own
|
||||
*
|
||||
* @return true if can wander
|
||||
*/
|
||||
public boolean canWander();
|
||||
|
||||
/**
|
||||
* Set whether this slime can randomly wander/jump around on its own
|
||||
*
|
||||
* @param canWander true if can wander
|
||||
*/
|
||||
public void setWander(boolean canWander);
|
||||
// Paper end
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue