Class AnimalColonyHandler
java.lang.Object
com.minecolonies.core.entity.mobs.AnimalColonyHandler
- All Implemented Interfaces:
IAnimalColonyHandler
Handles all colony orchestration for this managed animal.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final IManagedAnimal<? extends net.minecraft.world.entity.Entity>The animal assigned to this manager.protected @Nullable IColonyThe colony reference.protected intThe id of the colony.protected booleanWhether the entity is registered to the colony yet. -
Constructor Summary
ConstructorsConstructorDescriptionAnimalColonyHandler(IManagedAnimal<? extends net.minecraft.world.entity.Entity> managedAnimal) -
Method Summary
Modifier and TypeMethodDescription@Nullable IColonyGets the colony reference of the managed animal.intGetter for the colony id.voidonSyncedDataUpdated(net.minecraft.network.syncher.EntityDataAccessor<?> data) Called when the entity's data is updated from the server.voidregisterWithColony(int registeringToColony, int animalID) Registers the managed animal with the colony.voidsetColonyId(int colonyId) Setter for the colony id.voidUpdate the client side of the citizen entity.
-
Field Details
-
registered
protected boolean registeredWhether the entity is registered to the colony yet. -
colony
The colony reference. -
colonyId
protected int colonyIdThe id of the colony. -
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:
registerWithColonyin interfaceIAnimalColonyHandler- Parameters:
colonyID- the id of the colony.animalID- the id of the animal.
-
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:
getColonyin interfaceIAnimalColonyHandler- Returns:
- the colony reference.
-
getColonyId
public int getColonyId()Getter for the colony id.- Specified by:
getColonyIdin interfaceIAnimalColonyHandler- Returns:
- the colony id.
-
setColonyId
public void setColonyId(int colonyId) Setter for the colony id.- Specified by:
setColonyIdin interfaceIAnimalColonyHandler- Parameters:
colonyId- the new colonyId.
-
updateColonyClient
public void updateColonyClient()Update the client side of the citizen entity.- Specified by:
updateColonyClientin interfaceIAnimalColonyHandler
-
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:
onSyncedDataUpdatedin interfaceIAnimalColonyHandler- Parameters:
data- The data accessor which contains the updated data.
-