Lazuli
What is Lazuli?
Lazuli is a deno library to help you generate Minecraft Bedrock addon files using TypeScript.
Status
EXPERIMENTAL
Iām still not sure how things are implemented and named, so a lot of stuff are likely to change.
How it works
Lazuli will automatically detect the project paths in your current working directory.
Itāll look for a config.json
file (see: project-config-standard) containing the paths to BP and RP folders. If it doesnāt find it, itāll look for any folders ending in BP
and RP
(case insensitive) instead. The 2 folders must have identical name aside from the BP
and RP
suffix.
This helps you write scripts that would work on most projects without having to worry about how the project is structured.
Usage
You can pass any class that derives from AddonFile
to the lazuli
function, and itāll write the file to their designated path.
import {
createEntityBehavior,
lazuli,
} from "https://deno.land/x/lazuli/mod.ts";
const myEntity = createEntityBehavior("my_entity", {
format_version: "1.19.50",
"minecraft:entity": {
description: {
identifier: "lazuli:my_entity",
is_spawnable: true,
is_summonable: true,
is_experimental: false,
},
components: {
"minecraft:health": {
value: 20,
max: 20,
},
},
},
});
lazuli([myEntity]);
You can also write into a subdirectory. This will write to BP/entities/custom/my_entity.json
.
const myEntity = createEntityBehavior("custom/my_entity", {
// ...
});
Thatās pretty much it. You can also use the createEntity
function to create an entity quickly with some default values.
import { createEntity, lazuli } from "https://deno.land/x/lazuli/mod.ts";
const myEntity = createEntity({
identifier: "lazuli:my_entity",
behavior(entity) {
const bp = entity["minecraft:entity"];
bp.components = {
"minecraft:health": {
value: 20,
max: 20,
},
};
bp.component_groups = {
despawn: {
"minecraft:instant_despawn": {},
},
};
bp.events = {
despawn: {
add: {
component_groups: ["despawn"],
},
},
};
return entity;
},
resource(entity) {
const rp = entity["minecraft:client_entity"].description;
rp.textures = {
default: "textures/blank",
};
rp.geometry = {
default: "geometry.blank",
};
return entity;
},
});
lazuli([myEntity]);
Usage In Regolith
Install the filter:
regolith install github.com/ink0rr/regolith-filters/lazuli
The filter will look for any .ts
files inside your data/lazuli/export/
folder and get the default export.
import { createEntityBehavior } from "https://deno.land/x/lazuli/mod.ts";
const myEntity = createEntityBehavior("my_entity", {
// ...
});
export default myEntity;
You can also default export an array.
import { createEntity, createBlock } from "https://deno.land/x/lazuli/mod.ts";
const myEntity = createEntity({
identifier: "lazuli:my_entity",
// ...
});
const myBlock = createBlock({
identifier: "lazuli:my_block",
// ...
});
export default [myEntity, myBlock];
If you default export anything else, itāll just be ignored.
Contributing
Contributions are welcome. There are probably a lot of questionable design decisions here, so please open an issue if you have any ideas to help improve this library.
Credits
- Blockception for bedrock json schemas.
License
MIT