1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-01 23:25:09 +02:00

implement mob combat

This commit is contained in:
p2r3
2025-08-22 17:41:29 +03:00
parent ed6ad6de6d
commit e311b0cbe4
6 changed files with 138 additions and 19 deletions

View File

@@ -93,6 +93,9 @@ typedef struct {
short x;
uint8_t y;
short z;
// Lower 5 bits: health
// Upper 3 bits: reserved (?)
uint8_t data;
} MobData;
#pragma pack(pop)

View File

@@ -1,6 +1,7 @@
#ifndef H_PACKETS
#define H_PACKETS
// Serverbound packets
int cs_handshake (int client_fd);
int cs_loginStart (int client_fd, uint8_t *uuid, char *name);
int cs_clientInformation (int client_fd);
@@ -17,6 +18,7 @@ int cs_closeContainer (int client_fd);
int cs_clientStatus (int client_fd);
int cs_chat(int client_fd);
// Clientbound packets
int sc_loginSuccess (int client_fd, uint8_t *uuid, char *name);
int sc_knownPacks (int client_fd);
int sc_finishConfiguration (int client_fd);
@@ -44,6 +46,9 @@ int sc_damageEvent (int client_fd, int id, int type);
int sc_setHealth (int client_fd, uint8_t health, uint8_t food);
int sc_respawn (int client_fd);
int sc_systemChat (int client_fd, char* message, uint16_t len);
int cs_interact (int client_fd);
int sc_entityEvent (int client_fd, int entity_id, uint8_t status);
int sc_removeEntity (int client_fd, int entity_id);
int sc_registries (int client_fd);
#endif

View File

@@ -31,7 +31,8 @@ uint16_t getMiningResult (uint16_t held_item, uint8_t block);
void bumpToolDurability (PlayerData *player);
void handlePlayerAction (PlayerData *player, int action, short x, short y, short z);
void spawnMob (uint8_t type, short x, uint8_t y, short z);
void spawnMob (uint8_t type, short x, uint8_t y, short z, uint8_t health);
void hurtEntity (int entity_id, int attacker_id, uint8_t damage_type, uint8_t damage);
void handleServerTick (int64_t time_since_last_tick);
#endif