Class TimeBasedHappinessModifier
java.lang.Object
com.minecolonies.api.entity.citizen.happiness.AbstractHappinessModifier
com.minecolonies.api.entity.citizen.happiness.TimeBasedHappinessModifier
- All Implemented Interfaces:
IHappinessModifier,ITimeBasedHappinessModifier
public final class TimeBasedHappinessModifier
extends AbstractHappinessModifier
implements ITimeBasedHappinessModifier
The time based happiness modifier. Over a time the buff/boost gets worse.
-
Field Summary
Fields inherited from class com.minecolonies.api.entity.citizen.happiness.AbstractHappinessModifier
id -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance of the happiness modifier.TimeBasedHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier, Tuple<Integer, Double>... timeBasedFactor) Create an instance of the happiness modifier.TimeBasedHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier, BiPredicate<TimeBasedHappinessModifier, ICitizenData> dayRollOverPredicate, Tuple<Integer, Double>... timeBasedFactor) 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 citizenData) Get the factor of the happiness.voidread(net.minecraft.nbt.CompoundTag compoundNBT, boolean persist) Read the modifier from nbt.voidreset()Reset the modifier.voidwrite(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
-
TimeBasedHappinessModifier
@SafeVarargs public TimeBasedHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier, Tuple<Integer, Double>... timeBasedFactor) Create an instance of the happiness modifier.- Parameters:
id- its string id.weight- its weight.supplier- the supplier to get the factor.timeBasedFactor- tuples about the boost/buff factor over time.
-
TimeBasedHappinessModifier
@SafeVarargs public TimeBasedHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier, BiPredicate<TimeBasedHappinessModifier, ICitizenData> dayRollOverPredicate, Tuple<Integer, Double>... timeBasedFactor) Create an instance of the happiness modifier.- Parameters:
id- its string id.weight- its weight.supplier- the supplier to get the factor.timeBasedFactor- tuples about the boost/buff factor over time.dayRollOverPredicate- a predicate to check whether the current day should roll over or reset.
-
TimeBasedHappinessModifier
public TimeBasedHappinessModifier()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:
citizenData- 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
-
getDays
public int getDays()Description copied from interface:ITimeBasedHappinessModifierGet the days this is active.- Specified by:
getDaysin interfaceITimeBasedHappinessModifier- Returns:
- the days.
-
dayEnd
Description copied from interface:ITimeBasedHappinessModifierCalled at the end of each day.- Specified by:
dayEndin interfaceITimeBasedHappinessModifier
-
read
public void read(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(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.
-