From dd5361375844e85bf3e07df94ce299d5fc029084 Mon Sep 17 00:00:00 2001 From: Paula Date: Sat, 21 Nov 2026 13:16:12 -0300 Subject: [PATCH] Pathfinding data --- common/mod_data.ts | 5 +++++ docs/modding/entities/index.md | 2 ++ docs/modding/resources/tags.md | 8 ++++++++ mods/dangerous_business/entities/coilhead.json | 2 ++ .../tags/blocks/cubi/mobs_path_through.json | 8 ++++++++ tests/mod_entity_test.ts | 7 +++++++ 6 files changed, 32 insertions(+) create mode 100644 mods/dangerous_business/tags/blocks/cubi/mobs_path_through.json diff --git a/common/mod_data.ts b/common/mod_data.ts index 64215d4..edbdd4b 100644 --- a/common/mod_data.ts +++ b/common/mod_data.ts @@ -444,6 +444,11 @@ const entity_schema = z.object({ max_health: z.number().min(0).optional(), // minecraft's per tick speed, 0.25 for most animals movement_speed: z.number().min(0).optional(), + // whether it jumps, onto blocks in its way and up its path, true when not set. one that doesn't still steps up its + // step height, and swims up in water. see PATHFINDING.md + jumps: z.boolean().optional(), + // how many blocks it drops on its way, 3 when not set. 0 never walks off an edge, so it keeps out of pits + max_fall: z.number().int().min(0).optional(), // what its hits do, for monsters. 2 when not set, like minecraft's attack_damage: z.number().min(0).optional(), // protection from physical and from arcane damage, not used yet diff --git a/docs/modding/entities/index.md b/docs/modding/entities/index.md index f9c3c8c..823161b 100644 --- a/docs/modding/entities/index.md +++ b/docs/modding/entities/index.md @@ -32,6 +32,8 @@ and players. Mods define new kinds in their `entities/` folder, and draw them wi | `width`, `height` | required | Its collision box in blocks, up to 16. `width` is for both x and z. Its eyes are at 85% of the height. | | `max_health` | `10` | In half hearts. | | `movement_speed` | `0.25` | Minecraft's per tick speed, 0.25 for most animals. | +| `jumps` | `true` | Whether it jumps onto blocks in its way. Without, it still steps up 0.6 blocks and swims up in water. | +| `max_fall` | `3` | How many blocks it drops on its way. `0` never walks off an edge, to keep monsters out of pits. | | `attack_damage` | `2` | What a monster's hits do, in half hearts. | | `physical_shielding` | `0` | Protection from physical damage. Not used yet. | | `arcane_shielding` | `0` | Protection from arcane damage. Not used yet. | diff --git a/docs/modding/resources/tags.md b/docs/modding/resources/tags.md index 9e147bf..674a60e 100644 --- a/docs/modding/resources/tags.md +++ b/docs/modding/resources/tags.md @@ -78,6 +78,14 @@ back. Depend on the mod whose tag you change, so your file loads after its. chec | `#bworld:leaves` | blocks | Every kind of leaves. | | `#c:ingots` | items | `#c:ingots/copper`, `#c:ingots/tin`, `#c:ingots/iron`, `#c:ingots/gold`. | +## The Engine's Tags + +The engine reads these by name. No mod owns `cubi`, so adding to them needs no dependency. + +| Tag | Registry | What's in it | +| ------------------------- | -------- | ------------------------------------------------------------------------------------------------- | +| `#cubi:mobs_path_through` | blocks | Blocks mobs' paths go through, like doors: a mob runs into a closed one and waits for it to open. | + ## Using Tags in Data - **Recipes**: anywhere a recipe takes an item (shaped `key` values, smelting `input`, fuel `item`) it can take an item diff --git a/mods/dangerous_business/entities/coilhead.json b/mods/dangerous_business/entities/coilhead.json index 7704b8f..af9c204 100644 --- a/mods/dangerous_business/entities/coilhead.json +++ b/mods/dangerous_business/entities/coilhead.json @@ -9,6 +9,8 @@ "height": 1.9, "max_health": 40, "movement_speed": 0.23, + "jumps": false, + "max_fall": 0, "attack_damage": 5, "physical_shielding": 3 } diff --git a/mods/dangerous_business/tags/blocks/cubi/mobs_path_through.json b/mods/dangerous_business/tags/blocks/cubi/mobs_path_through.json new file mode 100644 index 0000000..09cb975 --- /dev/null +++ b/mods/dangerous_business/tags/blocks/cubi/mobs_path_through.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "tag": { + "values": [ + "dangerous_business:factory_door" + ] + } +} diff --git a/tests/mod_entity_test.ts b/tests/mod_entity_test.ts index f01e44f..79cee0a 100644 --- a/tests/mod_entity_test.ts +++ b/tests/mod_entity_test.ts @@ -87,6 +87,13 @@ Deno.test("an entity without a model is drawn as its texture, and a scripted one assertEquals(validate_entity({ id: "a:b", texture: "a:b", behavior: "a:flying", width: 0.25, height: 0.25 }), []); }); +Deno.test("an entity can say it doesn't jump and how far it drops, in whole blocks", () => { + const entity = { id: "a:b", texture: "a:b", width: 1, height: 1 }; + assertEquals(validate_entity({ ...entity, jumps: false, max_fall: 0 }), []); + assertEquals(validate_entity({ ...entity, max_fall: 1.5 }).length, 1); + assertEquals(validate_entity({ ...entity, max_fall: -1 }).length, 1); +}); + Deno.test("an entity's category is monster for monsters unless it says otherwise", () => { const entity = { id: "a:b", texture: "a:b", width: 1, height: 1 }; assertEquals(entity_category(entity), "creature");