Skip to content

Commit 71aa6a8

Browse files
committed
README.md: add manual model loading
1 parent 8fd70eb commit 71aa6a8

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Adding the API to your project
55

6-
```
6+
```groovy
77
repositories {
88
maven {
99
name = "OnyxStudios"
@@ -28,13 +28,13 @@ Firstly you have to register your MODID as an OBJ Model handler, so that FOML wi
2828

2929
### **Example:**
3030

31-
```
31+
```java
3232
OBJLoader.INSTANCE.registerDomain(MODID);
3333
```
3434

3535
After you register your domain, all you have to do is specify the OBJ model in the blockstate's file as such:
3636

37-
```
37+
```json
3838
{
3939
"variants": {
4040
"": { "model": "testmod:block/test_model.obj" }
@@ -68,7 +68,7 @@ And that's basically it, your block show now render your OBJ model! **(Note: It
6868

6969
JSON-formatted vanilla item models placed in the `models/item` folder can also specify your OBJ model as its "parent" model, similar to blockstates:
7070

71-
```
71+
```json
7272
{
7373
"parent": "MODID:item/test.obj",
7474
"display": {
@@ -103,3 +103,25 @@ JSON-formatted vanilla item models placed in the `models/item` folder can also s
103103
And your item should now render the OBJ model with the proper transformations specified in its model file.
104104

105105
So far, only vanilla model transformations are supported by FOML.
106+
107+
108+
### Using obj models in other contexts
109+
110+
First, register your models:
111+
```java
112+
public static final ModelIdenfier MODEL_IDENTIFIER = new ModelIdentifier(new Identifier(MODID, MODEL_PATH), null);
113+
114+
OBJLoader.INSTANCE.registerDomain(MODID); // Once; register your models after this line
115+
ManualModelLoaderRegistry.INSTANCE.register(MODEL_IDENTIFIER);
116+
```
117+
118+
Then use it in your renderers (example for an EntityModel):
119+
```java
120+
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
121+
MatrixStack.Entry entry = matrices.peek();
122+
BakedModel model = Env.getClient().getBakedModelManager().getModel(MODEL_IDENTIFIER);
123+
for (BakedQuad quad : model.getQuads(null, null, null)) {
124+
vertexConsumer.quad(entry, quad, 1, 1, 1, 15, 0);
125+
}
126+
}
127+
```

0 commit comments

Comments
 (0)