Package wbs.utils.util.entities
Class WbsEntityUtil
java.lang.Object
wbs.utils.util.entities.WbsEntityUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanblink(org.bukkit.entity.Entity entity, double distance) Teleports the entity a given distance in the direction they're looking, ensuring a safe landing (cannot land in non-solid blocks)static booleancanSeeSky(org.bukkit.entity.Entity entity) static voiddamage(org.bukkit.entity.Damageable target, double damage, org.bukkit.entity.LivingEntity attacker) Make the specified player deal damage to a living entity.static @NotNull org.bukkit.util.VectorgetFacingVector(org.bukkit.entity.Entity entity) Gets a unit vector in the direction the entity is facingstatic @NotNull org.bukkit.util.VectorgetFacingVector(org.bukkit.entity.Entity entity, double magnitude) Gets a vector in the direction the entity is facing scaled to the given magnitudestatic @Nullable org.bukkit.inventory.ItemStackgetItemInSlot(org.bukkit.entity.LivingEntity entity, org.bukkit.inventory.EquipmentSlot slot) static @NotNull org.bukkit.util.VectorgetLocalUp(org.bukkit.entity.Entity entity) static @NotNull org.bukkit.LocationgetMiddleLocation(org.bukkit.entity.Entity target) Get the location half way up a mobstatic @Nullable org.bukkit.LocationgetTargetPos(org.bukkit.entity.LivingEntity entity, double range) Gets the location at the block the entity is looking at.static booleanheal(org.bukkit.entity.LivingEntity entity, double toHeal) Heal the target LivingEntity safely, taking into account max healthstatic booleanisInMaterial(org.bukkit.entity.Entity entity, org.bukkit.Material type) static booleanisInWater(org.bukkit.entity.Entity entity) static voidpush(org.bukkit.entity.Entity entity, double speed) Pushes the entity in the direction they're facing at a given speed
-
Method Details
-
canSeeSky
public static boolean canSeeSky(org.bukkit.entity.Entity entity) -
isInMaterial
public static boolean isInMaterial(org.bukkit.entity.Entity entity, org.bukkit.Material type) -
isInWater
public static boolean isInWater(org.bukkit.entity.Entity entity) -
getTargetPos
@Nullable public static @Nullable org.bukkit.Location getTargetPos(org.bukkit.entity.LivingEntity entity, double range) Gets the location at the block the entity is looking at.- Parameters:
range- The maximum distance away from the entity the block may be- Returns:
- The target location. null if there was no block in range
-
getFacingVector
@NotNull public static @NotNull org.bukkit.util.Vector getFacingVector(org.bukkit.entity.Entity entity) Gets a unit vector in the direction the entity is facing- Returns:
- The facing vector
-
getFacingVector
@NotNull public static @NotNull org.bukkit.util.Vector getFacingVector(org.bukkit.entity.Entity entity, double magnitude) Gets a vector in the direction the entity is facing scaled to the given magnitude- Parameters:
magnitude- The scale of the resulting vector- Returns:
- The facing vector
-
getLocalUp
@NotNull public static @NotNull org.bukkit.util.Vector getLocalUp(org.bukkit.entity.Entity entity) -
push
public static void push(org.bukkit.entity.Entity entity, double speed) Pushes the entity in the direction they're facing at a given speed- Parameters:
speed- The new speedentity- The entity to push
-
blink
public static boolean blink(org.bukkit.entity.Entity entity, double distance) Teleports the entity a given distance in the direction they're looking, ensuring a safe landing (cannot land in non-solid blocks)- Parameters:
distance- The distance to teleport- Returns:
- true if the blink was successful, false if there was no safe landing spot found
-
damage
public static void damage(org.bukkit.entity.Damageable target, double damage, org.bukkit.entity.LivingEntity attacker) Make the specified player deal damage to a living entity.This method uses
Damageable.damage(double, Entity), except it works on Ender Dragons because they're awful to work with.- Parameters:
target- The entity to damagedamage- The amount of damage to dealattacker- The attacking entity to deal the damage. Nullable.
-
heal
public static boolean heal(org.bukkit.entity.LivingEntity entity, double toHeal) Heal the target LivingEntity safely, taking into account max health- Parameters:
entity- The entity to healtoHeal- The amount to heal- Returns:
- True if the entity was healed, false if already at max health
-
getMiddleLocation
@NotNull public static @NotNull org.bukkit.Location getMiddleLocation(org.bukkit.entity.Entity target) Get the location half way up a mob- Parameters:
target- The target mob- Returns:
- The location half way up the given mob.
-
getItemInSlot
@Nullable public static @Nullable org.bukkit.inventory.ItemStack getItemInSlot(org.bukkit.entity.LivingEntity entity, org.bukkit.inventory.EquipmentSlot slot)
-