Minecraft is not just a game, it's a whole platform for creativity and learning programming! Today we will figure out how to create your own mob from scratch. This is a great way to get to know Java and understand the basics of game development.

What do we need?
Before you start, make sure you have:
Java Development Kit (JDK) version 17 or higher
IntelliJ IDEA (Community Edition is suitable)
Minecraft Forge MDK (Mod Development Kit)
Basic Java knowledge (variables, classes, methods)
Step 1: Setting up the environment
First, download Forge MDK from the official website files.minecraftforge.net. Unzip the archive into a separate folder and open the project in IntelliJ IDEA.
Run the command in the IDE terminal:
./gradlew genIntellijRuns💡 Tip: This will set up the project for development. Wait for Gradle to download all dependencies — this may take a few minutes.
Step 2: Create a mob class
Let's create a simple mob — a friendly firefly that will fly and glow at night.
In the src/main/java/com/yourname/yourmod/entity folder, create the FireflyEntity.java file:
package com.yourname.yourmod.entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal;
import net.minecraft.world.level.Level;
public class FireflyEntity extends PathfinderMob {
public FireflyEntity(EntityType<? extends PathfinderMob> type, Level world) {
super(type, world);
}
// Registering mob behavior
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(1, new WaterAvoidingRandomStrollGoal(this, 1.0D));
}
// Configure attributes (health, speed)
public static AttributeSupplier.Builder createAttributes() {
return PathfinderMob.createMobAttributes()
.add(Attributes.MAX_HEALTH, 5.0D)
.add(Attributes.MOVEMENT_SPEED, 0.25D);
}
}What's going on here?
PathfinderMob — base class for mobs that can walk
registerGoals() — a method where we determine the behavior of the mob (swimming, walking, attacking)
createAttributes() — here we set the characteristics: health, speed, damage
Step 3: Register the mob
Now we need to "tell" the game about our mob. Create a class ModEntities.java:
package com.yourname.yourmod.entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModEntities {
public static final DeferredRegister<EntityType<?>> ENTITIES =
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, "yourmod");
public static final RegistryObject<EntityType<FireflyEntity>> FIREFLY =
ENTITIES.register("firefly", () -> EntityType.Builder
.of(FireflyEntity::new, MobCategory.CREATURE)
.sized(0.4F, 0.3F) // hitbox size
.build("firefly"));
}Don't forget to register ENTITIES in the main class of your mod:
@Mod("yourmod")
public class YourMod {
public YourMod() {
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
ModEntities.ENTITIES.register(bus);
}
}Step 4: Create a model and texture
There is a mob, but it is invisible! You need to create a 3D model. You can use the program Blockbench - free editor for Minecraft models.
Create a simple model (cube for the body, small cubes for the wings)
Export as Java file
Place the model in
src/main/java/com/yourname/yourmod/client/model/Create a texture (16x16 pixels) and save it in
src/main/resources/assets/yourmod/textures/entity/

Step 5: Mob Renderer
Create a class FireflyRenderer.java:
package com.yourname.yourmod.client.renderer;
import com.yourname.yourmod.entity.FireflyEntity;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
public class FireflyRenderer extends MobRenderer<FireflyEntity, FireflyModel> {
private static final ResourceLocation TEXTURE =
new ResourceLocation("yourmod", "textures/entity/firefly.png");
public FireflyRenderer(EntityRendererProvider.Context context) {
super(context, new FireflyModel(context.bakeLayer(FireflyModel.LAYER)), 0.3F);
}
@Override
public ResourceLocation getTextureLocation(FireflyEntity entity) {
return TEXTURE;
}
}Step 6: Spawn the mob in the world
Let's add a mob to the natural spawn of the game. In the main mod class, add an event handler:
@SubscribeEvent
public static void onBiomeLoading(BiomeLoadingEvent event) {
if (event.getCategory() == Biome.BiomeCategory.FOREST) {
event.getSpawns().getSpawner(MobCategory.CREATURE)
.add(new MobSpawnSettings.SpawnerData(
ModEntities.FIREFLY.get(), 15, 2, 4));
}
}✅ Excellent! Now fireflies will appear in forest biomes!
Step 7: Testing
Run the game through IntelliJ IDEA (use the runClient configuration). Create a new world and check:
Does the mob appear in the forest?
Is the model displayed correctly?
Does the behavior (walking, swimming) work?
💡 Tip: If something doesn't work, check the logs in the console. Forge describes all errors in detail.
Additional features
You can add a mob:
Own sounds (steps, attack, death)
Animations (wings fluttering, glowing)
Unique behavior (attack, escape, search for food)
Item drop in case of death
Spawn through the summoning egg
@Override
protected void dropCustomDeathLoot(DamageSource source, int looting, boolean recentlyHit) {
super.dropCustomDeathLoot(source, looting, recentlyHit);
this.spawnAtLocation(Items.GLOWSTONE_DUST, 1);
}Common mistakes of beginners
Forgot to register the mob — check that
ENTITIES.register(bus)is calledIncorrect texture path — make sure that the paths in the code and the file system match
Did not generate a working environment — perform
gradlew genIntellijRunsagainOutdated version of Forge - use the latest stable version for your Minecraft version
Do you want to explore this topic in more depth and create a really cool mob with unique mechanics?
In Codice we analyze in detail many other programming topics - from the basics of Java to the creation of complex projects. Each topic is accompanied by practical tasks that will help to consolidate the material.
Here you will learn:
Work with Java on real examples
Create mods, plugins, and games
Understand code architecture and write clean code
Solve problems like a real developer
And if you have any questions or need support, welcome to our active Telegram channel, where a large team of like-minded people has already gathered! We will always help you to deal with the problem, suggest the best solution and support you on the way of learning.
Join Kodik — programming can be clear and exciting! 🚀
