-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add friend entity model to test manual model loading and fix texture …
…loading
- Loading branch information
1 parent
4a752a5
commit 71807bb
Showing
8 changed files
with
268 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
foml-test/src/main/java/nerdhub/fomltest/entity/FriendEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nerdhub.fomltest.entity; | ||
|
||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.mob.CreeperEntity; | ||
import net.minecraft.world.World; | ||
|
||
public class FriendEntity extends CreeperEntity { | ||
public FriendEntity(EntityType<? extends FriendEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
foml-test/src/main/java/nerdhub/fomltest/entity/FriendEntityModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package nerdhub.fomltest.entity; | ||
|
||
import nerdhub.fomltest.FOMLTest; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.render.RenderLayer; | ||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.entity.model.EntityModel; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.BakedQuad; | ||
import net.minecraft.client.util.ModelIdentifier; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class FriendEntityModel<T extends FriendEntity> extends EntityModel<T> { | ||
public static final ModelIdentifier MODEL = new ModelIdentifier(new Identifier(FOMLTest.MODID, "entity/friend.obj"), null); | ||
|
||
public FriendEntityModel() { | ||
super(texture -> RenderLayer.getSolid()); | ||
} | ||
|
||
@Override | ||
public void setAngles(T entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) { | ||
} | ||
|
||
@Override | ||
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 = MinecraftClient.getInstance().getBakedModelManager().getModel(MODEL); | ||
for (BakedQuad quad : model.getQuads(null, null, null)) { | ||
vertexConsumer.quad(entry, quad, red, green, blue, light, overlay); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
foml-test/src/main/java/nerdhub/fomltest/entity/FriendEntityRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package nerdhub.fomltest.entity; | ||
|
||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
import net.minecraft.client.render.entity.MobEntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class FriendEntityRenderer<T extends FriendEntity, M extends FriendEntityModel<T>> extends MobEntityRenderer<T, M> { | ||
public FriendEntityRenderer(EntityRenderDispatcher dispatcher, M model) { | ||
super(dispatcher, model, 1); | ||
} | ||
|
||
@Override | ||
public void render(T mobEntity, float yaw, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int overlay) { | ||
matrixStack.push(); | ||
matrixStack.scale(-1.0F, -1.0F, 1.0F); | ||
this.scale(mobEntity, matrixStack, tickDelta); | ||
matrixStack.translate(0.0D, -1.5010000467300415D, 0.0D); | ||
super.render(mobEntity, yaw, tickDelta, matrixStack, vertexConsumerProvider, overlay); | ||
matrixStack.pop(); | ||
} | ||
|
||
@Override | ||
public Identifier getTexture(T entity) { | ||
return null; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
foml-test/src/main/resources/assets/fomltest/models/entity/friend.mtl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Blender MTL File: 'friend.blend' | ||
# Material Count: 1 | ||
|
||
newmtl Material | ||
Ns 323.999994 | ||
Ka 1.000000 1.000000 1.000000 | ||
Kd 0.800000 0.800000 0.800000 | ||
Ks 0.500000 0.500000 0.500000 | ||
Ke 0.000000 0.000000 0.000000 | ||
Ni 1.450000 | ||
d 1.000000 | ||
illum 2 | ||
map_Kd fomltest:entities/friend |
150 changes: 150 additions & 0 deletions
150
foml-test/src/main/resources/assets/fomltest/models/entity/friend.obj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
# Blender v2.82 (sub 7) OBJ File: 'friend.blend' | ||
# www.blender.org | ||
mtllib entity/friend.mtl | ||
o Cube | ||
v 0.250000 1.800000 -0.250000 | ||
v 0.250000 0.000000 -0.250000 | ||
v 0.250000 1.800000 0.250000 | ||
v 0.250000 0.000000 0.250000 | ||
v -0.250000 1.800000 -0.250000 | ||
v -0.250000 0.000000 -0.250000 | ||
v -0.250000 1.800000 0.250000 | ||
v -0.250000 0.000000 0.250000 | ||
v 0.250000 1.350000 -0.250000 | ||
v -0.250000 1.350000 0.250000 | ||
v 0.250000 1.350000 0.250000 | ||
v -0.250000 1.350000 -0.250000 | ||
v 0.250000 1.282500 -0.250000 | ||
v 0.250000 1.282500 0.250000 | ||
v -0.250000 1.282500 -0.250000 | ||
v -0.250000 1.282500 0.250000 | ||
v 0.250000 0.064125 -0.250000 | ||
v 0.250000 0.064125 0.250000 | ||
v -0.250000 0.064125 -0.250000 | ||
v -0.250000 0.064125 0.250000 | ||
v -0.225000 0.064125 0.225000 | ||
v -0.225000 1.282500 0.225000 | ||
v 0.225000 1.282500 0.225000 | ||
v -0.225000 1.282500 -0.225000 | ||
v 0.225000 1.282500 -0.225000 | ||
v 0.225000 0.064125 -0.225000 | ||
v 0.225000 0.064125 0.225000 | ||
v -0.225000 0.064125 -0.225000 | ||
vt 0.250000 0.750000 | ||
vt 0.500000 0.750000 | ||
vt 0.500000 1.000000 | ||
vt 0.250000 1.000000 | ||
vt 0.500000 0.500000 | ||
vt 0.500000 0.750000 | ||
vt 0.250000 0.750000 | ||
vt 0.250000 0.500000 | ||
vt 0.000000 0.500000 | ||
vt 0.250000 0.500000 | ||
vt 0.250000 0.750000 | ||
vt 0.000000 0.750000 | ||
vt 0.500000 0.000000 | ||
vt 0.750000 0.000000 | ||
vt 0.750000 0.250000 | ||
vt 0.500000 0.250000 | ||
vt 0.500000 0.500000 | ||
vt 0.750000 0.500000 | ||
vt 0.750000 0.750000 | ||
vt 0.500000 0.750000 | ||
vt 0.750000 0.500000 | ||
vt 1.000000 0.500000 | ||
vt 1.000000 0.750000 | ||
vt 0.750000 0.750000 | ||
vt 0.968750 0.250000 | ||
vt 1.000000 0.250000 | ||
vt 1.000000 0.500000 | ||
vt 0.968750 0.500000 | ||
vt 0.531250 0.125000 | ||
vt 0.562500 0.125000 | ||
vt 0.562500 0.375000 | ||
vt 0.531250 0.375000 | ||
vt 0.968750 0.000000 | ||
vt 1.000000 0.000000 | ||
vt 0.500000 0.125000 | ||
vt 0.531250 0.125000 | ||
vt 0.531250 0.375000 | ||
vt 0.500000 0.375000 | ||
vt 0.250000 0.343750 | ||
vt 0.500000 0.343750 | ||
vt 0.500000 0.375000 | ||
vt 0.250000 0.375000 | ||
vt 0.812500 0.093750 | ||
vt 0.812500 0.062500 | ||
vt 0.781250 0.062500 | ||
vt 0.781250 0.093750 | ||
vt 0.750000 0.343750 | ||
vt 1.000000 0.343750 | ||
vt 1.000000 0.375000 | ||
vt 0.750000 0.375000 | ||
vt 0.812500 0.125000 | ||
vt 0.781250 0.125000 | ||
vt 0.718750 0.250000 | ||
vt 0.750000 0.250000 | ||
vt 0.750000 0.500000 | ||
vt 0.718750 0.500000 | ||
vt 0.750000 0.750000 | ||
vt 0.718750 0.750000 | ||
vt 0.718750 0.000000 | ||
vt 0.750000 0.000000 | ||
vt 0.750000 1.000000 | ||
vt 0.718750 1.000000 | ||
vt 0.093750 0.125000 | ||
vt 0.843750 0.125000 | ||
vt 0.843750 0.375000 | ||
vt 0.093750 0.375000 | ||
vt 0.093750 -0.000000 | ||
vt 0.843750 -0.000000 | ||
vt 0.843750 0.250000 | ||
vt 0.093750 0.250000 | ||
vt 0.093750 -0.000000 | ||
vt 0.843750 -0.000000 | ||
vt 0.843750 0.250000 | ||
vt 0.093750 0.250000 | ||
vt 0.093750 0.125000 | ||
vt 0.843750 0.125000 | ||
vt 0.843750 0.375000 | ||
vt 0.093750 0.375000 | ||
vt -0.000000 0.343750 | ||
vt -0.000000 0.375000 | ||
vt 0.812500 0.031250 | ||
vt 0.812500 0.000000 | ||
vt 0.781250 0.000000 | ||
vt 0.781250 0.031250 | ||
vn 0.0000 1.0000 0.0000 | ||
vn 0.0000 0.0000 1.0000 | ||
vn -1.0000 0.0000 0.0000 | ||
vn 0.0000 -1.0000 0.0000 | ||
vn 1.0000 0.0000 0.0000 | ||
vn 0.0000 0.0000 -1.0000 | ||
usemtl Material | ||
s off | ||
f 1/1/1 5/2/1 7/3/1 3/4/1 | ||
f 11/5/2 3/6/2 7/7/2 10/8/2 | ||
f 10/9/3 7/10/3 5/11/3 12/12/3 | ||
f 6/13/4 2/14/4 4/15/4 8/16/4 | ||
f 9/17/5 1/18/5 3/19/5 11/20/5 | ||
f 12/21/6 5/22/6 1/23/6 9/24/6 | ||
f 15/25/6 12/26/6 9/27/6 13/28/6 | ||
f 13/29/5 9/30/5 11/31/5 14/32/5 | ||
f 16/33/3 10/34/3 12/26/3 15/25/3 | ||
f 14/35/2 11/36/2 10/37/2 16/38/2 | ||
f 15/39/4 13/40/4 25/41/4 24/42/4 | ||
f 18/43/1 17/44/1 26/45/1 27/46/1 | ||
f 14/47/4 16/48/4 22/49/4 23/50/4 | ||
f 20/51/1 18/43/1 27/46/1 21/52/1 | ||
f 6/53/6 19/54/6 17/55/6 2/56/6 | ||
f 2/56/5 17/55/5 18/57/5 4/58/5 | ||
f 8/59/3 20/60/3 19/54/3 6/53/3 | ||
f 4/58/2 18/57/2 20/61/2 8/62/2 | ||
f 27/63/2 23/64/2 22/65/2 21/66/2 | ||
f 21/67/3 22/68/3 24/69/3 28/70/3 | ||
f 26/71/5 25/72/5 23/73/5 27/74/5 | ||
f 28/75/6 24/76/6 25/77/6 26/78/6 | ||
f 16/79/4 15/39/4 24/42/4 22/80/4 | ||
f 19/81/1 20/82/1 21/83/1 28/84/1 | ||
f 17/44/1 19/81/1 28/84/1 26/45/1 | ||
f 13/40/4 14/47/4 23/50/4 25/41/4 |
Binary file added
BIN
+2.38 KB
foml-test/src/main/resources/assets/fomltest/textures/entities/friend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.