tutorial:entity
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:entity [2021/07/17 18:26] – [Registering Entity Renderer] logdawg970 | tutorial:entity [2025/03/31 13:02] (current) – new Identifier -> Identifier.of slainlight | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Creating an Entity ===== | ===== Creating an Entity ===== | ||
- | //The source code for this project can be found [[https:// | + | //The source code for this project can be found [[https:// |
Entities are a movable object in a world with logic attached to them. A few examples include: | Entities are a movable object in a world with logic attached to them. A few examples include: | ||
Line 10: | Line 10: | ||
Living Entities are Entities that have health and can deal damage. | Living Entities are Entities that have health and can deal damage. | ||
There are various classes that branch off `LivingEntity` for different purposes, including: | There are various classes that branch off `LivingEntity` for different purposes, including: | ||
- | * '' | + | * '' |
- | * '' | + | * '' |
* '' | * '' | ||
- | * '' | + | * '' |
- | What you extend depends on your needs and goals are. | + | What you extend depends on what your needs and goals are. |
As you get further down the chain, the entity logic becomes more specific and curated to certain tasks. | As you get further down the chain, the entity logic becomes more specific and curated to certain tasks. | ||
The two generic entity classes that come after '' | The two generic entity classes that come after '' | ||
Line 61: | Line 61: | ||
*/ | */ | ||
public static final EntityType< | public static final EntityType< | ||
- | | + | |
- | | + | Identifier.of(" |
- | | + | |
); | ); | ||
Line 131: | Line 131: | ||
@Override | @Override | ||
public Identifier getTexture(CubeEntity entity) { | public Identifier getTexture(CubeEntity entity) { | ||
- | return | + | return Identifier.of(" |
} | } | ||
} | } | ||
Line 140: | Line 140: | ||
@Environment(EnvType.CLIENT) | @Environment(EnvType.CLIENT) | ||
public class EntityTestingClient implements ClientModInitializer { | public class EntityTestingClient implements ClientModInitializer { | ||
- | public static final EntityModelLayer MODEL_CUBE_LAYER = new EntityModelLayer(new Identifier(" | + | public static final EntityModelLayer MODEL_CUBE_LAYER = new EntityModelLayer(Identifier.of(" |
@Override | @Override | ||
public void onInitializeClient() { | public void onInitializeClient() { | ||
Line 151: | Line 151: | ||
return new CubeEntityRenderer(context); | return new CubeEntityRenderer(context); | ||
}); | }); | ||
- | EntityModelLayerRegistry.registerModelLayer(MODEL_CUBE_LAYER, | + | |
+ | EntityRendererRegistry.register(EntityTesting.CUBE, | ||
+ | return new CubeEntityRenderer(context); | ||
+ | }); | ||
+ | |||
+ | | ||
} | } | ||
} | } | ||
Line 192: | Line 197: | ||
} | } | ||
| | ||
+ | // You can use BlockBench, make your model and export it to get this method for your entity model. | ||
public static TexturedModelData getTexturedModelData() { | public static TexturedModelData getTexturedModelData() { | ||
ModelData modelData = new ModelData(); | ModelData modelData = new ModelData(); | ||
ModelPartData modelPartData = modelData.getRoot(); | ModelPartData modelPartData = modelData.getRoot(); | ||
- | modelPartData.addChild(EntityModelPartNames.CUBE, | + | modelPartData.addChild(EntityModelPartNames.CUBE, |
+ | return TexturedModelData.of(modelData, | ||
} | } | ||
</ | </ | ||
Line 220: | Line 227: | ||
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { | public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { | ||
ImmutableList.of(this.base).forEach((modelRenderer) -> { | ImmutableList.of(this.base).forEach((modelRenderer) -> { | ||
- | modelRenderer.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); | + | modelRenderer.render(matrices, vertices, light, overlay, red, green, blue, alpha); |
}); | }); | ||
} | } | ||
Line 269: | Line 276: | ||
===== Adding tasks & activities ===== | ===== Adding tasks & activities ===== | ||
- | To add activities see [[: | + | To add activities see [[tutorial: |
tutorial/entity.1626546419.txt.gz · Last modified: 2021/07/17 18:26 by logdawg970