Class CitizenHappinessHandler
java.lang.Object
com.minecolonies.core.entity.citizen.citizenhandlers.CitizenHappinessHandler
- All Implemented Interfaces:
ICitizenHappinessHandler
The new happiness handler for the citizen.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe different happiness factor. -
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty happiness handler for the client side.Create a new instance of the citizen happiness handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModifier(IHappinessModifier modifier) Add the modifier to the handler.static doublegetFoodFactor(ICitizenData citizenData) Get the food happiness modifier from the citizen.static doublegetGuardFactor(IColony colony) Get the guard security happiness modifier from the colony.doublegetHappiness(IColony colony, ICitizenData citizenData) Get the computed happiness of the citizen.getModifier(String name) Get a modifier by the name.Get a list of all modifiers.static doublegetMysticalSiteFactor(IColony colony) Get the mystical site happiness modifier from the colony.static doublegetSocialModifier(IColony colony) Get the social modifier for the colony.voidprocessDailyHappiness(ICitizenData citizenData) Process the happiness factors daily.voidread(net.minecraft.nbt.CompoundTag compound, boolean persist) Read the handler from NBT.voidresetModifier(String name) Reset a modifier.voidwrite(net.minecraft.nbt.CompoundTag compound, boolean persist) Write the handler to NBT.
-
Field Details
-
happinessFactors
The different happiness factor.
-
-
Constructor Details
-
CitizenHappinessHandler
Create a new instance of the citizen happiness handler.- Parameters:
data- the data to handle.
-
CitizenHappinessHandler
public CitizenHappinessHandler()Create an empty happiness handler for the client side.
-
-
Method Details
-
addModifier
Description copied from interface:ICitizenHappinessHandlerAdd the modifier to the handler.- Specified by:
addModifierin interfaceICitizenHappinessHandler- Parameters:
modifier- the modifier.
-
resetModifier
Description copied from interface:ICitizenHappinessHandlerReset a modifier.- Specified by:
resetModifierin interfaceICitizenHappinessHandler- Parameters:
name- the name of the modifier.
-
getModifier
Description copied from interface:ICitizenHappinessHandlerGet a modifier by the name.- Specified by:
getModifierin interfaceICitizenHappinessHandler- Parameters:
name- the name of the modifier to return.- Returns:
- the modifier.
-
processDailyHappiness
Description copied from interface:ICitizenHappinessHandlerProcess the happiness factors daily.- Specified by:
processDailyHappinessin interfaceICitizenHappinessHandler- Parameters:
citizenData- the citizen to process it for.
-
getHappiness
Description copied from interface:ICitizenHappinessHandlerGet the computed happiness of the citizen.- Specified by:
getHappinessin interfaceICitizenHappinessHandler- Parameters:
colony- the colony.- Returns:
- the happiness.
-
read
public void read(net.minecraft.nbt.CompoundTag compound, boolean persist) Description copied from interface:ICitizenHappinessHandlerRead the handler from NBT.- Specified by:
readin interfaceICitizenHappinessHandler- Parameters:
compound- the compound to read it from.persist- whether we're reading from persisted data or from networking.
-
write
public void write(net.minecraft.nbt.CompoundTag compound, boolean persist) Description copied from interface:ICitizenHappinessHandlerWrite the handler to NBT.- Specified by:
writein interfaceICitizenHappinessHandler- Parameters:
compound- the compound to write it to.persist- whether we're reading from persisted data or from networking.
-
getModifiers
Description copied from interface:ICitizenHappinessHandlerGet a list of all modifiers.- Specified by:
getModifiersin interfaceICitizenHappinessHandler- Returns:
- the list.
-
getSocialModifier
Get the social modifier for the colony.- Parameters:
colony- the colony.- Returns:
- the factor.
-
getGuardFactor
Get the guard security happiness modifier from the colony.- Parameters:
colony- the colony.- Returns:
- the factor.
-
getFoodFactor
Get the food happiness modifier from the citizen. Mininmal Happiness: 1: 1 Different types of food, e.g. baked potato 2: 2 Types of food baked potato + mushroom soup 3: 3 Types food baked potato + mushroom soup + 1 Minecolonies food 4: 4 Types food baked potato + mushroom soup + 2 Minecolonies food 5: 5 Types food baked potato + mushroom soup + 3 Minecolonies food- Parameters:
citizenData- the citizen.- Returns:
- the factor.
-
getMysticalSiteFactor
Get the mystical site happiness modifier from the colony. Mystical site happiness is never negative : Supply vary from 1 to 3.5 max (1 + (Mystical site lvl 5 / 2))- Parameters:
colony- the colony.- Returns:
- the factor.
-