location – Locations¶
The location module contains objects for tracking and analyzing locations.
- class bravo.location.Location¶
The position and orientation of an entity.
- classmethod at_block(x, y, z)¶
Pinpoint a location at a certain block.
This constructor is intended to aid in pinpointing locations at a specific block rather than forcing users to do the pixel<->block maths themselves. Admittedly, the maths in question aren’t hard, but there’s no reason to avoid this encapsulation.
Force this location to be sane.
Forces the position and orientation to be sane, then fixes up location-specific things, like stance.
Returns: bool indicating whether this location had to be altered
Return the distance between this location and another location.
Return a Location a certain number of blocks in front of this position.
The orientation of the returned location is identical to this position’s orientation.
Parameters: distance (int) – the number of blocks by which to offset this position
Returns a position/look/grounded packet.
- class bravo.location.Orientation¶
The angles corresponding to the heading of an entity.
Theta and phi are very much like the theta and phi of spherical coordinates, except that phi’s zero is perpendicular to the XZ-plane rather than pointing straight up or straight down.
Orientation is stored in floating-point radians, for simplicity of computation. Unfortunately, no wire protocol speaks radians, so several conversion methods are provided for sanity and convenience.
The from_degs() and to_degs() methods provide integer degrees. This form is called “yaw and pitch” by protocol documentation.
- classmethod from_degs(yaw, pitch)¶
Create an Orientation from integer degrees.
Return this orientation as integer degrees.
Return this orientation as fractions of a byte.
- class bravo.location.Position¶
The coordinates pointing to an entity.
Positions are always stored as integer absolute pixel coordinates.
Return the distance between this position and another, in absolute pixels.
- classmethod from_player(x, y, z)¶
Create a Position from floating-point block coordinates.
Return the heading from this position to another, in radians.
This is a wrapper for the common atan2() expression found in games, meant to help encapsulate semantics and keep copy-paste errors from happening.
Return this position as block coordinates.
Return this position as floating-point block coordinates.