Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TypeRegistry #23

Closed
rvandoosselaer opened this issue Mar 5, 2020 · 1 comment
Closed

Update TypeRegistry #23

rvandoosselaer opened this issue Mar 5, 2020 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@rvandoosselaer
Copy link
Owner

rvandoosselaer commented Mar 5, 2020

The TypeRegistry will be adapted to make it more easy to use custom created materials. It will however still be simple to change or update a texture of a block.

The current solution always uses the same material (Blocks/Materials/default-block.j3m) based on the Lighting.j3md material definition. Textures are loaded from the theme folder and set on the material. This way it's easy to change textures, but it's not possible to use other materials that are not based on the Lighting.j3md material definition. This way PBR is not supported for example.

When a material file is found in the theme's folder, it should be used for that type. When there is no material file found, the old behavior should remain. In this case, the default material (Blocks/Materials/default-block.j3m) will be used and the textures in the theme's folder will be loaded.

Another 'quality of life' update is to let the TypeRegistry automatically pack textures together. Now you still need to use an image editor to combine the top, side and bottom textures into one texture. When you supply the 3 textures (top, side, bottom) in the theme's folder instead of the already combined one, the TypeRegistry will combine them and set them on the default material.

@rvandoosselaer rvandoosselaer added this to the v1.4.0 milestone Mar 5, 2020
@rvandoosselaer rvandoosselaer added the enhancement New feature or request label Mar 5, 2020
rvandoosselaer added a commit that referenced this issue Mar 6, 2020
…ry as is. A type can also be loaded by supplying just the name. Based on the name of the type, a material is loaded from the theme's folder. When no material could be found, the default block material is used. #23
rvandoosselaer added a commit that referenced this issue Mar 6, 2020
…that can be combined. When the three type textures are found (top, side, bottom) they are combined in a single texture. #23
@rvandoosselaer
Copy link
Owner Author

rvandoosselaer commented Mar 6, 2020

With the recent changes to the TypeRegistry, there are now 3 possible ways to register a type to the TypeRegistry.

Using a material

You can directly set a material for a specific type:

Material customGrassMaterial = assetManager.loadMaterial("/path/to/my/material/myGrass.j3m");

TypeRegistry typeRegistry = BlocksConfig.getInstance().getTypeRegistry();
typeRegistry.register(TypeIds.GRASS, customGrassMaterial);

Using a material in the theme folder

You can place a material file in the theme folder. The TypeRegistry will locate the material file associated with the type and register it. When the type of the block is grass, the file grass.j3m will be loaded in the theme folder. Type names can be found in the TypeIds interface.

Using textures in the theme folder

When a material file couldn't be found for the type, the TypeRegistry will look for textures associated with the type and register them using the default block material. When the type of the block is grass, the textures grass.png, grass-normal.png and grass-parallax.png will be used in the material. The normal and parallax textures are optional.

If the block should use different images in the texture, the images should be combined in the same texture file using an image editor. See the wiki page about theming for more information.

Using multiple textures in the theme folder

A 'quality of life' update is made so you don't need to use an image editor to combine the top image, side image and bottom image into one texture.
You can place the 3 image files in the theme folder and the TypeRegistry will load and combine the 3 images into 1. The images should have exactly the same size and colorspace or the merging will fail.

Make sure to name the images correct, otherwise they will not be found by the TypeRegistry.
If you want to combine the top, side and bottom images for the grass type block, the image names should be: grass_top.png, grass_side.png and grass_bottom.png.
This will also work for the optional normal and parallax textures. Those filenames should be: grass_top-normal.png, grass_side-normal.png, grass_bottom-normal.png, grass_top-parallax.png, grass_side-parallax.png and grass_bottom-parallax.png.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant