Class ExpirationBasedHappinessModifier
java.lang.Object
com.minecolonies.api.entity.citizen.happiness.AbstractHappinessModifier
com.minecolonies.api.entity.citizen.happiness.ExpirationBasedHappinessModifier
- All Implemented Interfaces:
IHappinessModifier,ITimeBasedHappinessModifier
public final class ExpirationBasedHappinessModifier
extends AbstractHappinessModifier
implements ITimeBasedHappinessModifier
The Expiration based happiness modifier. These modifiers are invoked for a limited period of time and have a happiness buff or boost for this time on the happiness. This can
also be inverted resulting in a buff or boost if this modifier is not invoked regularly.
-
Field Summary
Fields inherited from class com.minecolonies.api.entity.citizen.happiness.AbstractHappinessModifier
id -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance of the happiness modifier.ExpirationBasedHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier, int period) Create an instance of the happiness modifier. -
Method Summary
Modifier and TypeMethodDescriptionvoiddayEnd(ICitizenData data) Called at the end of each day.intgetDays()Get the days this is active.doublegetFactor(ICitizenData data) Get the factor of the happiness.voidread(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Read the modifier from nbt.voidreset()Reset the modifier.voidwrite(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Write it to NBT.Methods inherited from class com.minecolonies.api.entity.citizen.happiness.AbstractHappinessModifier
getId, getWeightMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.entity.citizen.happiness.IHappinessModifier
getId, getWeight
-
Constructor Details
-
ExpirationBasedHappinessModifier
public ExpirationBasedHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier, int period) Create an instance of the happiness modifier.- Parameters:
id- its string id.weight- its weight.supplier- the supplier to get the factor.period- the period.
-
ExpirationBasedHappinessModifier
public ExpirationBasedHappinessModifier()Create an instance of the 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- Overrides:
getFactorin classAbstractHappinessModifier- Parameters:
data- the citizen the factor is for.- Returns:
- the value of the factor.
-
reset
public void reset()Description copied from interface:ITimeBasedHappinessModifierReset the modifier.- Specified by:
resetin interfaceITimeBasedHappinessModifier
-
dayEnd
Description copied from interface:ITimeBasedHappinessModifierCalled at the end of each day.- Specified by:
dayEndin interfaceITimeBasedHappinessModifier
-
getDays
public int getDays()Description copied from interface:ITimeBasedHappinessModifierGet the days this is active.- Specified by:
getDaysin interfaceITimeBasedHappinessModifier- Returns:
- the days.
-
read
public void read(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Description copied from interface:IHappinessModifierRead the modifier from nbt.- Specified by:
readin interfaceIHappinessModifier- Overrides:
readin classAbstractHappinessModifier- Parameters:
compoundNBT- the compound to read it from.persist- whether we're reading from persisted data or from networking.
-
write
public void write(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Description copied from interface:IHappinessModifierWrite it to NBT.- Specified by:
writein interfaceIHappinessModifier- Overrides:
writein classAbstractHappinessModifier- Parameters:
compoundNBT- the compound to write it to.persist- whether we're reading from persisted data or from networking.
-