Class FabricDefaultAttributeRegistry

java.lang.Object
net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry

public final class FabricDefaultAttributeRegistry extends Object
Allows registering custom default attributes for living entities.

All living entity types must have default attributes registered. See EntityType.Builder for utility on entity type registration in general.

A registered default attribute for an entity type can be retrieved through DefaultAttributes.getSupplier(EntityType).

See Also:
  • DefaultAttributes
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    register(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity> type, net.minecraft.world.entity.ai.attributes.AttributeSupplier container)
    Registers a default attribute for a type of living entity.
    static void
    register(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity> type, net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder builder)
    Registers a default attribute for a type of living entity.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • register

      public static void register(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity> type, net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder builder)
      Registers a default attribute for a type of living entity.
      Parameters:
      type - the entity type
      builder - the builder that creates the default attribute
      See Also:
    • register

      public static void register(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity> type, net.minecraft.world.entity.ai.attributes.AttributeSupplier container)
      Registers a default attribute for a type of living entity.

      It can be used in a fashion similar to this:

      FabricDefaultAttributeRegistry.register(type, LivingEntity.createLivingAttributes());
      

      If a registration overrides another, a debug log message will be emitted. Existing registrations can be checked at DefaultAttributes.hasSupplier(EntityType).

      For convenience, this can also be done on the FabricEntityType.Builder to simplify the building process.

      Parameters:
      type - the entity type
      container - the container for the default attribute
      See Also: