Class EntityUtils

java.lang.Object
com.minecolonies.api.util.EntityUtils

public final class EntityUtils extends Object
Entity related utilities.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    checkForFreeSpace(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos groundPosition)
    Check for free space AIR_SPACE_ABOVE_TO_CHECK blocks high.
    static List<net.minecraft.world.entity.Entity>
    getEntitiesFromID(@NotNull net.minecraft.world.level.Level world, @NotNull List<Integer> ids)
    Returns a list of loaded entities whose id's match the ones provided.
    static net.minecraft.world.entity.Entity
    getPlayerByUUID(@NotNull net.minecraft.world.level.Level world, @NotNull UUID id)
    Returns the loaded Entity with the given UUID.
    static @NotNull net.minecraft.world.entity.player.Player
    getPlayerOfFakePlayer(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.world.level.Level world)
    Checks if a player is a fakePlayer and tries to get the owning player if possible.
    static @Nullable net.minecraft.core.BlockPos
    getSpawnPoint(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos nearPoint)
    Get a safe spawnpoint near a location.
    static boolean
    isFlying(net.minecraft.world.entity.LivingEntity target)
    Checks if the target is flying
    static boolean
    isLivingAtSite(@NotNull net.minecraft.world.entity.LivingEntity entityLiving, int x, int y, int z, int range)
    Returns whether or not the entity is within a specific range of his working site.
    static boolean
    isLivingAtSiteWithMove(@NotNull net.minecraft.world.entity.LivingEntity entity, int x, int y, int z, int range)
    Checks if a entity is at his working site.
    static Predicate<net.minecraft.world.entity.Entity>
    Entity pushable by predicate.
    static boolean
    solidOrLiquid(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos blockPos)
    Checks if a blockPos in a world is solid or liquid.
    static boolean
    tryMoveLivingToXYZ(@NotNull net.minecraft.world.entity.Mob living, int x, int y, int z)
    Sets the movement of the entity to specific point.
    static boolean
    tryMoveLivingToXYZ(@NotNull net.minecraft.world.entity.Mob living, int x, int y, int z, double speedFactor)
    Sets the movement of the entity to specific point.
    static double
    updateRotation(double currentRotation, double intendedRotation, double maxIncrement)
    Returns the new rotation degree calculated from the current and intended rotation up to a max.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPlayerOfFakePlayer

      @NotNull public static @NotNull net.minecraft.world.entity.player.Player getPlayerOfFakePlayer(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.world.level.Level world)
      Checks if a player is a fakePlayer and tries to get the owning player if possible.
      Parameters:
      player - the incoming player.
      world - the world.
      Returns:
      the PlayerEntity owner in the best case.
    • getPlayerByUUID

      public static net.minecraft.world.entity.Entity getPlayerByUUID(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull UUID id)
      Returns the loaded Entity with the given UUID.
      Parameters:
      world - world the entity is in
      id - the entity's UUID
      Returns:
      the Entity
    • getEntitiesFromID

      public static List<net.minecraft.world.entity.Entity> getEntitiesFromID(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull List<Integer> ids)
      Returns a list of loaded entities whose id's match the ones provided.
      Parameters:
      world - the world the entities are in.
      ids - List of Entity id's
      Returns:
      list of Entity's
    • updateRotation

      public static double updateRotation(double currentRotation, double intendedRotation, double maxIncrement)
      Returns the new rotation degree calculated from the current and intended rotation up to a max.
      Parameters:
      currentRotation - the current rotation the citizen has.
      intendedRotation - the wanted rotation he should have after applying this.
      maxIncrement - the 'movement speed.
      Returns:
      a rotation value he should move.
    • checkForFreeSpace

      public static boolean checkForFreeSpace(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos groundPosition)
      Check for free space AIR_SPACE_ABOVE_TO_CHECK blocks high.

      And ensure a solid ground

      Parameters:
      world - the world to look in
      groundPosition - the position to maybe stand on
      Returns:
      true if a suitable Place to walk to
    • solidOrLiquid

      public static boolean solidOrLiquid(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos blockPos)
      Checks if a blockPos in a world is solid or liquid.

      Useful to find a suitable Place to stand. (avoid these blocks to find one)

      Parameters:
      world - the world to look in
      blockPos - the blocks position
      Returns:
      true if solid or liquid
    • getSpawnPoint

      @Nullable public static @Nullable net.minecraft.core.BlockPos getSpawnPoint(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos nearPoint)
      Get a safe spawnpoint near a location.
      Parameters:
      world - the world he should spawn in.
      nearPoint - the point to search near.
      Returns:
      The spawn position.
    • tryMoveLivingToXYZ

      public static boolean tryMoveLivingToXYZ(@NotNull @NotNull net.minecraft.world.entity.Mob living, int x, int y, int z)
      Sets the movement of the entity to specific point. Returns true if direction is set, otherwise false.
      Parameters:
      living - Entity to move
      x - x-coordinate
      y - y-coordinate
      z - z-coordinate
      Returns:
      True if the path is set to destination, otherwise false
    • tryMoveLivingToXYZ

      public static boolean tryMoveLivingToXYZ(@NotNull @NotNull net.minecraft.world.entity.Mob living, int x, int y, int z, double speedFactor)
      Sets the movement of the entity to specific point. Returns true if direction is set, otherwise false.
      Parameters:
      living - Entity to move
      x - x-coordinate
      y - y-coordinate
      z - z-coordinate
      speedFactor - Speedfactor to modify base speed with
      Returns:
      true if arrived
    • isLivingAtSiteWithMove

      public static boolean isLivingAtSiteWithMove(@NotNull @NotNull net.minecraft.world.entity.LivingEntity entity, int x, int y, int z, int range)
      Checks if a entity is at his working site. If he isn't, sets it's path to the location.
      Parameters:
      entity - entity to check
      x - X-coordinate
      y - Y-coordinate
      z - Z-coordinate
      range - Range to check in
      Returns:
      True if entity is at site, otherwise false.
    • isLivingAtSite

      public static boolean isLivingAtSite(@NotNull @NotNull net.minecraft.world.entity.LivingEntity entityLiving, int x, int y, int z, int range)
      Returns whether or not the entity is within a specific range of his working site.
      Parameters:
      entityLiving - entity to check
      x - X-coordinate
      y - Y-coordinate
      z - Z-coordinate
      range - Range to check in
      Returns:
      True if entity is at site, otherwise false
    • isFlying

      public static boolean isFlying(net.minecraft.world.entity.LivingEntity target)
      Checks if the target is flying
      Parameters:
      target - entity to check
      Returns:
      true if flying or falling deeper
    • pushableBy

      public static Predicate<net.minecraft.world.entity.Entity> pushableBy()
      Entity pushable by predicate. Cheaper version compared to mojank.
      Returns:
      The predicate.