Package com.minecolonies.api.util
Class EntityUtils
java.lang.Object
com.minecolonies.api.util.EntityUtils
Entity related utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckForFreeSpace(@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.EntitygetPlayerByUUID(@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.PlayergetPlayerOfFakePlayer(@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.BlockPosgetSpawnPoint(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos nearPoint) Get a safe spawnpoint near a location.static booleanisFlying(net.minecraft.world.entity.LivingEntity target) Checks if the target is flyingstatic booleanisLivingAtSite(@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 booleanisLivingAtSiteWithMove(@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 booleansolidOrLiquid(@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 booleantryMoveLivingToXYZ(@NotNull net.minecraft.world.entity.Mob living, int x, int y, int z) Sets the movement of the entity to specific point.static booleantryMoveLivingToXYZ(@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 doubleupdateRotation(double currentRotation, double intendedRotation, double maxIncrement) Returns the new rotation degree calculated from the current and intended rotation up to a max.
-
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 inid- 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 ingroundPosition- 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 inblockPos- 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 movex- x-coordinatey- y-coordinatez- 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 movex- x-coordinatey- y-coordinatez- z-coordinatespeedFactor- 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 checkx- X-coordinatey- Y-coordinatez- Z-coordinaterange- 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 checkx- X-coordinatey- Y-coordinatez- Z-coordinaterange- 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
Entity pushable by predicate. Cheaper version compared to mojank.- Returns:
- The predicate.
-