Undergarden mod !

This commit is contained in:
2026-09-30 17:30:14 -03:00
parent cbc9edfd60
commit 0052faa24d
21 changed files with 545 additions and 46 deletions
+9 -6
View File
@@ -96,15 +96,18 @@ export interface EntityJson {
// an entity model, see EntityModelJson
model?: string;
texture: string;
// "animal" (the default) wanders around, panics when hurt and looks at players. "scripted" stays where scripts put
// it: no gravity, ai or health, and it isn't saved with the world, like the fishing hook
behavior?: "animal" | "scripted";
// "animal" (the default) wanders around, panics when hurt and looks at players. "monster" goes after players it
// sees and whoever hurts it, and despawns far from players, like minecraft's zombies. "scripted" stays where
// scripts put it: no gravity, ai or health, and it isn't saved with the world, like the fishing hook
behavior?: "animal" | "monster" | "scripted";
// its collision box in blocks, width is for both x and z
width: number;
height: number;
max_health?: number;
// minecraft's per tick speed, 0.25 for most animals
movement_speed?: number;
// what its hits do, for monsters. 2 when not set, like minecraft's
attack_damage?: number;
// protection from physical and from arcane damage, not used yet
physical_shielding?: number;
arcane_shielding?: number;
@@ -705,15 +708,15 @@ export function validate_entity(json: unknown): Problems {
...(json.model === undefined ? [] : validate_id(json.model, "model")),
...validate_id(json.texture, "texture"),
];
if (json.behavior !== undefined && json.behavior !== "animal" && json.behavior !== "scripted") {
problems.push('behavior must be "animal" or "scripted"');
if (json.behavior !== undefined && !["animal", "monster", "scripted"].includes(json.behavior as string)) {
problems.push('behavior must be "animal", "monster" or "scripted"');
}
for (const key of ["width", "height"]) {
if (typeof json[key] !== "number" || json[key] <= 0 || json[key] > 16) {
problems.push(`${key} must be a number of blocks above 0, at most 16`);
}
}
for (const key of ["max_health", "movement_speed", "physical_shielding", "arcane_shielding"]) {
for (const key of ["max_health", "movement_speed", "attack_damage", "physical_shielding", "arcane_shielding"]) {
if (json[key] !== undefined && (typeof json[key] !== "number" || json[key] < 0)) {
problems.push(`${key} must be a number, 0 or more`);
}
+6 -3
View File
@@ -7,7 +7,7 @@ export const AIR_ID = "bworld:air";
// bump when a client and server of different versions can't play together.
// the server rejects a different version before the client downloads anything
export const PROTOCOL_VERSION = 12;
export const PROTOCOL_VERSION = 13;
export interface PlayerInfo {
id: string;
@@ -46,6 +46,9 @@ export type EntityInfo =
// glowing, on_fire, silent, left_handed, equipment (slot to item). only what's set is there
export type EntityData = Record<string, unknown>;
// what happens to an entity that clients show, see entity_event
export type EntityEvent = "hurt" | "death" | "swing";
// x, y, z, block id, and its state bits when they aren't 0
export type BlockChange = [number, number, number, string, number?];
@@ -162,8 +165,8 @@ export type ServerMessage =
}
// all of an entity's synced data, when any of it changed
| { type: "entity_data"; id: string; data: EntityData }
// hurt flashes it red, death starts it falling over (it's removed a second later)
| { type: "entity_event"; id: string; event: "hurt" | "death" }
// hurt flashes it red, death starts it falling over (it's removed a second later), swing is it attacking
| { type: "entity_event"; id: string; event: EntityEvent }
// what's riding it now, by id
| { type: "set_passengers"; id: string; passengers: string[] }
// a dropped item's stack changed, like when two stacks merge