diff --git a/README.md b/README.md index 3b2c1c3..3c6d901 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Basin A high performance Minecraft server implementation written in C. +## Discord Server + +Join the Discord server [here](https://discord.gg/3uW2QQV). + # Goals * Pure performance: minimum resource usage for a full Minecraft server implementation * Drop-in replacement: compatible with Spigot API plugins via JNI, standard Minecraft world format (Anvil) diff --git a/src/entity.c b/src/entity.c index aef124c..16380b6 100644 --- a/src/entity.c +++ b/src/entity.c @@ -1033,7 +1033,8 @@ void tick_entity(struct world* world, struct entity* entity) { damageEntity(entity, 1., 0); } if (ei != NULL && ei->onTick != NULL) { - if ((*ei->onTick)(world, entity)) { + (*ei->onTick)(world, entity); + if (entity->despawn) { return; } } diff --git a/src/entity_impl.c b/src/entity_impl.c index 8cf6038..0fda1e2 100644 --- a/src/entity_impl.c +++ b/src/entity_impl.c @@ -188,14 +188,11 @@ void tick_arrow(struct world* world, struct entity* entity) { return 1; } } -//printf("hf2c = %f, %f, %f\n", entity->x, entity->y, entity->z); if (entity->data.arrow.ticksInGround == 0) { float dhz = sqrtf(entity->motX * entity->motX + entity->motZ * entity->motZ); entity->yaw = atan2f(entity->motX, entity->motZ) * 180. / M_PI; entity->pitch = atan2f(entity->motY, dhz) * 180. / M_PI; - //printf("desired %f, %f, %f\n", entity->pitch, entity->motY, dhz); - //printf("yaw = %f, last_yaw = %f\npitch = %f, last_pitch = %f\n", entity->yaw, entity->last_yaw, entity->pitch, entity->last_pitch); if ((entity->last_yaw == 0. && entity->last_pitch == 0.)) { entity->last_yaw = entity->yaw; entity->last_pitch = entity->pitch; @@ -215,7 +212,7 @@ void tick_arrow(struct world* world, struct entity* entity) { return 0; } -int tick_itemstack(struct world* world, struct entity* entity) { +void tick_itemstack(struct world* world, struct entity* entity) { if (entity->data.itemstack.delayBeforeCanPickup > 0) { entity->data.itemstack.delayBeforeCanPickup--; return 0; diff --git a/src/world.c b/src/world.c index f3e6796..ed05753 100644 --- a/src/world.c +++ b/src/world.c @@ -888,7 +888,7 @@ void world_tick(struct world* world) { pthread_rwlock_rdlock(&world->players->rwlock); ITER_MAP(world->players) { struct player* player = (struct player*) value; - player_tick(world, player); + player_tick(player); tick_entity(world, player->entity); // might need to be moved into separate loop later ITER_MAP_END(); } @@ -899,6 +899,9 @@ void world_tick(struct world* world) { ITER_MAP(world->entities) { struct entity* entity = (struct entity*) value; if (entity->type != ENT_PLAYER) tick_entity(world, entity); + if (entity->despawn) { + pfree(entity->pool); + } ITER_MAP_END(); } pthread_rwlock_unlock(&world->entities->rwlock);