Skip to content

Commit

Permalink
README.md: add manual model loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpieboop committed Feb 21, 2020
1 parent 030e9e2 commit 4a752a5
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Adding the API to your project

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

### **Example:**

```
```java
OBJLoader.INSTANCE.registerDomain(MODID);
```

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

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

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

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

So far, only vanilla model transformations are supported by FOML.


### Using obj models in other contexts

First, register your models:
```java
public static final ModelIdenfier MODEL_IDENTIFIER = new ModelIdentifier(new Identifier(MODID, MODEL_PATH), null);

OBJLoader.INSTANCE.registerDomain(MODID); // Once; register your models after this line
ManualModelLoaderRegistry.INSTANCE.register(MODEL_IDENTIFIER);
```

Then use it in your renderers (example for an EntityModel):
```java
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
MatrixStack.Entry entry = matrices.peek();
BakedModel model = Env.getClient().getBakedModelManager().getModel(MODEL_IDENTIFIER);
for (BakedQuad quad : model.getQuads(null, null, null)) {
vertexConsumer.quad(entry, quad, 1, 1, 1, 15, 0);
}
}
```

0 comments on commit 4a752a5

Please sign in to comment.