Start working on entities

This commit is contained in:
2026-11-21 10:53:33 -03:00
parent 65865033c1
commit 60a7cae86e
7 changed files with 150 additions and 11 deletions
+5 -4
View File
@@ -4,7 +4,7 @@
// the kinds of entity mods define in entities/<name>.json (see EntityJson): animals that wander around, panic when hurt
// and look at players now and then, like minecraft's simpler animals, monsters that go after players, and scripted
// ones that stay where scripts put them
import type { EntityJson } from "@/common/mod_data.ts";
import { entity_category, type EntityJson } from "@/common/mod_data.ts";
import { ATTRIBUTES, type AttributeType } from "./attributes.ts";
import { Entity } from "./entity.ts";
import type { EntityFactory } from "./entity_types.ts";
@@ -28,6 +28,7 @@ export function mod_entity_factory(json: EntityJson): EntityFactory {
}
const monster = json.behavior === "monster";
const category = entity_category(json);
class ModEntity extends Mob {
readonly type = json.id;
@@ -36,7 +37,7 @@ export function mod_entity_factory(json: EntityJson): EntityFactory {
override eye_height = json.height * 0.85;
override get category(): MobCategory {
return monster ? "monster" : "creature";
return category;
}
override default_attributes(): [AttributeType, number?][] {
@@ -68,9 +69,9 @@ export function mod_entity_factory(json: EntityJson): EntityFactory {
this.goals.add_goal(7, new RandomLookAroundGoal(this));
}
// animals stay, like minecraft's farm animals. monsters go away when no player is near
// creatures stay, like minecraft's farm animals. monsters go away when no player is near
override remove_when_far_away() {
return monster;
return category === "monster";
}
}
return (level) => new ModEntity(level);