Interface IAnimalData

All Superinterfaces:
net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
All Known Implementing Classes:
AnimalData

public interface IAnimalData extends net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
Data interface for animals managed by the Animal Manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the dirty flag for this animal data.
    float
    Returns the current combat cooldown of the animal.
    Gets the home building of the animal.
    int
    Get the animal data ID.
    @NotNull net.minecraft.core.BlockPos
    Gets the last position of the animal.
    Optional<IManagedAnimal<? extends net.minecraft.world.entity.animal.Animal>>
    Get the animal entity.
    Gets the owner of the animal.
    Get the globally unique identifier associated with this animal data.
    void
    Initializes the entities values from animal data.
    boolean
    Check if this animal data is dirty and needs syncing.
    void
    Mark this animal data as dirty and in need of syncing / saving.
    void
    Called when a building is removed.
    void
    serializeViewNetworkData(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
    Writes the animal data to a byte buf for transition.
    void
    setCombatCooldown(float newCooldown)
    Sets the combat cooldown of the animal.
    void
    setHomeBuilding(@NotNull IBuilding building)
    Sets the home building of the animal.
    void
    setLastPosition(net.minecraft.core.BlockPos lastPosition)
    Sets the last position of the animal.
    void
    setManagedAnimal(IManagedAnimal<? extends net.minecraft.world.entity.animal.Animal> entity)
    Set the animal entity.
    void
    setOwner(UUID owner)
    Sets the owner of the animal.
    void
    update(int tickRate)
    Update the animal data.

    Methods inherited from interface net.neoforged.neoforge.common.util.INBTSerializable

    deserializeNBT, serializeNBT
  • Method Details

    • getId

      int getId()
      Get the animal data ID.
      Returns:
      the animal data ID
    • getUUID

      UUID getUUID()
      Get the globally unique identifier associated with this animal data.
      Returns:
      the globally unique identifier associated with this animal data.
    • initEntityValues

      void initEntityValues()
      Initializes the entities values from animal data.
    • getManagedAnimal

      Optional<IManagedAnimal<? extends net.minecraft.world.entity.animal.Animal>> getManagedAnimal()
      Get the animal entity.
      Returns:
      the animal entity.
    • setManagedAnimal

      void setManagedAnimal(IManagedAnimal<? extends net.minecraft.world.entity.animal.Animal> entity)
      Set the animal entity.
      Parameters:
      entity - the animal entity.
    • clearDirty

      void clearDirty()
      Clear the dirty flag for this animal data.
    • isDirty

      boolean isDirty()
      Check if this animal data is dirty and needs syncing.
      Returns:
      true if dirty, false otherwise
    • markDirty

      void markDirty()
      Mark this animal data as dirty and in need of syncing / saving.
    • update

      void update(int tickRate)
      Update the animal data.
      Parameters:
      tickRate - the tick rate
    • serializeViewNetworkData

      void serializeViewNetworkData(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
      Writes the animal data to a byte buf for transition.
      Parameters:
      buf - Buffer to write to.
    • getHomeBuilding

      IBuilding getHomeBuilding()
      Gets the home building of the animal.
      Returns:
      the home building, or null if the animal does not have a home building.
    • setHomeBuilding

      void setHomeBuilding(@NotNull @NotNull IBuilding building)
      Sets the home building of the animal.
      Parameters:
      building - the new home building of the animal.
    • onRemoveBuilding

      void onRemoveBuilding(IBuilding building)
      Called when a building is removed.
      Parameters:
      building - the building that was removed.
    • setLastPosition

      void setLastPosition(net.minecraft.core.BlockPos lastPosition)
      Sets the last position of the animal.
      Parameters:
      lastPosition - the last position of the animal.
    • getLastPosition

      @NotNull @NotNull net.minecraft.core.BlockPos getLastPosition()
      Gets the last position of the animal.
      Returns:
      the last position of the animal.
    • getCombatCooldown

      float getCombatCooldown()
      Returns the current combat cooldown of the animal. A higher value means the animal is currently less ready for combat.
      Returns:
      the current combat cooldown of the animal
    • setCombatCooldown

      void setCombatCooldown(float newCooldown)
      Sets the combat cooldown of the animal.
      Parameters:
      newCooldown - the new combat cooldown of the animal
    • getOwner

      UUID getOwner()
      Gets the owner of the animal.
      Returns:
      the owner of the animal
    • setOwner

      void setOwner(UUID owner)
      Sets the owner of the animal.
      Parameters:
      owner - the new owner of the animal