Class AbstractHappinessModifier

java.lang.Object
com.minecolonies.api.entity.citizen.happiness.AbstractHappinessModifier
All Implemented Interfaces:
IHappinessModifier
Direct Known Subclasses:
ExpirationBasedHappinessModifier, StaticHappinessModifier, TimeBasedHappinessModifier

public abstract class AbstractHappinessModifier extends Object implements IHappinessModifier
Abstract happiness modifier implementation.
  • Field Details

    • id

      public String id
      The id of the modifier.
  • Constructor Details

    • AbstractHappinessModifier

      public AbstractHappinessModifier(String id, double weight, IHappinessSupplierWrapper supplier)
      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

      public double getFactor(@Nullable @Nullable ICitizenData citizenData)
      Description copied from interface: IHappinessModifier
      Get the factor of the happiness. value between 0 and 1 if negative. value above 1 if positive.
      Specified by:
      getFactor in interface IHappinessModifier
      Parameters:
      citizenData - the citizen the factor is for.
      Returns:
      the value of the factor.
    • getId

      public String getId()
      Description copied from interface: IHappinessModifier
      Get the unique happiness id.
      Specified by:
      getId in interface IHappinessModifier
      Returns:
      the string id.
    • read

      public void read(net.minecraft.nbt.CompoundTag compoundNBT, boolean persist)
      Description copied from interface: IHappinessModifier
      Read the modifier from nbt.
      Specified by:
      read in interface IHappinessModifier
      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: IHappinessModifier
      Write it to NBT.
      Specified by:
      write in interface IHappinessModifier
      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: IHappinessModifier
      Get the weight of the happiness.
      Specified by:
      getWeight in interface IHappinessModifier
      Returns:
      the weight.