Class EntityUtils
java.lang.Object
org.skriptlang.skript.bukkit.entity.EntityUtils
Utility class for quick
Entity methods-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetAge(org.bukkit.entity.Entity entity) Gets the age of anEntitythat extendsAgeable.static booleanisAdult(org.bukkit.entity.Entity entity) Quick method to check if entity is an adult.static booleanisAgeable(org.bukkit.entity.Entity entity) Deprecated, for removal: This API element is subject to removal in a future version.static voidsetAdult(org.bukkit.entity.Entity entity) Quick method for making an entity an adult.static voidsetAge(org.bukkit.entity.Entity entity, int age) Sets the age of anEntitythat extendsAgeable.static voidsetBaby(org.bukkit.entity.Entity entity) Quick method for making an entity a baby.static org.bukkit.entity.EntityTypetoBukkitEntityType(Class<? extends org.bukkit.entity.Entity> entityClass) static org.bukkit.entity.EntityTypetoBukkitEntityType(EntityData<?> data) Get theEntityTypethatdatacorrelates to.static EntityData<?> toSkriptEntityData(org.bukkit.entity.EntityType entityType) Gets aEntityDatafrom the providedentityType.
-
Constructor Details
-
EntityUtils
public EntityUtils()
-
-
Method Details
-
isAgeable
@Deprecated(since="2.17", forRemoval=true) public static boolean isAgeable(org.bukkit.entity.Entity entity) Deprecated, for removal: This API element is subject to removal in a future version.The minimum supported version of MC 1.21.4, all entities covered in this method now extendAgeable. -
getAge
public static int getAge(org.bukkit.entity.Entity entity) Gets the age of anEntitythat extendsAgeable.- Parameters:
entity- TheEntityto grab the age from.- Returns:
- The age of the
EntityifAgeable, otherwise0.
-
setAge
public static void setAge(org.bukkit.entity.Entity entity, int age) Sets the age of anEntitythat extendsAgeable. Setting below 0 will make them a baby otherwise adult.- Parameters:
entity- TheEntityto set the age for.age- The age to set to.
-
setBaby
public static void setBaby(org.bukkit.entity.Entity entity) Quick method for making an entity a baby. Ageable entities (such as sheep or pigs) will set their default baby age to -24000.- Parameters:
entity- Entity to make baby
-
setAdult
public static void setAdult(org.bukkit.entity.Entity entity) Quick method for making an entity an adult.- Parameters:
entity- Entity to make adult
-
isAdult
public static boolean isAdult(org.bukkit.entity.Entity entity) Quick method to check if entity is an adult.- Parameters:
entity- Entity to check- Returns:
- True if entity is an adult
-
toBukkitEntityType
Get theEntityTypethatdatacorrelates to.- Parameters:
data- TheEntityDatato get theEntityTypefrom.- Returns:
- The correlating
EntityType.
-
toBukkitEntityType
@Nullable public static org.bukkit.entity.EntityType toBukkitEntityType(Class<? extends org.bukkit.entity.Entity> entityClass) Attempts to get anEntityTypefrom aClassextendingEntity. Ensures at least oneEntityTypecan represent an entity class throughClass.isAssignableFrom(Class).- Parameters:
entityClass- TheClassextendingEntity- Returns:
- The exact or assignable
EntityTypeornull
-
toSkriptEntityData
Gets aEntityDatafrom the providedentityType.- Parameters:
entityType- TheEntityTypeto get theEntityData.- Returns:
- The
EntityData.
-
Ageable.