KubeJS (Old)

KubeJS (Old)

3M Downloads

Allow loading custom assets (blockstates, patchouli_books, models, lang, etc)

artemisSystem opened this issue ยท 1 comments

commented

Describe the feature

Not sure if this is possible already, but i don't see anything about it in the wiki.

Would be really cool if it was possible to script the loading of resources like blockstates, models and lang. For me it would be sufficient with just basic support (and it might be a lot of work to add custom templates and functions for different types of models), something along the lines of:

onEvent("resources", event => {
  // This is a vanilla model, just for example's sake
  event.custom("models", "minecraft:block/black_carpet", {
    parent: "minecraft:block/carpet",
    textures: {
      wool: "minecraft:block/black_wool"
    }
  });
  
  event.custom("lang", "some_namespace:en_us", { "some.lang.string": "Some Lang String" });

  // Would be especially nice if it supported custom resource areas:
  event.custom("patchouli_books", "botania:lexicon/en_us/entries/basics/apothecary", {});
});

As mentioned in the last comment in the code, it would be really nice if there was no filtering/checks for whether you're writing to one of lang, blockstates, models, etc, so you could write JSONs to things like patchouli_books automatically as well.

Additional info

An example of how I think it could work:

An invocation like this:

onEvent("resources", event => {
  event.custom("my_asset_type", "my_namespace:some/asset", { some: "example", json: "data" });
});

...would generate this file:

<wherever kubejs puts its resources>/assets/my_namespace/my_asset_type/some/asset.json

...with the contents:

{
  "some": "example",
  "json": "data"
}
commented

You can already use KubeJS to generate arbitrary jsons, but I agree that a resource pack equivilant to server.datapack.high_priority and server.datapack.low_priority would be good.

//writing jsons
let data = {foo: 12, bar: false}
JsonIO.write('kubejs/assets/my_random_folder', data)