-
Notifications
You must be signed in to change notification settings - Fork 0
Entity
EntityUtil is a utility class for interacting with entities, attributes, and other common tasks in Minecraft plugin development.
Gets the bow from which the arrow was shot.
Returns: The ItemStack representing the bow, or null if unavailable.
Gets the current value of an attribute for a given entity.
Returns: The value of the attribute, or 0.0 if the attribute is not present.
Gets the base value of an attribute for a given entity.
Returns: The base value of the attribute, or 0.0 if the attribute is not present.
Checks if the entity is underwater.
Returns: true if the entity is underwater, otherwise false.
Checks if the ItemDisplay has its transform set to FIXED.
Returns: true if the transform is FIXED, otherwise false.
Checks if the ItemDisplay has its transform set to NONE.
Returns: true if the transform is NONE, otherwise false.
Teleports an entity to a specified location with a given cause.
Teleports an entity to a specified location using PLUGIN as the teleportation cause.
- Methods like
isUnderWaterandteleportadapt to server types and versions (e.g., Paper, Folia). - Version-specific logic ensures compatibility with Minecraft 1.19+.
- The utility class focuses on simplifying repetitive tasks.
// Example: Retrieve the bow used to shoot an arrow
Arrow arrow = ...; // An arrow instance
ItemStack bow = EntityUtil.getBowFromArrow(arrow);
if (bow != null) {
System.out.println("Bow retrieved: " + bow);
}
// Example: Teleport an entity to a new location
Location destination = new Location(world, 100, 65, 200);
EntityUtil.teleport(destination, entity);