Create a models holder
Models holder is an Enum of individual models bounded with their textures.
-
Create
ModModels.javaenum class and add your modelDirectorylibs/
- …
Directorysrc/main/
Directoryjava/your/namespace/your_mod_id/
- …
Directoryclient/
Directoryloader/
- ModModels.java
- ExampleMod.java
Directoryresources/assets/your_mod_id/
Directorytextures/
Directorytesr/
- …
Directorymodels/
Directorytesr/
- …
- …
- …
This is an example of models holder class structure:
ModModels.java // ... other importsimport dev.tauri.jsg.core.client.IModelsHolder;import dev.tauri.jsg.core.client.LoadersHolder;import dev.tauri.jsg.core.common.entity.BiomeOverlayInstance;public enum ModModels implements IModelsHolder { // should implement IModelsHolder// MODEL ENTRY// 1st parameter is path to the model file - must end with .obj// 2nd parameter is BASE path to the texture - file end is added automatically by scanning if file exists when loading textures (.png, then .webp and then .jpg)// 3rd parameter is true/false - true if you want to use different textures for each biome overlayMY_AWESOME_MODEL_WITH_TEXTURE("awesome/model.obj", "awesome/textures", true);// holds path to the obj model filepublic final ResourceLocation model;// map of texture path for each biome overlay registered in the corepublic final Map<BiomeOverlayInstance, ResourceLocation> biomeTextureResourceMap = new HashMap<>();// holds all biome overlays that have not been found for this model texture to prevent spamming log with errorsprivate final List<BiomeOverlayInstance> nonExistingReported = new ArrayList<>();ModModels(String modelPath, String texturePath, boolean byOverlay) {this.model = ExampleMod.LOADERS_HOLDER.model().getModelResource(modelPath);loadEntry(texturePath, byOverlay);}@Overridepublic @NotNull LoadersHolder getLoadersHolder() {return ExampleMod.LOADERS_HOLDER;}@Overridepublic @NotNull ResourceLocation getModelLocation() {return model;}@Overridepublic @NotNull Map<BiomeOverlayInstance, ResourceLocation> getBiomeTextureResourceMap() {return biomeTextureResourceMap;}@Overridepublic @NotNull List<BiomeOverlayInstance> getNonExistingTexturesReported() {return nonExistingReported;}} -
Add model file and BASE texture
Directorylibs/
- …
Directorysrc/main/
Directoryjava/your/namespace/your_mod_id/
- …
Directoryclient/
Directoryloader/
- ModModels.java
- ExampleMod.java
Directoryresources/assets/your_mod_id/
Directorytextures/
Directorytesr/
Directoryawesome/
- texture.webp
Directorymodels/
Directorytesr/
Directoryawesome/
- model.obj
- …
- …
-
Now you have added your model!