Skip to content
On this page
Common

Entity

top.katton.api.registrycommon/src/main/kotlin/top/katton/api/registry/Entity.kt
Registers a complete native Entity with hot-reload support.

registerNativeEntity

registerNativeEntityCommonFunction
kotlin
@ApiStatus.Experimental
@ApiStatus.Experimental fun registerNativeEntity(id: String, registerMode: RegisterMode = RegisterMode.WORLD, configure: KattonEntityProperties.() -> Unit = {}, entityFactory: (KattonEntityProperties) -> EntityType<*>): KattonRegistry.KattonEntityTypeEntry

Registers a complete native Entity with hot-reload support.

This is the primary API for registering custom entities from scripts. It handles EntityType registration plus optional attributes, spawn egg, and spawn placement configuration in a single call.

Parameters

ParameterDescription
idEntity identifier (e.g., "mymod:custom_mob")
registerModeRegistration mode (GLOBAL, WORLD, or RELOADABLE)
configureConfiguration lambda for entity properties (dimensions, category, attributes, etc.)
entityFactoryFactory function to create the EntityType instance

Returns

The registered KattonEntityTypeEntry

registerNativeEntity

registerNativeEntityCommonFunction
kotlin
fun registerNativeEntity(id: Identifier, registerMode: RegisterMode = RegisterMode.WORLD, configure: KattonEntityProperties.() -> Unit = {}, entityFactory: (KattonEntityProperties) -> EntityType<*>): KattonRegistry.KattonEntityTypeEntry

Registers a complete native Entity with hot-reload support (Identifier overload).

registerEntityAttributes

registerEntityAttributesCommonFunction
kotlin
@ApiStatus.Experimental
@ApiStatus.Experimental fun registerEntityAttributes(id: String, entityType: EntityType<out net.minecraft.world.entity.LivingEntity>, configure: KattonEntityProperties.() -> Unit, reloadable: Boolean = true)

Registers entity default attributes independently.

Use this when you want to register attributes for an entity that was already registered via [registerNativeEntityType]. For new entities, prefer [registerNativeEntity] which handles attributes automatically.

Note: This uses the reloadable path by default since standalone attribute registration typically happens during hot-reload. For global entities, use [registerNativeEntity] which routes through the correct mode-aware path.

Parameters

ParameterDescription
idEntity identifier
entityTypeThe already-registered entity type
configureConfiguration lambda for attributes
reloadabletrue for RELOADABLE, false for GLOBAL

registerSpawnPlacement

registerSpawnPlacementCommonFunction
kotlin
@ApiStatus.Experimental
@Suppress("UNCHECKED_CAST")
@ApiStatus.Experimental @Suppress("UNCHECKED_CAST") fun <T : net.minecraft.world.entity.Mob> registerSpawnPlacement(entityType: EntityType<T>, placementType: SpawnPlacementType, heightmap: Heightmap.Types = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, predicate: SpawnPlacements.SpawnPredicate<T>, reloadable: Boolean = true)

Registers a spawn placement rule independently.

Parameters

ParameterDescription
TThe mob entity type
entityTypeThe entity type
placementTypeWhere the entity can spawn (e.g., ON_GROUND, IN_WATER)
heightmapThe heightmap type for spawn checks
predicateCustom spawn predicate
reloadabletrue for RELOADABLE, false for GLOBAL

registerSpawnEgg

registerSpawnEggCommonFunction
kotlin
@ApiStatus.Experimental
@ApiStatus.Experimental fun registerSpawnEgg(id: String, entityType: EntityType<out net.minecraft.world.entity.Mob>, registerMode: RegisterMode = RegisterMode.WORLD): KattonRegistry.KattonItemEntry

Registers a spawn egg item for an entity type independently.

Use this to create a spawn egg for an entity registered via [registerNativeEntityType]. For new entities, prefer [registerNativeEntity] with withSpawnEgg().

In MC 1.21.11+, spawn egg colors are derived from the entity type automatically.

Parameters

ParameterDescription
idSpawn egg item identifier (e.g., "mymod:custom_mob_spawn_egg")
entityTypeThe entity type this egg spawns
registerModeRegistration mode

Returns

The registered KattonItemEntry

registerSpawnEgg

registerSpawnEggCommonFunction
kotlin
@ApiStatus.Experimental
@ApiStatus.Experimental fun registerSpawnEgg(id: Identifier, entityType: EntityType<out net.minecraft.world.entity.Mob>, registerMode: RegisterMode = RegisterMode.WORLD): KattonRegistry.KattonItemEntry

Registers a spawn egg item for an entity type independently (Identifier overload).