tutorial:entity
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:entity [2020/06/11 20:18] – created draylar | tutorial:entity [2021/06/18 12:12] – Update to 1.17 redgrapefruit | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Creating an Entity ===== | ===== Creating an Entity ===== | ||
+ | |||
+ | //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 17: | Line 19: | ||
The two generic entity classes that come after '' | The two generic entity classes that come after '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
- | '' | + | '' |
for pathfinding favor, and various AI tasks require this to operate. | for pathfinding favor, and various AI tasks require this to operate. | ||
- | In this tutorial, we will look at creating a cube entity that extends '' | + | In this tutorial, we will look at creating a cube entity that extends '' |
This entity will have a model & texture. Movement and mechanics will be covered in a future tutorial. | This entity will have a model & texture. Movement and mechanics will be covered in a future tutorial. | ||
===== Creating & Registering an Entity ===== | ===== Creating & Registering an Entity ===== | ||
- | Create a class that extends '' | + | Create a class that extends '' |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
/* | /* | ||
- | * Our Cube Entity extends | + | * Our Cube Entity extends |
* | * | ||
* LivingEntity has health and can deal damage. | * LivingEntity has health and can deal damage. | ||
* MobEntity has movement controls and AI capabilities. | * MobEntity has movement controls and AI capabilities. | ||
- | | + | |
*/ | */ | ||
- | public class CubeEntity extends | + | public class CubeEntity extends |
- | public CubeEntity(EntityType<? | + | public CubeEntity(EntityType<? |
super(entityType, | super(entityType, | ||
} | } | ||
Line 123: | Line 125: | ||
public class CubeEntityRenderer extends MobEntityRenderer< | public class CubeEntityRenderer extends MobEntityRenderer< | ||
- | public CubeEntityRenderer(EntityRenderDispatcher entityRenderDispatcher) { | + | public CubeEntityRenderer(EntityRendererFactory.Context context) { |
- | super(entityRenderDispatcher, new CubeEntityModel(), | + | super(context, new CubeEntityModel(), |
} | } | ||
Line 146: | Line 148: | ||
* Entity Renderers can also manipulate the model before it renders based on entity context (EndermanEntityRenderer# | * Entity Renderers can also manipulate the model before it renders based on entity context (EndermanEntityRenderer# | ||
*/ | */ | ||
- | EntityRendererRegistry.INSTANCE.register(EntityTesting.CUBE, | + | EntityRendererRegistry.INSTANCE.register(EntityTesting.CUBE, |
- | return new CubeEntityRenderer(dispatcher); | + | return new CubeEntityRenderer(context); |
}); | }); | ||
} | } | ||
Line 254: | Line 256: | ||
You can spawn your entity by typing ''/ | You can spawn your entity by typing ''/ | ||
{{https:// | {{https:// | ||
+ | |||
+ | **NOTE:** If your entity does not extend '' | ||
+ | ===== Adding tasks & activities ===== | ||
+ | |||
+ | To add activities see [[: | ||
tutorial/entity.txt · Last modified: 2024/04/30 20:42 by ryhon