Creating a full Minecraft Fabric mod with a custom entity, model, texture, and animations is a complex task, but I will provide a complete example project structure and all necessary code and resource files. This example will be for Minecraft 1.20.1 with Fabric.
Overview
Entity name: Tricky
Behavior: Attacks player, then runs away very fast
Custom model: JSON model with animations (using GeckoLib)
Texture: Custom PNG
Animations: Simple attack and run animations
Tools & Libraries used
Fabric API
Fabric Loom (build tool)
GeckoLib (for animated entity models)
1. Project Structure
code Copy code
trickymod/
├── build.gradle
├── gradle/
├── gradlew
├── gradlew.bat
├── settings.gradle
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ └── tricky/
│ │ │ ├── TrickyMod.java
│ │ │ ├── entity/
│ │ │ │ ├── TrickyEntity.java
│ │ │ │ ├── TrickyEntityRenderer.java
│ │ │ │ └── TrickyEntityModel.java
│ │ │ └── entity/
│ │ │ └── TrickyEntityRenderer.java
│ │ └── resources/
│ │ ├── META-INF/
│ │ │ └── mods.toml
│ │ ├── fabric.mod.json
│ │ ├── assets/
│ │ │ └── trickymod/
│ │ │ ├── animations/
│ │ │ │ └── tricky.animation.json
│ │ │ ├── models/
│ │ │ │ └── entity/
│ │ │ │ └── tricky.geo.json
│ │ │ ├── textures/
│ │ │ │ └── entity/
│ │ │ │ └── tricky.png
│ │ │ └── lang/
│ │ │ └── en_us.json
2. build.gradle
gradle Copy code
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
id 'java'
}
group = 'com.example'
version = '1.0.0'
archivesBaseName = 'trickymod'
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
maven { url = 'https://maven.fabricmc.net/' }
maven { url = 'https://repo.spongepowered.org/maven' }
maven { url = 'https://jitpack.io' }
}
dependencies {
minecraft 'com.mojang:minecraft:1.20.1'
mappings 'net.fabricmc:yarn:1.20.1+build.6:v2'
modImplementation 'net.fabricmc:fabric-loader:0.14.21'
modImplementation 'net.fabricmc.fabric-api:fabric-api:0.77.0+1.20.1'
modImplementation 'software.bernie.geckolib:geckolib-fabric-1.20.1:4.0.2'
}
java {
withSourcesJar()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.release = 17
}
3. settings.gradle
gradle Copy code
rootProject.name = 'trickymod'
4. fabric.mod.json
json Copy code
{
"schemaVersion": 1,
"id": "trickymod",
"version": "1.0.0",
"name": "Tricky Mod",
"description": "Adds the annoying Tricky mob that attacks and runs away.",
"authors": [
"YourName"
],
"contact": {
"homepage": "https://example.com",
"sources": "https://github.com/example/trickymod"
},
"license": "MIT",
"environment": "*",
"entrypoints": {
"main": [
"com.example.tricky.TrickyMod"
],
"client": [
"com.example.tricky.entity.TrickyEntityRenderer"
]
},
"depends": {
"fabricloader": ">=0.14.0",
"fabric": "*",
"minecraft": "1.20.1",
"geckolib3": "*"
},
"suggests": {
"another-mod": "*"
}
}
5. mods.toml (META-INF/mods.toml)
toml Copy code
modLoader="fabric"
loaderVersion="[0.14,)"
license="MIT"
issueTrackerURL="https://github.com/example/trickymod/issues"
[[mods]]
modId="trickymod"
version="1.0.0"
displayName="Tricky Mod"
description='''Adds the annoying Tricky mob that attacks and runs away.'''
authors="YourName"
6. Java Source Code
6.1 TrickyMod.java
java Copy code
package com.example.tricky;
import com.example.tricky.entity.TrickyEntity;
import com.example.tricky.entity.TrickyEntityRenderer;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class TrickyMod implements ModInitializer, ClientModInitializer {
public static final String MODID = "trickymod";
public static final EntityType<TrickyEntity> TRICKY_ENTITY_TYPE = Registry.register(
Registry.ENTITY_TYPE,
new Identifier(MODID, "tricky"),
FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, TrickyEntity::new)
.dimensions(EntityDimensions.fixed(0.6f, 1.8f))
.build()
);
@Override
public void onInitialize() {
// Server-side initialization if needed
}
@Override
public void onInitializeClient() {
EntityRendererRegistry.register(TRICKY_ENTITY_TYPE, TrickyEntityRenderer::new);
}
}
6.2 TrickyEntity.java
java Copy code
package com.example.tricky.entity;
import com.example.tricky.TrickyMod;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
public class TrickyEntity extends MobEntity implements IAnimatable {
private final AnimationFactory factory = new AnimationFactory(this);
public TrickyEntity(EntityType<? extends MobEntity> entityType, World world) {
super(entityType, world);
this.experiencePoints = 5;
}
@Override
protected void initGoals() {
this.goalSelector.add(1, new MeleeAttackGoal(this, 1.2, false));
this.goalSelector.add(2, new FleeSunlightGoal(this, 1.5));
this.goalSelector.add(3, new WanderAroundFarGoal(this, 1.0));
this.goalSelector.add(4, new LookAtEntityGoal(this, PlayerEntity.class, 8.0f));
this.targetSelector.add(1, new ActiveTargetGoal<>(this, PlayerEntity.class, true));
}
@Override
public void tick() {
super.tick();
if (this.getTarget() != null && this.distanceTo(this.getTarget()) < 3) {
// Attack and then run away fast
this.getNavigation().stop();
this.getNavigation().startMovingTo(this.getX() + (random.nextDouble() - 0.5) * 10,
this.getY(),
this.getZ() + (random.nextDouble() - 0.5) * 10,
2.5);
}
}
private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
if (this.getTarget() != null && this.distanceTo(this.getTarget()) < 3) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.tricky.attack", false));
return PlayState.CONTINUE;
} else if (this.getNavigation().isFollowingPath()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.tricky.run", true));
return PlayState.CONTINUE;
} else {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.tricky.idle", true));
return PlayState.CONTINUE;
}
}
@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController<>(this, "controller", 4, this::predicate));
}
@Override
public AnimationFactory getFactory() {
return factory;
}
}
6.3 TrickyEntityRenderer.java
java Copy code
package com.example.tricky.entity;
import com.example.tricky.TrickyMod;
import net.minecraft.client.render.entity.EntityRendererFactory;
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;
public class TrickyEntityRenderer extends GeoEntityRenderer<TrickyEntity> {
public TrickyEntityRenderer(EntityRendererFactory.Context ctx) {
super(ctx, new TrickyEntityModel());
this.shadowRadius = 0.5f;
}
@Override
public net.minecraft.util.Identifier getTextureLocation(TrickyEntity entity) {
return new net.minecraft.util.Identifier(TrickyMod.MODID, "textures/entity/tricky.png");
}
}
6.4 TrickyEntityModel.java
java Copy code
package com.example.tricky.entity;
import software.bernie.geckolib3.model.AnimatedGeoModel;
public class TrickyEntityModel extends AnimatedGeoModel<TrickyEntity> {
@Override
public net.minecraft.util.Identifier getModelLocation(TrickyEntity object) {
return new net.minecraft.util.Identifier("trickymod", "models/entity/tricky.geo.json");
}
@Override
public net.minecraft.util.Identifier getTextureLocation(TrickyEntity object) {
return new net.minecraft.util.Identifier("trickymod", "textures/entity/tricky.png");
}
@Override
public net.minecraft.util.Identifier getAnimationFileLocation(TrickyEntity animatable) {
return new net.minecraft.util.Identifier("trickymod", "animations/tricky.animation.json");
}
}
7. Resources
7.1 Texture: src/main/resources/assets/trickymod/textures/entity/tricky.png
Place your custom PNG texture here.
For testing, you can create a simple 64x64 PNG with a colorful pattern or a simple face.
7.2 Model: src/main/resources/assets/trickymod/models/entity/tricky.geo.json
Here is a very simple GeckoLib model JSON example (a cube with a head):
json Copy code
{
"format_version": "1.12",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.tricky",
"texture_width": 64,
"texture_height": 64,
"visible_bounds_width": 2,
"visible_bounds_height": 3,
"visible_bounds_offset": [0, 1.5, 0]
},
"bones": [
{
"name": "body",
"pivot": [0, 12, 0],
"cubes": [
{
"origin": [-4, 0, -2],
"size": [8, 12, 4],
"uv": [0, 0]
}
]
},
{
"name": "head",
"parent": "body",
"pivot": [0, 12, 0],
"cubes": [
{
"origin": [-4, 12, -4],
"size": [8, 8, 8],
"uv": [32, 0]
}
]
}
]
}
]
}
7.3 Animations: src/main/resources/assets/trickymod/animations/tricky.animation.json
Example animation JSON for GeckoLib:
json Copy code
{
"format_version": "1.10",
"animations": {
"animation.tricky.idle": {
"loop": true,
"bones": {}
},
"animation.tricky.run": {
"loop": true,
"bones": {
"body": {
"rotation": [
{
"key": 0,
"angle": 5,
"axis": "x"
},
{
"key": 5,
"angle": -5,
"axis": "x"
},
{
"key": 10,
"angle": 5,
"axis": "x"
}
]
},
"head": {
"rotation": [
{
"key": 0,
"angle": 10,
"axis": "x"
},
{
"key": 5,
"angle": -10,
"axis": "x"
},
{
"key": 10,
"angle": 10,
"axis": "x"
}
]
}
}
},
"animation.tricky.attack": {
"loop": false,
"bones": {
"head": {
"rotation": [
{
"key": 0,
"angle": 0,
"axis": "x"
},
{
"key": 3,
"angle": -30,
"axis": "x"
},
{
"key": 6,
"angle": 0,
"axis": "x"
}
]
}
}
}
}
}
7.4 Language file: src/main/resources/assets/trickymod/lang/en_us.json
json Copy code
{
"entity.trickymod.tricky": "Tricky"
}
8. How to build and run
Place your texture PNG in the specified folder.
Run ./gradlew build to build the mod.
Place the generated JAR in your Fabric mods folder.
Run Minecraft 1.20.1 with Fabric Loader and Fabric API.
Spawn the entity with /summon trickymod:tricky.
Summary
This mod adds a custom entity "Tricky" with:
Custom model and texture using GeckoLib
Animations for idle, run, and attack
Behavior: attacks player, then runs away fast
If you want me to generate the texture or a more complex model, or help with spawning commands or data packs, just ask!