Class CitizenHappinessHandler

java.lang.Object
com.minecolonies.core.entity.citizen.citizenhandlers.CitizenHappinessHandler
All Implemented Interfaces:
ICitizenHappinessHandler

public class CitizenHappinessHandler extends Object implements ICitizenHappinessHandler
The new happiness handler for the citizen.
  • Field Details

  • Constructor Details

    • CitizenHappinessHandler

      public CitizenHappinessHandler(ICitizenData data)
      Create a new instance of the citizen happiness handler.
      Parameters:
      data - the data to handle.
    • CitizenHappinessHandler

      public CitizenHappinessHandler()
      Create an empty happiness handler for the client side.
  • Method Details

    • addModifier

      public void addModifier(IHappinessModifier modifier)
      Description copied from interface: ICitizenHappinessHandler
      Add the modifier to the handler.
      Specified by:
      addModifier in interface ICitizenHappinessHandler
      Parameters:
      modifier - the modifier.
    • resetModifier

      public void resetModifier(String name)
      Description copied from interface: ICitizenHappinessHandler
      Reset a modifier.
      Specified by:
      resetModifier in interface ICitizenHappinessHandler
      Parameters:
      name - the name of the modifier.
    • getModifier

      public IHappinessModifier getModifier(String name)
      Description copied from interface: ICitizenHappinessHandler
      Get a modifier by the name.
      Specified by:
      getModifier in interface ICitizenHappinessHandler
      Parameters:
      name - the name of the modifier to return.
      Returns:
      the modifier.
    • processDailyHappiness

      public void processDailyHappiness(ICitizenData citizenData)
      Description copied from interface: ICitizenHappinessHandler
      Process the happiness factors daily.
      Specified by:
      processDailyHappiness in interface ICitizenHappinessHandler
      Parameters:
      citizenData - the citizen to process it for.
    • getHappiness

      public double getHappiness(IColony colony, ICitizenData citizenData)
      Description copied from interface: ICitizenHappinessHandler
      Get the computed happiness of the citizen.
      Specified by:
      getHappiness in interface ICitizenHappinessHandler
      Parameters:
      colony - the colony.
      Returns:
      the happiness.
    • read

      public void read(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound, boolean persist)
      Description copied from interface: ICitizenHappinessHandler
      Read the handler from NBT.
      Specified by:
      read in interface ICitizenHappinessHandler
      Parameters:
      compound - 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 compound, boolean persist)
      Description copied from interface: ICitizenHappinessHandler
      Write the handler to NBT.
      Specified by:
      write in interface ICitizenHappinessHandler
      Parameters:
      compound - the compound to write it to.
      persist - whether we're reading from persisted data or from networking.
    • getModifiers

      public List<String> getModifiers()
      Description copied from interface: ICitizenHappinessHandler
      Get a list of all modifiers.
      Specified by:
      getModifiers in interface ICitizenHappinessHandler
      Returns:
      the list.
    • getSocialModifier

      public static double getSocialModifier(IColony colony)
      Get the social modifier for the colony.
      Parameters:
      colony - the colony.
      Returns:
      the factor.
    • getGuardFactor

      public static double getGuardFactor(IColony colony)
      Get the guard security happiness modifier from the colony.
      Parameters:
      colony - the colony.
      Returns:
      the factor.
    • getFoodFactor

      public static double getFoodFactor(ICitizenData citizenData)
      Get the food happiness modifier from the citizen. Mininmal Happiness: 1: 1 Different types of food, e.g. baked potato 2: 2 Types of food baked potato + mushroom soup 3: 3 Types food baked potato + mushroom soup + 1 Minecolonies food 4: 4 Types food baked potato + mushroom soup + 2 Minecolonies food 5: 5 Types food baked potato + mushroom soup + 3 Minecolonies food
      Parameters:
      citizenData - the citizen.
      Returns:
      the factor.
    • getMysticalSiteFactor

      public static double getMysticalSiteFactor(IColony colony)
      Get the mystical site happiness modifier from the colony. Mystical site happiness is never negative : Supply vary from 1 to 3.5 max (1 + (Mystical site lvl 5 / 2))
      Parameters:
      colony - the colony.
      Returns:
      the factor.