Skip to content

Styles, resources and static elements.

Marc Hermans edited this page Sep 9, 2018 · 3 revisions

BlockOut requires, just as any GUI library, as well as Minecraft itself, resources that it renders on screen. These resources are managed by BlockOuts styles.

Styles. The what and the who now?

Well styles are a collection of resource types and their instances. When a BlockOut element requires a Resource like a texture it will request that resource from the StyleManager using its style id and the id of the resource it is looking for.

Enough talk about styles. How do i make them?

Well first of all you will need a styles.json file under: assets/modid/styles. This file will hold a list of all your styles in a json array, like so:

[
  "<modid>:<path_to_your_style.json>",
  "<modid>:<path_to_another_style.json>"
]

Now you know how to register styles, lets talk about adding one ourselfs. As stated a style needs an id and a list of resource types. BlockOut does not care were either of them are located as long as it is listed in the styles.json list of atleast one mod. If it finds the same style (so two styles with the same id) it will try to merge them together, were the second one overrides the information from the first style if a collision occurs. So lets create a style.

Style creation, resources and resource types.

By default blockout provides several different resource types, including, but not limited to: Images, Template and ItemStacks. In a later tutorial I will teach you how to add your own static resource types. Now on to making a style. For this tutorial i will be making a test style with a single image. My style will be located under: /assets/modid/styles/test/ under this directory we will now first create our style json. This file can be named what ever you want so i will choose: test.json:

{
  "id": "modid:test",
  "types": [
    "modid:styles/test/image/images.json",
  ]
}

Now when ever a control has the style: "modid:test" the StyleManager will try to lookup resources in this style first, before falling back to other styles. As you can see this style only contains one resource type. The loader will given resource type file and try to load all resources specified in said style.

Resource types, their data and defining them.