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 Summary

    Fields
    Modifier and Type
    Field
    Description
    The id of the modifier.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an empty instance of the abstract happiness modifier.
    Create an instance of the happiness modifier.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getFactor(@Nullable ICitizenData citizenData)
    Get the factor of the happiness.
    Get the unique happiness id.
    double
    Get the weight of the happiness.
    void
    read(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compoundNBT, boolean persist)
    Read the modifier from nbt.
    void
    write(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compoundNBT, boolean persist)
    Write it to NBT.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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(@NotNull net.minecraft.core.HolderLookup.Provider provider, 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(@NotNull net.minecraft.core.HolderLookup.Provider provider, 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.