https://github.com/frederoxdev/regolith-generators
https://github.com/frederoxdev/regolith-generators
regolith-filter
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/frederoxdev/regolith-generators
- Owner: FrederoxDev
- Created: 2024-12-15T17:55:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-04T09:00:07.000Z (about 1 year ago)
- Last Synced: 2025-04-04T09:34:25.890Z (about 1 year ago)
- Topics: regolith-filter
- Language: TypeScript
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Regolith Generators
Intended to be the regolith alternative to the [bridge. generator scripts](https://bridge-core.app/guide/advanced/generator-scripts/index.html)
### Install Filter
```
regolith install regolith_generators
```
## Use-cases
Place `.ts` files directly into your BP/RP and this filter will run each one with Deno. More convenient than making filters for one off scripts.
### Bulk file generation
```ts
// BP/blocks/ExampleBlockGenerator.ts
import { createFile } from "jsr:@frederoxdev/regolith-generators"
const blockNames = ["foo", "bar"];
blockNames.forEach(id => {
createFile({
"format_version": "1.21.70",
"minecraft:block": {
"description": {
"identifier": `studio_name:${id}`,
},
"components": {
// do whatever ...
}
}
}, `BP/blocks/${id}.json`)
// ^ Must pass in a file name here since generating multiple
});
```
### One off file generation
```ts
// RP/textures/item_texture.ts
import { createFile } from "jsr:@frederoxdev/regolith-generators"
import { join, extname, basename } from "jsr:@std/path";
import { walkSync } from "jsr:@std/fs";
const projectNamespace = "foo";
const studioBase = `bar/baz`;
const texturesFolder = join(Deno.cwd(), "RP", "textures", studioBase, "items");
const textureData: Record = {};
for (const entry of walkSync(texturesFolder, { exts: [".png"], includeFiles: true })) {
const textureName = basename(entry.path, extname(entry.path));
const relativePath = entry.path.replaceAll("\\", "/").split("/RP/")[1];
const noExtensionPath = relativePath.replace(extname(relativePath), "");
textureData[`${projectNamespace}:${textureName}`] = {
"textures": noExtensionPath
}
}
createFile({
resource_pack_name: "pack.name",
texture_name: 'atlas.items',
texture_data: textureData,
});
// ^ No file path has to be provided for one off files
```