PetMotion

public final class PetMotion

Movement maths shared by the pet behaviors: hover, standing and swimming spots, the ground under a point, and one tick of steering. A floating body steers by velocity, since a flying mob's navigation crawls; a walking or swimming body paths there natively. Speeds are blocks per tick.

Functions

Link copied to clipboard
public static boolean floatsOnLiquid(PetControl control)
Whether the species hovers over liquid surfaces: everything that does not swim.
Link copied to clipboard
public static double groundBelow(Location point, int depth, boolean liquidIsGround)
The top of the highest solid block under the point, searched a bounded number of blocks down.
Link copied to clipboard
public static Location groundPoint(Location center, double radius)
A spot to stand on within radius of center: the floor of a random column nearest center's height.
Link copied to clipboard
public static Location hoverPoint(PetControl control, Location center, double radius)
A point near center, inside the species' hover band above the ground under it.
Link copied to clipboard
public static boolean loaded(Location location)
Link copied to clipboard
public static Location restPoint(PetControl control, Location center, double radius)
A spot to rest within radius of center in the body's own medium: in its hover band when it flies, on standing ground when it walks or cannot move, in water when it swims, and on ground or else in water when it is amphibious.
Link copied to clipboard
public static boolean settled(PetControl control, LivingEntity body)
Free to wander: not told to stay, and wild or within the follow distance of its owner.
Link copied to clipboard
public static boolean steerFlight(MindContext context, Location target, double cruise)
One tick of flight toward target: accelerate to the cruise speed, ease off over the last few blocks, and hold still on arrival.
Link copied to clipboard
public static boolean teleportNearOwner(PetControl control, LivingEntity body, double radius)
Puts the body beside its owner: in its hover band when floating, on standing ground when walking, in water when swimming, and on ground or else in water when amphibious, so it keeps up with an owner who swims or sails.
Link copied to clipboard
public static Location trailPoint(PetControl control, Player owner, double back, double height)
Behind the owner: back blocks behind where they face, height above their feet when floating, at them otherwise.
Link copied to clipboard
public static Location waterPoint(Location center, double radius, double minDepth, double maxDepth)
A spot in water within radius of center, between minDepth and maxDepth below the topmost water the column's scan finds.