implement sheep shearing

* Added shearing sheeps

* Added empty line

* Changed comment in MobData to say what the middle 1 bit is used for

* Replaced if statements with a switch statement and early returns

* Send mob metadata to players that join

* Fixed mob metadata getting freed when exiting the switch statement

* remove currently unnecessary check

* use bitwise and in place of modulo

* style nitpicks

---------

Co-authored-by: p2r3 <p2r3@p2r3.com>
This commit is contained in:
SDFTDusername
2025-09-16 12:36:42 +02:00
committed by GitHub
parent 244c98552f
commit ba86dfd927
5 changed files with 102 additions and 7 deletions

View File

@@ -241,7 +241,7 @@ typedef struct {
uint8_t y;
short z;
// Lower 5 bits: health
// Middle 1 bit: reserved for future use
// Middle 1 bit: sheep sheared, unused for other mobs
// Upper 2 bits: panic timer
uint8_t data;
} MobData;

View File

@@ -21,6 +21,7 @@ int givePlayerItem (PlayerData *player, uint16_t item, uint8_t count);
void spawnPlayer (PlayerData *player);
void broadcastPlayerMetadata (PlayerData *player);
void broadcastMobMetadata (int client_fd, int entity_id);
uint8_t serverSlotToClientSlot (int window_id, uint8_t slot);
uint8_t clientSlotToServerSlot (int window_id, uint8_t slot);
@@ -44,6 +45,7 @@ void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t
void checkFluidUpdate (short x, uint8_t y, short z, uint8_t block);
void spawnMob (uint8_t type, short x, uint8_t y, short z, uint8_t health);
void interactEntity (int entity_id, int interactor_id);
void hurtEntity (int entity_id, int attacker_id, uint8_t damage_type, uint8_t damage);
void handleServerTick (int64_t time_since_last_tick);