RangedEntity API

Allows you to determine if an entity is capable of ranged attacks,
and to perform an attack.
This commit is contained in:
Aikar 2018-06-26 21:34:40 -04:00
parent 77334adf24
commit c8a0abe8fd
10 changed files with 58 additions and 9 deletions

View file

@ -0,0 +1,36 @@
package com.destroystokyo.paper.entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.jspecify.annotations.NullMarked;
@NullMarked
public interface RangedEntity extends Mob {
/**
* Attack the specified entity using a ranged attack.
*
* @param target the entity to target
* @param charge How "charged" the attack is (how far back the bow was pulled for Bow attacks).
* This should be a value between 0 and 1, represented as targetDistance/maxDistance.
*/
void rangedAttack(LivingEntity target, float charge);
/**
* Sets that the Entity is "charging" up an attack, by raising its hands
*
* @param raiseHands Whether the entities hands are raised to charge attack
* @deprecated use {@link #setAggressive(boolean)}
*/
@Deprecated(since = "1.19.2")
void setChargingAttack(boolean raiseHands);
/**
* Alias to {@link LivingEntity#isHandRaised()}, if the entity is charging an attack
* @return If entities hands are raised
* @deprecated use {@link #isHandRaised()}
*/
@Deprecated(since = "1.19.2")
default boolean isChargingAttack() {
return this.isHandRaised();
}
}

View file

@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
* of this type, instanceOf checks against the specific subtypes listed prior
* are recommended.
*/
public interface AbstractSkeleton extends Monster {
public interface AbstractSkeleton extends Monster, com.destroystokyo.paper.entity.RangedEntity { // Paper
/**
* Gets the current type of this skeleton.

View file

@ -1,6 +1,8 @@
package org.bukkit.entity;
import com.destroystokyo.paper.entity.RangedEntity;
/**
* Drowned zombie.
*/
public interface Drowned extends Zombie { }
public interface Drowned extends Zombie, RangedEntity { } // Paper

View file

@ -1,6 +1,10 @@
package org.bukkit.entity;
import com.destroystokyo.paper.entity.RangedEntity;
/**
* Represents an Illusioner "Illager".
*/
public interface Illusioner extends Spellcaster { }
public interface Illusioner extends Spellcaster, RangedEntity { // Paper
}

View file

@ -1,12 +1,13 @@
package org.bukkit.entity;
import com.destroystokyo.paper.entity.RangedEntity;
import org.bukkit.inventory.LlamaInventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a Llama.
*/
public interface Llama extends ChestedHorse {
public interface Llama extends ChestedHorse, RangedEntity { // Paper
/**
* Represents the base color that the llama has.

View file

@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a Piglin.
*/
public interface Piglin extends PiglinAbstract, InventoryHolder {
public interface Piglin extends PiglinAbstract, InventoryHolder, com.destroystokyo.paper.entity.RangedEntity { // Paper
/**
* Get whether the piglin is able to hunt hoglins.

View file

@ -1,8 +1,10 @@
package org.bukkit.entity;
import com.destroystokyo.paper.entity.RangedEntity; // Paper
import org.bukkit.inventory.InventoryHolder;
/**
* Illager entity.
*/
public interface Pillager extends Illager, InventoryHolder { }
public interface Pillager extends Illager, InventoryHolder, RangedEntity { } // Paper

View file

@ -1,9 +1,11 @@
package org.bukkit.entity;
import com.destroystokyo.paper.entity.RangedEntity;
/**
* Represents a snowman entity
*/
public interface Snowman extends Golem {
public interface Snowman extends Golem, RangedEntity { // Paper
/**
* Gets whether this snowman is in "derp mode", meaning it is not wearing a

View file

@ -1,9 +1,11 @@
package org.bukkit.entity;
import com.destroystokyo.paper.entity.RangedEntity;
/**
* Represents a Witch
*/
public interface Witch extends Raider {
public interface Witch extends Raider, RangedEntity { // Paper
/**
* Gets whether the witch is drinking a potion

View file

@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a Wither boss
*/
public interface Wither extends Monster, Boss {
public interface Wither extends Monster, Boss, com.destroystokyo.paper.entity.RangedEntity { // Paper
/**
* {@inheritDoc}