mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-30 11:19:17 +02:00
Add methods for Creaking (#12094)
This commit is contained in:
parent
9b9f046f41
commit
fc56c728c0
2 changed files with 66 additions and 1 deletions
paper-api/src/main/java/org/bukkit/entity
paper-server/src/main/java/org/bukkit/craftbukkit/entity
|
@ -1,8 +1,43 @@
|
|||
package org.bukkit.entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Creaking.
|
||||
*/
|
||||
@NullMarked
|
||||
public interface Creaking extends Monster {
|
||||
|
||||
/**
|
||||
* Gets the home location for this creaking (where its {@link org.bukkit.block.CreakingHeart} could be found).
|
||||
*
|
||||
* @return the location of the home if available, null otherwise
|
||||
*/
|
||||
@Nullable
|
||||
Location getHome();
|
||||
|
||||
/**
|
||||
* Activates this creaking to target and follow a player.
|
||||
*
|
||||
* @param player the target
|
||||
*/
|
||||
void activate(final Player player);
|
||||
|
||||
/**
|
||||
* Deactivates the creaking, clearing its current attack target and
|
||||
* marking it as inactive.
|
||||
*/
|
||||
void deactivate();
|
||||
|
||||
/**
|
||||
* Returns if this creaking is currently active and hunting.
|
||||
*
|
||||
* @see #activate(Player)
|
||||
*
|
||||
* @return true if active
|
||||
*/
|
||||
boolean isActive();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.Optionull;
|
||||
import net.minecraft.world.entity.monster.creaking.Creaking;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Creaking {
|
||||
|
||||
public CraftCreaking(CraftServer server, Creaking entity) {
|
||||
public CraftCreaking(final CraftServer server, final Creaking entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
|
@ -14,6 +22,28 @@ public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Cre
|
|||
return (Creaking) this.entity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Location getHome() {
|
||||
return Optionull.map(this.getHandle().getHomePos(), pos -> CraftLocation.toBukkit(pos, this.getHandle().level()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(final Player player) {
|
||||
Preconditions.checkArgument(player != null, "player cannot be null");
|
||||
this.getHandle().activate(((CraftPlayer) player).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
this.getHandle().deactivate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return this.getHandle().isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftCreaking";
|
||||
|
|
Loading…
Add table
Reference in a new issue