Back to Skills

custom-mob-spawn-egg

majiayu000
Updated Today
1 views
58
9
58
View on GitHub
Designdesign

About

This skill provides implementation guidance for adding custom mob spawn eggs in Minecraft mods. It includes a comprehensive checklist covering item registration, entity configuration, and resource file setup across Fabric and NeoForge versions. Use it to prevent common visual bugs like black squares or grayscale textures when creating spawn eggs.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/majiayu000/claude-skill-registry
Git CloneAlternative
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/custom-mob-spawn-egg

Copy and paste this command in Claude Code to install this skill

Documentation

Custom Mob Spawn Egg Implementation Guide

Purpose: Ensure all required steps are completed when adding a spawn egg for a custom mob. Spawn eggs require multiple registration points across Fabric, NeoForge, and multi-version resource files. Missing any step causes visual bugs (grayscale, invisible texture).


Spawn Egg Implementation Checklist

When adding a spawn egg for a new custom mob, all of the following steps must be completed:

1. Item Registration (ModItems.java)

Register the spawn egg item in ModItems.java for each version.

1.21.2 (requires .setId()):

public static final RegistrySupplier<Item> MOB_NAME_SPAWN_EGG = ITEMS.register(
    "mob_name_spawn_egg",
    () -> new com.chronodawn.items.DeferredSpawnEggItem(
        ModEntities.MOB_NAME,
        0xAABBCC, // Background color
        0xDDEEFF, // Spots color
        new Item.Properties()
                .setId(ResourceKey.create(Registries.ITEM,
                    ResourceLocation.fromNamespaceAndPath(ChronoDawn.MOD_ID, "mob_name_spawn_egg")))
    )
);

1.21.1 / 1.20.1 (simpler, no .setId()):

public static final RegistrySupplier<Item> MOB_NAME_SPAWN_EGG = ITEMS.register(
    "mob_name_spawn_egg",
    () -> new com.chronodawn.items.DeferredSpawnEggItem(
        ModEntities.MOB_NAME,
        0xAABBCC, // Background color
        0xDDEEFF, // Spots color
        new Item.Properties()
    )
);

2. Initialize Spawn Egg (ModItems.java)

Add the initializeSpawnEgg() call inside the initializeSpawnEggs() method:

if (MOB_NAME_SPAWN_EGG.get() instanceof com.chronodawn.items.DeferredSpawnEggItem) {
    ((com.chronodawn.items.DeferredSpawnEggItem) MOB_NAME_SPAWN_EGG.get()).initializeSpawnEgg();
}

3. Creative Tab Entry (ModItems.java)

Add to the populateCreativeTab() method:

if (MOB_NAME_SPAWN_EGG.isPresent()) {
    output.accept(MOB_NAME_SPAWN_EGG.get());
}

4. Item Model File (CRITICAL)

Without this file, the spawn egg will be completely invisible in the inventory.

Create models/item/mob_name_spawn_egg.json in all version resource directories:

  • common-1.20.1/src/main/resources/assets/chronodawn/models/item/
  • common-1.21.1/src/main/resources/assets/chronodawn/models/item/
  • common-1.21.2/src/main/resources/assets/chronodawn/models/item/

Content (identical for all versions):

{
  "parent": "item/template_spawn_egg"
}

No custom texture file is needed - Minecraft generates the spawn egg texture procedurally from the two color values.

5. NeoForge Color Handler Registration (CRITICAL)

Without this, the spawn egg will appear grayscale on NeoForge. Fabric handles this automatically via vanilla mechanisms, but NeoForge requires explicit registration.

File: neoforge-base/src/main/java/com/chronodawn/neoforge/client/ChronoDawnClientNeoForge.java

Add ModItems.MOB_NAME_SPAWN_EGG.get() to the item list in the onRegisterItemColors method:

@SubscribeEvent
public static void onRegisterItemColors(RegisterColorHandlersEvent.Item event) {
    event.register(
        (stack, tintIndex) -> {
            if (stack.getItem() instanceof com.chronodawn.items.DeferredSpawnEggItem egg) {
                int color = egg.getColor(tintIndex);
                return 0xFF000000 | color;
            }
            return 0xFFFFFFFF;
        },
        // ... existing spawn eggs ...
        ModItems.MOB_NAME_SPAWN_EGG.get()  // <-- Add here
    );
}

6. Language Files

Add entries to both en_us.json and ja_jp.json for all 3 versions:

"item.chronodawn.mob_name_spawn_egg": "Mob Name Spawn Egg"

Common Issues

SymptomCauseFix
Spawn egg invisible, or black square (dark purple on hover)Missing item model JSONAdd models/item/xxx_spawn_egg.json with "parent": "item/template_spawn_egg"
Grayscale on NeoForge onlyMissing NeoForge color handlerAdd to onRegisterItemColors in ChronoDawnClientNeoForge.java
Correct on NeoForge, broken on FabricMissing initializeSpawnEgg() callAdd to initializeSpawnEggs()
No name displayedMissing lang entryAdd to en_us.json / ja_jp.json
Not in creative tabMissing creative tab entryAdd to populateCreativeTab()

Why NeoForge Needs Explicit Color Registration

Minecraft spawn eggs use tintIndex (0 = background, 1 = spots) to colorize the template texture at runtime. Fabric integrates with vanilla's ColorProviderRegistry automatically through DeferredSpawnEggItem, but NeoForge uses its own event system (RegisterColorHandlersEvent.Item) which requires manual registration. The alpha channel (0xFF000000 |) must also be added explicitly on NeoForge.

GitHub Repository

majiayu000/claude-skill-registry
Path: skills/custom-mob-spawn-egg

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

creating-opencode-plugins

Meta

This skill provides the structure and API specifications for creating OpenCode plugins that hook into 25+ event types like commands, files, and LSP operations. It offers implementation patterns for JavaScript/TypeScript modules that intercept and extend the AI assistant's lifecycle. Use it when you need to build event-driven plugins for monitoring, custom handling, or extending OpenCode's capabilities.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

Algorithmic Art Generation

Meta

This skill helps developers create algorithmic art using p5.js, focusing on generative art, computational aesthetics, and interactive visualizations. It automatically activates for topics like "generative art" or "p5.js visualization" and guides you through creating unique algorithms with features like seeded randomness, flow fields, and particle systems. Use it when you need to build reproducible, code-driven artistic patterns.

View skill