| #ifndef _MCIPM_PACKET_H |
| #define _MCIPM_PACKET_H |
| |
| #include <sys/types.h> |
| #include <stdint.h> |
| |
| #define MCIPM_GET_VERSION 1 |
| #define MCIPM_GET_ENTITIES 2 |
| #define MCIPM_REPLY_ERROR 128 |
| #define MCIPM_REPLY_VERSION 129 |
| #define MCIPM_REPLY_ENTITIES 130 |
| |
| #define MCIPM_GET_ENTITIES_SELECTOR_ALL 0 |
| #define MCIPM_GET_ENTITIES_SELECTOR_WORLD 1 |
| #define MCIPM_GET_ENTITIES_SELECTOR_ENTITY_ID 2 |
| #define MCIPM_GET_ENTITIES_SELECTOR_ENTITY_TYPE 3 |
| |
| #define MCIPM_PACKET_MAX_LENGTH (16 * 1024 * 1024) |
| |
| #define GET_PACKET_EOF -1 |
| #define GET_PACKET_ERROR -2 |
| #define GET_PACKET_SHORT_READ -3 |
| #define GET_PACKET_TOO_SMALL -4 |
| #define GET_PACKET_TOO_LARGE -5 |
| #define GET_PACKET_OUT_OF_MEMORY -6 |
| #define GET_PACKET_INCOMPLETE -7 |
| |
| struct mcipm_packet { |
| uint32_t length; |
| uint8_t type; |
| uint8_t data[0]; |
| }; |
| |
| struct entity { |
| uint16_t entry_length; // Including this variable |
| uint16_t world_name_offset; |
| uint16_t entity_type_name_offset; |
| uint16_t display_name_offset; |
| uint32_t entity_id; |
| double location_x; |
| double location_y; |
| double location_z; |
| float rotation_yaw; |
| float rotation_pitch; |
| uint8_t is_living_entity; |
| uint8_t is_on_ground; |
| uint8_t is_dead; |
| float width; |
| float height; |
| int32_t chunk_x; |
| int32_t chunk_y; |
| int32_t chunk_z; |
| uint64_t uuid_most_sig; |
| uint64_t uuid_least_sig; |
| // Living entity properties |
| float max_health; |
| float health; |
| uint32_t idle_time; |
| uint32_t attack_target_id; |
| // Variably-length data |
| uint8_t data[0]; |
| } __attribute__((__packed__)); |
| |
| int send_packet_get_version(int); |
| int send_packet_get_entities(int, const void *, size_t, unsigned int); |
| int receive_packet(int, struct mcipm_packet **, int); |
| |
| #endif |