Class EntityHelper

java.lang.Object
net.darkhax.bookshelf.api.util.EntityHelper

public final class EntityHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areEntitiesCloseEnough(net.minecraft.world.entity.Entity firstEntity, net.minecraft.world.entity.Entity secondEntity, double maxDistance)
    Checks if two entities are close enough together.
    static void
    clearEffects(net.minecraft.world.entity.LivingEntity entity, boolean removePositive, boolean removeNegative)
    Clears potion effect from an entity based on whether or not the effects are positive or negative.
    static double
    getDistaceFromPos(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos)
    Calculates the distance between an entity and a BlockPos.
    static double
    getDistanceFromEntity(net.minecraft.world.entity.Entity firstEntity, net.minecraft.world.entity.Entity secondEntity)
    Calculates the distance between two entities.
    static net.minecraft.util.Tuple<Integer,Integer>
    getEggColors(net.minecraft.world.entity.EntityType<?> type)
    Get the egg color associated with an entity type.
    static <T extends net.minecraft.world.entity.Entity>
    List<T>
    getEntitiesInArea(Class<T> entityClass, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, int range)
    Gets a List of entities that are within the provided area.
    static boolean
    isAffectedByFire(net.minecraft.world.entity.LivingEntity toCheck)
    Checks if an entity can be affected by fire.
    static boolean
    isWearingFullSet(net.minecraft.world.entity.Mob living, Class<net.minecraft.world.item.Item> armorClass)
    A check to see if an entity is wearing a full suit of the armor.
    static void
    pushTowards(net.minecraft.world.entity.Entity entityToMove, net.minecraft.core.BlockPos pos, double force)
    Pushes an Entity towards a BlockPos.
    static void
    pushTowards(net.minecraft.world.entity.Entity entityToMove, net.minecraft.core.Direction direction, double force)
    Pushes an entity towards a specific direction.
    static void
    pushTowards(net.minecraft.world.entity.Entity entityToMove, net.minecraft.world.entity.Entity destination, double force)
    Pushes an entity towards another one.
    static void
    pushTowardsDirection(net.minecraft.world.entity.Entity entityToMove, net.minecraft.core.Direction direction, double force)
    Creates a Vector3d that represents the additional motion that would be needed to push an entity towards a destination.
    static net.minecraft.world.phys.HitResult
    rayTrace(net.minecraft.world.entity.LivingEntity entity, double length, net.minecraft.world.level.ClipContext.Block blockMode, net.minecraft.world.level.ClipContext.Fluid fluidMode)
    Performs a ray trace for the look vector of an entity.

    Methods inherited from class java.lang.Object

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

    • EntityHelper

      public EntityHelper()
  • Method Details

    • getDistanceFromEntity

      public static double getDistanceFromEntity(net.minecraft.world.entity.Entity firstEntity, net.minecraft.world.entity.Entity secondEntity)
      Calculates the distance between two entities.
      Parameters:
      firstEntity - The first entity to use.
      secondEntity - The second entity to use.
      Returns:
      double The distance between the two entities passed.
    • getDistaceFromPos

      public static double getDistaceFromPos(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos)
      Calculates the distance between an entity and a BlockPos.
      Parameters:
      entity - The Entity to use for the first position.
      pos - The BlockPos to use for the second position.
      Returns:
      double The distance between the Entity and the BlockPos.
    • pushTowards

      public static void pushTowards(net.minecraft.world.entity.Entity entityToMove, net.minecraft.core.Direction direction, double force)
      Pushes an entity towards a specific direction.
      Parameters:
      entityToMove - The entity that you want to push.
      direction - The direction to push the entity.
      force - The amount of force to push the entity with.
    • pushTowards

      public static void pushTowards(net.minecraft.world.entity.Entity entityToMove, net.minecraft.core.BlockPos pos, double force)
      Pushes an Entity towards a BlockPos.
      Parameters:
      entityToMove - The entity that you want to push.
      pos - The BlockPos to push the entity towards.
      force - The amount of force to push the entity with.
    • pushTowards

      public static void pushTowards(net.minecraft.world.entity.Entity entityToMove, net.minecraft.world.entity.Entity destination, double force)
      Pushes an entity towards another one.
      Parameters:
      entityToMove - The entity that should be pushed towards the other entity.
      destination - The destination entity, that the entity to move should be pushed towards.
      force - The amount of force to push the entityToMove with.
    • pushTowardsDirection

      public static void pushTowardsDirection(net.minecraft.world.entity.Entity entityToMove, net.minecraft.core.Direction direction, double force)
      Creates a Vector3d that represents the additional motion that would be needed to push an entity towards a destination.
      Parameters:
      entityToMove - The entity to push.
      direction - The direction to push the entity.
      force - The amount of force to use.
    • areEntitiesCloseEnough

      public static boolean areEntitiesCloseEnough(net.minecraft.world.entity.Entity firstEntity, net.minecraft.world.entity.Entity secondEntity, double maxDistance)
      Checks if two entities are close enough together.
      Parameters:
      firstEntity - The first entity to check.
      secondEntity - The second entity to check.
      maxDistance - The maximum distance that the entities can be apart.
      Returns:
      boolean True if the distance between the entities are within range of the maxDistance.
    • getEntitiesInArea

      public static <T extends net.minecraft.world.entity.Entity> List<T> getEntitiesInArea(Class<T> entityClass, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, int range)
      Gets a List of entities that are within the provided area.
      Type Parameters:
      T - The type of entities to look for.
      Parameters:
      entityClass - The type of entity you are looking for.
      world - The world to search in.
      pos - The position to start the search around.
      range - The range of the search.
      Returns:
      A List containing all entities of the specified type that are within the range.
    • isWearingFullSet

      public static boolean isWearingFullSet(net.minecraft.world.entity.Mob living, Class<net.minecraft.world.item.Item> armorClass)
      A check to see if an entity is wearing a full suit of the armor. This check is based on the class names of armor.
      Parameters:
      living - : The living entity to check the armor of.
      armorClass - : The class of the armor to check against.
      Returns:
      boolean: True if every piece of armor the entity is wearing are the same class as the provied armor class.
    • rayTrace

      public static net.minecraft.world.phys.HitResult rayTrace(net.minecraft.world.entity.LivingEntity entity, double length, net.minecraft.world.level.ClipContext.Block blockMode, net.minecraft.world.level.ClipContext.Fluid fluidMode)
      Performs a ray trace for the look vector of an entity.
      Parameters:
      entity - The entity to perform a ray trace on.
      length - The distance to cast the rays.
      blockMode - The mode used when detecting blocks.
      fluidMode - The mode used when detecting fluids.
      Returns:
      An object containing the results of the ray trace.
    • isAffectedByFire

      public static boolean isAffectedByFire(net.minecraft.world.entity.LivingEntity toCheck)
      Checks if an entity can be affected by fire. While fire immune entities can already negate the effects of fire doing prechecks using this method can be used to avoid rendering flickers or filter out these types of entities.
      Parameters:
      toCheck - The entity to check.
      Returns:
      Whether or not this entity can be affected by fire.
    • clearEffects

      public static void clearEffects(net.minecraft.world.entity.LivingEntity entity, boolean removePositive, boolean removeNegative)
      Clears potion effect from an entity based on whether or not the effects are positive or negative.
      Parameters:
      entity - The entity to remove effects from.
      removePositive - Should positive effects be cleared?
      removeNegative - Should negative effects be cleared?
    • getEggColors

      public static net.minecraft.util.Tuple<Integer,Integer> getEggColors(net.minecraft.world.entity.EntityType<?> type)
      Get the egg color associated with an entity type. If the entity does not have an egg type this will be 0 for both values.
      Parameters:
      type - The entity type to get a color for.
      Returns:
      A Tuple containing the primary and secondary egg colors.