Class AbstractHappinessModifier
java.lang.Object
com.minecolonies.api.entity.citizen.happiness.AbstractHappinessModifier
- All Implemented Interfaces:
IHappinessModifier
- Direct Known Subclasses:
ExpirationBasedHappinessModifier,StaticHappinessModifier,TimeBasedHappinessModifier
Abstract happiness modifier implementation.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty instance of the abstract happiness modifier.AbstractHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier) Create an instance of the happiness modifier. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetFactor(@Nullable ICitizenData citizenData) Get the factor of the happiness.getId()Get the unique happiness id.doubleGet the weight of the happiness.voidread(net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Read the modifier from nbt.voidwrite(net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Write it to NBT.
-
Field Details
-
id
The id of the modifier.
-
-
Constructor Details
-
AbstractHappinessModifier
Create an instance of the happiness modifier.- Parameters:
id- its string id.weight- its weight.
-
AbstractHappinessModifier
public AbstractHappinessModifier()Create an empty instance of the abstract happiness modifier.
-
-
Method Details
-
getFactor
Description copied from interface:IHappinessModifierGet the factor of the happiness. value between 0 and 1 if negative. value above 1 if positive.- Specified by:
getFactorin interfaceIHappinessModifier- Parameters:
citizenData- the citizen the factor is for.- Returns:
- the value of the factor.
-
getId
Description copied from interface:IHappinessModifierGet the unique happiness id.- Specified by:
getIdin interfaceIHappinessModifier- Returns:
- the string id.
-
read
public void read(net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Description copied from interface:IHappinessModifierRead the modifier from nbt.- Specified by:
readin interfaceIHappinessModifier- Parameters:
compoundNBT- 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 compoundNBT, boolean persist) Description copied from interface:IHappinessModifierWrite it to NBT.- Specified by:
writein interfaceIHappinessModifier- Parameters:
compoundNBT- the compound to write it to.persist- whether we're reading from persisted data or from networking.
-
getWeight
public double getWeight()Description copied from interface:IHappinessModifierGet the weight of the happiness.- Specified by:
getWeightin interfaceIHappinessModifier- Returns:
- the weight.
-