Class AnimalColonyHandler

java.lang.Object
com.minecolonies.core.entity.mobs.AnimalColonyHandler
All Implemented Interfaces:
IAnimalColonyHandler

public class AnimalColonyHandler extends Object implements IAnimalColonyHandler
Handles all colony orchestration for this managed animal.
  • Field Details

    • registered

      protected boolean registered
      Whether the entity is registered to the colony yet.
    • colony

      @Nullable protected @Nullable IColony colony
      The colony reference.
    • colonyId

      protected int colonyId
      The id of the colony.
    • animal

      protected final IManagedAnimal<? extends net.minecraft.world.entity.Entity> animal
      The animal assigned to this manager.
  • Constructor Details

    • AnimalColonyHandler

      public AnimalColonyHandler(IManagedAnimal<? extends net.minecraft.world.entity.Entity> managedAnimal)
  • Method Details

    • registerWithColony

      public void registerWithColony(int registeringToColony, int animalID)
      Registers the managed animal with the colony. If the animal ID is 0 or the colony ID is 0, the animal is removed from the world. If the colony is not found, the animal is removed from the world and a warn message is logged.
      Specified by:
      registerWithColony in interface IAnimalColonyHandler
      Parameters:
      colonyID - the id of the colony.
      animalID - the id of the animal.
    • getColony

      @Nullable public @Nullable IColony getColony()
      Gets the colony reference of the managed animal. May return null if the managed animal is not registered to the colony yet.
      Specified by:
      getColony in interface IAnimalColonyHandler
      Returns:
      the colony reference.
    • getColonyId

      public int getColonyId()
      Getter for the colony id.
      Specified by:
      getColonyId in interface IAnimalColonyHandler
      Returns:
      the colony id.
    • setColonyId

      public void setColonyId(int colonyId)
      Setter for the colony id.
      Specified by:
      setColonyId in interface IAnimalColonyHandler
      Parameters:
      colonyId - the new colonyId.
    • updateColonyClient

      public void updateColonyClient()
      Update the client side of the citizen entity.
      Specified by:
      updateColonyClient in interface IAnimalColonyHandler
    • onSyncedDataUpdated

      public void onSyncedDataUpdated(net.minecraft.network.syncher.EntityDataAccessor<?> data)
      Called when the entity's data is updated from the server. If the entity data accessor is the animal id accessor or the colony id accessor, it sets the needs client update flag to true.
      Specified by:
      onSyncedDataUpdated in interface IAnimalColonyHandler
      Parameters:
      data - The data accessor which contains the updated data.