I recommend adding options for auto-spawning and attack goals because those are common entity functions:
MobCategory.CREATUR in ModEntityTypes and
BiomeModifications.addSpawn(
BiomeSelectors.foundInOverworld(),
MobCategory.CREATURE,
ModEntityTypes.MINI_GOLEM,
20,
2,
4
);
in main onInitialize
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, (double)1.0F, true));
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal(this, Mob.class, 5, false, false, (target, var1) -> target instanceof Enemy));
I just completed the "Creating Your First Entity" part of the Fabric documentation. The following things were unclear or missing from the documentation:
After using the Template mod generator, files must be in the correct directories:
\src\client\java\com\example\docs\client\mixin\ExampleClientMixin.java
\src\client\java\com\example\docs\entity\ExampleModCustomEntityClient.java
\src\client\java\com\example\docs\entity\animation\MiniGolemAnimations.java
\src\client\java\com\example\docs\entity\client\EntityClient.java
\src\client\java\com\example\docs\entity\client\mixin\ExampleClientMixin.java
\src\client\java\com\example\docs\entity\model\MiniGolemEntityModel.java
\src\client\java\com\example\docs\entity\model\ModEntityModelLayers.java
\src\client\java\com\example\docs\entity\renderer\MiniGolemEntityRenderer.java
\src\client\java\com\example\docs\entity\state\MiniGolemEntityRenderState.java
\src\client\resources\entity.client.mixins.json
\src\client\resources\assets\example-mod\textures\entity\mini_golem_small.png
\src\main\java\com\example\docs\ExampleMod.java
\src\main\java\com\example\docs\entity\MiniGolemEntity.java
\src\main\java\com\example\docs\entity\ModEntityTypes.java
\src\main\java\com\example\docs\entity\attribute\EntityAttributesGameTest.java
\src\main\java\com\example\docs\entity\attribute\ExampleModAttributes.java
\src\main\java\com\example\docs\entity\attribute\ModAttributes.java
\src\main\java\com\example\docs\entity\mixin\ExampleMixin.java
\src\main\java\com\example\docs\mixin\ExampleMixin.java
\src\main\resources\entity.mixins.json
\src\main\resources\fabric.mod.json
\src\main\resources\assets\example-mod\icon.png
Mod ID must match between ExampleMod.java
public static final String MOD_ID = "example-mod";
and fabric.mod.json
"name": "example-mod",
Entry points must be set correctly in fabric.mod.json, template client file should be removed
"entrypoints": {
"main": [
"com.example.docs.ExampleMod"
],
"client": [
"com.example.docs.entity.ExampleModCustomEntityClient"
]
},
Code to register the entity must be added to the main entry point function (or a file for the main entry point should be provided):
ModEntityTypes.registerModEntityTypes();
ModEntityTypes.registerAttributes();
I recommend adding options for auto-spawning and attack goals because those are common entity functions:
MobCategory.CREATUR in ModEntityTypes and
BiomeModifications.addSpawn(
BiomeSelectors.foundInOverworld(),
MobCategory.CREATURE,
ModEntityTypes.MINI_GOLEM,
20,
2,
4
);
in main onInitialize
in registerGoals
and
.add(Attributes.ATTACK_DAMAGE, 1);
in AttributeSupplier.Builder