This commit is contained in:
2026-11-16 23:49:42 -03:00
parent 94b0e3789c
commit eedaa955f6
13 changed files with 148 additions and 2 deletions
+9
View File
@@ -104,6 +104,8 @@ export interface EntityLevel {
entity_loot(entity: Entity, source: DamageSource): ItemStack[];
// it's standing on the block at x y z after moving, for the block's components, see on_entity_stand
stands_on(entity: Entity, x: number, y: number, z: number): void;
// it moved, for the components of the blocks its box is in, see on_entity_inside
inside_blocks(entity: Entity): void;
}
// an entity as level.json keeps it, see Entity.save. each kind adds its own fields
@@ -308,6 +310,7 @@ export abstract class Entity {
if (this.on_ground) {
this.level.stands_on(this, Math.floor(this.x), Math.floor(this.y - STANDING_DEPTH), Math.floor(this.z));
}
this.level.inside_blocks(this);
this.update_fall_distance(this.y - from_y);
return collisions;
}
@@ -362,6 +365,12 @@ export abstract class Entity {
this.fire = 0;
}
// like minecraft's Entity.kill: ones that can die do, even when invulnerable, the rest go away. cause is for events
// and the death message
kill(_cause: string) {
this.remove();
}
// takes it out of the world. the entity manager tells clients and forgets it
remove() {
if (this.removed) return;