From 12dcf26991ae029f72cee1e11a19c219b55f6d06 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 15 Sep 2024 15:05:27 +0200 Subject: [PATCH] Fix time based happiness working as expected (#10197) Fix time based happiness working as expected [1.21] --- .../ICitizenHappinessHandler.java | 6 +- .../happiness/AbstractHappinessModifier.java | 4 +- .../ExpirationBasedHappinessModifier.java | 48 ++---------- .../citizen/happiness/HappinessRegistry.java | 5 +- .../citizen/happiness/IHappinessModifier.java | 6 +- .../happiness/StaticHappinessModifier.java | 4 +- .../happiness/TimeBasedHappinessModifier.java | 78 +++++++++++++------ .../api/util/constant/NbtTagConstants.java | 1 - .../ModHappinessFactorTypeInitializer.java | 4 +- .../minecolonies/core/colony/CitizenData.java | 6 +- .../core/colony/CitizenDataView.java | 2 +- .../CitizenHappinessHandler.java | 14 ++-- 12 files changed, 92 insertions(+), 86 deletions(-) diff --git a/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenHappinessHandler.java b/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenHappinessHandler.java index 04dca8bf710..772306924d3 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenHappinessHandler.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenHappinessHandler.java @@ -55,15 +55,17 @@ public interface ICitizenHappinessHandler * Read the handler from NBT. * * @param compound the compound to read it from. + * @param persist whether we're reading from persisted data or from networking. */ - void read(@NotNull final HolderLookup.Provider provider, CompoundTag compound); + void read(@NotNull final HolderLookup.Provider provider, CompoundTag compound, final boolean persist); /** * Write the handler to NBT. * * @param compound the compound to write it to. + * @param persist whether we're reading from persisted data or from networking. */ - void write(@NotNull final HolderLookup.Provider provider, CompoundTag compound); + void write(@NotNull final HolderLookup.Provider provider, CompoundTag compound, final boolean persist); /** * Get a list of all modifiers. diff --git a/src/main/java/com/minecolonies/api/entity/citizen/happiness/AbstractHappinessModifier.java b/src/main/java/com/minecolonies/api/entity/citizen/happiness/AbstractHappinessModifier.java index b6f3a4028ed..b9c0cb4f338 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/happiness/AbstractHappinessModifier.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/happiness/AbstractHappinessModifier.java @@ -62,7 +62,7 @@ public String getId() } @Override - public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT) + public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist) { this.id = compoundNBT.getString(TAG_ID); this.weight = compoundNBT.getDouble(TAG_WEIGHT); @@ -79,7 +79,7 @@ public void read(@NotNull final HolderLookup.Provider provider, final CompoundTa } @Override - public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT) + public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist) { compoundNBT.putString(TAG_ID, this.id); compoundNBT.putDouble(TAG_WEIGHT, this.weight); diff --git a/src/main/java/com/minecolonies/api/entity/citizen/happiness/ExpirationBasedHappinessModifier.java b/src/main/java/com/minecolonies/api/entity/citizen/happiness/ExpirationBasedHappinessModifier.java index 48d72ebf87c..88532c8a570 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/happiness/ExpirationBasedHappinessModifier.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/happiness/ExpirationBasedHappinessModifier.java @@ -17,18 +17,13 @@ public final class ExpirationBasedHappinessModifier extends AbstractHappinessMod /** * The number of passed days. */ - private int days = 0; + private int days; /** * Period of time this modifier applies. */ private int period; - /** - * If this should give a penalty if not active. - */ - private boolean inverted; - /** * Create an instance of the happiness modifier. * @@ -40,24 +35,10 @@ public final class ExpirationBasedHappinessModifier extends AbstractHappinessMod public ExpirationBasedHappinessModifier(final String id, final double weight, final IHappinessSupplierWrapper supplier, final int period) { super(id, weight, supplier); + this.days = period; this.period = period; } - /** - * Create an instance of the happiness modifier. - * - * @param id its string id. - * @param weight its weight. - * @param period the period. - * @param supplier the supplier to get the factor. - * @param inverted if inverted. - */ - public ExpirationBasedHappinessModifier(final String id, final double weight, final IHappinessSupplierWrapper supplier, final int period, final boolean inverted) - { - this(id, weight, supplier, period); - this.inverted = inverted; - } - /** * Create an instance of the happiness modifier. */ @@ -69,22 +50,11 @@ public ExpirationBasedHappinessModifier() @Override public double getFactor(final ICitizenData data) { - if (inverted) + if (days > 0 && days <= period) { - if (days <= period) - { - return 1.0; - } return super.getFactor(data); } - else - { - if (days < period) - { - return super.getFactor(data); - } - return 1.0; - } + return 1.0; } @Override @@ -109,21 +79,19 @@ public int getDays() } @Override - public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT) + public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist) { - super.read(provider, compoundNBT); + super.read(provider, compoundNBT, persist); this.days = compoundNBT.getInt(TAG_DAY); - this.inverted = compoundNBT.getBoolean(TAG_INVERTED); this.period = compoundNBT.getInt(TAG_PERIOD); } @Override - public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT) + public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist) { - super.write(provider, compoundNBT); + super.write(provider, compoundNBT, persist); compoundNBT.putString(NbtTagConstants.TAG_MODIFIER_TYPE, HappinessRegistry.EXPIRATION_MODIFIER.toString()); compoundNBT.putInt(TAG_DAY, days); - compoundNBT.putBoolean(TAG_INVERTED, inverted); compoundNBT.putInt(TAG_PERIOD, period); } } diff --git a/src/main/java/com/minecolonies/api/entity/citizen/happiness/HappinessRegistry.java b/src/main/java/com/minecolonies/api/entity/citizen/happiness/HappinessRegistry.java index 974cb1d2f22..9775e465443 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/happiness/HappinessRegistry.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/happiness/HappinessRegistry.java @@ -67,9 +67,10 @@ public IHappinessModifier create() * Static getter to load a happiness modifier from a compound. * * @param compound the compound to load it from. + * @param persist whether we're reading from persisted data or from networking. * @return the modifier instance. */ - public static IHappinessModifier loadFrom(@NotNull final HolderLookup.Provider provider, @NotNull final CompoundTag compound) + public static IHappinessModifier loadFrom(@NotNull final HolderLookup.Provider provider, @NotNull final CompoundTag compound, final boolean persist) { final ResourceLocation modifierType = compound.contains(NbtTagConstants.TAG_MODIFIER_TYPE) ? ResourceLocation.parse(compound.getString(NbtTagConstants.TAG_MODIFIER_TYPE)) @@ -80,7 +81,7 @@ public static IHappinessModifier loadFrom(@NotNull final HolderLookup.Provider p { try { - modifier.read(provider, compound); + modifier.read(provider, compound, persist); } catch (final RuntimeException ex) { diff --git a/src/main/java/com/minecolonies/api/entity/citizen/happiness/IHappinessModifier.java b/src/main/java/com/minecolonies/api/entity/citizen/happiness/IHappinessModifier.java index f9dc6f875da..12a1c5592c7 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/happiness/IHappinessModifier.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/happiness/IHappinessModifier.java @@ -36,13 +36,15 @@ public interface IHappinessModifier * Read the modifier from nbt. * * @param compoundNBT the compound to read it from. + * @param persist whether we're reading from persisted data or from networking. */ - void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT); + void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist); /** * Write it to NBT. * * @param compoundNBT the compound to write it to. + * @param persist whether we're reading from persisted data or from networking. */ - void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT); + void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist); } diff --git a/src/main/java/com/minecolonies/api/entity/citizen/happiness/StaticHappinessModifier.java b/src/main/java/com/minecolonies/api/entity/citizen/happiness/StaticHappinessModifier.java index 75fea101c41..e7f0c804bdc 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/happiness/StaticHappinessModifier.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/happiness/StaticHappinessModifier.java @@ -31,9 +31,9 @@ public StaticHappinessModifier() } @Override - public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT) + public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist) { - super.write(provider, compoundNBT); + super.write(provider, compoundNBT, persist); compoundNBT.putString(NbtTagConstants.TAG_MODIFIER_TYPE, HappinessRegistry.STATIC_MODIFIER.toString()); } } diff --git a/src/main/java/com/minecolonies/api/entity/citizen/happiness/TimeBasedHappinessModifier.java b/src/main/java/com/minecolonies/api/entity/citizen/happiness/TimeBasedHappinessModifier.java index 53d0c9f2e37..19a25c2db1e 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/happiness/TimeBasedHappinessModifier.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/happiness/TimeBasedHappinessModifier.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.BiPredicate; import static com.minecolonies.api.util.constant.NbtTagConstants.*; @@ -19,10 +20,15 @@ */ public final class TimeBasedHappinessModifier extends AbstractHappinessModifier implements ITimeBasedHappinessModifier { + /** + * A predicate to check whether the current day should roll over or reset. + */ + private BiPredicate dayRollOverPredicate; + /** * The time based factors. */ - private Tuple[] timeBasedFactor; + private List> timeBasedFactor = new ArrayList<>(); /** * The number of passed days. @@ -37,10 +43,32 @@ public final class TimeBasedHappinessModifier extends AbstractHappinessModifier * @param supplier the supplier to get the factor. * @param timeBasedFactor tuples about the boost/buff factor over time. */ - public TimeBasedHappinessModifier(final String id, final double weight, final IHappinessSupplierWrapper supplier, final Tuple...timeBasedFactor) + @SafeVarargs + public TimeBasedHappinessModifier(final String id, final double weight, final IHappinessSupplierWrapper supplier, final Tuple... timeBasedFactor) + { + this(id, weight, supplier, (modifier, data) -> modifier.getFactor(data) < 1, timeBasedFactor); + } + + /** + * Create an instance of the happiness modifier. + * + * @param id its string id. + * @param weight its weight. + * @param supplier the supplier to get the factor. + * @param timeBasedFactor tuples about the boost/buff factor over time. + * @param dayRollOverPredicate a predicate to check whether the current day should roll over or reset. + */ + @SafeVarargs + public TimeBasedHappinessModifier( + final String id, + final double weight, + final IHappinessSupplierWrapper supplier, + final BiPredicate dayRollOverPredicate, + final Tuple... timeBasedFactor) { super(id, weight, supplier); - this.timeBasedFactor = timeBasedFactor; + this.dayRollOverPredicate = dayRollOverPredicate; + this.timeBasedFactor = List.of(timeBasedFactor); } /** @@ -61,7 +89,7 @@ public double getFactor(final ICitizenData citizenData) { for (final Tuple tuple : timeBasedFactor) { - if (this.days > tuple.getA()) + if (this.days >= tuple.getA()) { factor = baseFactor * tuple.getB(); } @@ -85,7 +113,7 @@ public int getDays() @Override public void dayEnd(final ICitizenData data) { - if (getFactor(data) < 1) + if (dayRollOverPredicate.test(this, data)) { days++; } @@ -96,34 +124,40 @@ public void dayEnd(final ICitizenData data) } @Override - public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT) + public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist) { - super.read(provider, compoundNBT); + super.read(provider, compoundNBT, persist); this.days = compoundNBT.getInt(TAG_DAY); - final ListTag listTag = compoundNBT.getList(TAG_LIST, Constants.TAG_COMPOUND); - final List> list = new ArrayList<>(); - for (int i = 0; i < listTag.size(); i++) + if (!persist) { - final CompoundTag entryTag = listTag.getCompound(i); - list.add(new Tuple<>(entryTag.getInt(TAG_DAY), entryTag.getDouble(TAG_VALUE))); + final ListTag listTag = compoundNBT.getList(TAG_LIST, Constants.TAG_COMPOUND); + final List> list = new ArrayList<>(); + for (int i = 0; i < listTag.size(); i++) + { + final CompoundTag entryTag = listTag.getCompound(i); + list.add(new Tuple<>(entryTag.getInt(TAG_DAY), entryTag.getDouble(TAG_VALUE))); + } + this.timeBasedFactor = list; } - this.timeBasedFactor = list.toArray(new Tuple[0]); } @Override - public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT) + public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compoundNBT, final boolean persist) { - super.write(provider, compoundNBT); + super.write(provider, compoundNBT, persist); compoundNBT.putString(NbtTagConstants.TAG_MODIFIER_TYPE, HappinessRegistry.TIME_PERIOD_MODIFIER.toString()); - compoundNBT.putInt(TAG_DAY, days); - final ListTag listTag = new ListTag(); - for (final Tuple entry : timeBasedFactor) + if (!persist) { - final CompoundTag listEntry = new CompoundTag(); - listEntry.putInt(TAG_DAY, entry.getA()); - listEntry.putDouble(TAG_VALUE, entry.getB()); + final ListTag listTag = new ListTag(); + for (final Tuple entry : timeBasedFactor) + { + final CompoundTag listEntry = new CompoundTag(); + listEntry.putInt(TAG_DAY, entry.getA()); + listEntry.putDouble(TAG_VALUE, entry.getB()); + listTag.add(listEntry); + } + compoundNBT.put(TAG_LIST, listTag); } - compoundNBT.put(TAG_LIST, listTag); } } diff --git a/src/main/java/com/minecolonies/api/util/constant/NbtTagConstants.java b/src/main/java/com/minecolonies/api/util/constant/NbtTagConstants.java index b42194a55b5..fc9adbedb62 100755 --- a/src/main/java/com/minecolonies/api/util/constant/NbtTagConstants.java +++ b/src/main/java/com/minecolonies/api/util/constant/NbtTagConstants.java @@ -65,7 +65,6 @@ public final class NbtTagConstants public static final String TAG_OFFHAND_HELD_ITEM_SLOT = "OffhandHeldItemSlot"; public static final String TAG_STATUS = "status"; public static final String TAG_DAY = "day"; - public static final String TAG_INVERTED = "inverted"; public static final String TAG_PERIOD = "period"; public static final String TAG_IS_BUILT = "isBuilt"; public static final String TAG_CUSTOM_NAME = "customName"; diff --git a/src/main/java/com/minecolonies/apiimp/initializer/ModHappinessFactorTypeInitializer.java b/src/main/java/com/minecolonies/apiimp/initializer/ModHappinessFactorTypeInitializer.java index d19ab600eb7..e41b7583399 100755 --- a/src/main/java/com/minecolonies/apiimp/initializer/ModHappinessFactorTypeInitializer.java +++ b/src/main/java/com/minecolonies/apiimp/initializer/ModHappinessFactorTypeInitializer.java @@ -47,7 +47,7 @@ private ModHappinessFactorTypeInitializer() HappinessRegistry.healthFunction = DEFERRED_REGISTER_HAPPINESS_FUNCTION.register(HEALTH_FUNCTION.getPath(), () -> new HappinessFunctionEntry(data -> data.getEntity().isPresent() ? (data.getEntity().get().getCitizenDiseaseHandler().isSick() ? 0.5 : 1.0) : 1.0)); HappinessRegistry.idleatjobFunction = DEFERRED_REGISTER_HAPPINESS_FUNCTION.register(IDLEATJOB_FUNCTION.getPath(), () -> new HappinessFunctionEntry(data -> data.isIdleAtJob() ? 0.5 : 1.0)); - HappinessRegistry.sleptTonightFunction = DEFERRED_REGISTER_HAPPINESS_FUNCTION.register(SLEPTTONIGHT_FUNCTION.getPath(), () -> new HappinessFunctionEntry(data -> data.getJob() instanceof AbstractJobGuard ? 1 : 0.0)); - HappinessRegistry.foodFunction = DEFERRED_REGISTER_HAPPINESS_FUNCTION.register(FOOD_FUNCTION.getPath(), () -> new HappinessFunctionEntry(data -> (data.getHomeBuilding() == null || data.getHomeBuilding().getBuildingLevel() <= 2) ? 0.0 : data.getHomeBuilding().getBuildingLevel() - 2.0)); + HappinessRegistry.sleptTonightFunction = DEFERRED_REGISTER_HAPPINESS_FUNCTION.register(SLEPTTONIGHT_FUNCTION.getPath(), () -> new HappinessFunctionEntry(data -> data.getJob() instanceof AbstractJobGuard ? 1 : 0.5)); + HappinessRegistry.foodFunction = DEFERRED_REGISTER_HAPPINESS_FUNCTION.register(FOOD_FUNCTION.getPath(), () -> new HappinessFunctionEntry(data -> (data.getHomeBuilding() == null || data.getHomeBuilding().getBuildingLevel() <= 2) ? 1 : 0.5)); } } diff --git a/src/main/java/com/minecolonies/core/colony/CitizenData.java b/src/main/java/com/minecolonies/core/colony/CitizenData.java index 8b420b7bcfa..2dcc0a15b98 100755 --- a/src/main/java/com/minecolonies/core/colony/CitizenData.java +++ b/src/main/java/com/minecolonies/core/colony/CitizenData.java @@ -1011,7 +1011,7 @@ public void serializeViewNetworkData(@NotNull final RegistryFriendlyByteBuf buf) } final CompoundTag happinessCompound = new CompoundTag(); - citizenHappinessHandler.write(buf.registryAccess(), happinessCompound); + citizenHappinessHandler.write(buf.registryAccess(), happinessCompound, false); buf.writeNbt(happinessCompound); buf.writeInt(status != null ? status.getId() : -1); @@ -1248,7 +1248,7 @@ public CompoundTag serializeNBT(@NotNull final HolderLookup.Provider provider) nbtTagCompound.put("job", jobCompound); } - citizenHappinessHandler.write(provider, nbtTagCompound); + citizenHappinessHandler.write(provider, nbtTagCompound, true); citizenMournHandler.write(nbtTagCompound); inventory.write(provider, nbtTagCompound); @@ -1413,7 +1413,7 @@ public void deserializeNBT(@NotNull final HolderLookup.Provider provider, final } } - this.citizenHappinessHandler.read(provider, nbtTagCompound); + this.citizenHappinessHandler.read(provider, nbtTagCompound, true); this.citizenMournHandler.read(nbtTagCompound); if (nbtTagCompound.contains(TAG_LEVEL_MAP) && !nbtTagCompound.contains(TAG_NEW_SKILLS)) diff --git a/src/main/java/com/minecolonies/core/colony/CitizenDataView.java b/src/main/java/com/minecolonies/core/colony/CitizenDataView.java index 987d6634220..d89e0a8c2eb 100644 --- a/src/main/java/com/minecolonies/core/colony/CitizenDataView.java +++ b/src/main/java/com/minecolonies/core/colony/CitizenDataView.java @@ -362,7 +362,7 @@ public void deserialize(@NotNull final RegistryFriendlyByteBuf buf) sortedInteractions = new ArrayList<>(citizenChatOptions.values()); sortedInteractions.sort(Comparator.comparingInt(e -> -e.getPriority().getPriority())); - citizenHappinessHandler.read(buf.registryAccess(), buf.readNbt()); + citizenHappinessHandler.read(buf.registryAccess(), buf.readNbt(), false); int statusindex = buf.readInt(); statusIcon = statusindex >= 0 ? VisibleCitizenStatus.getForId(statusindex) : null; diff --git a/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenHappinessHandler.java b/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenHappinessHandler.java index c02f98d1d8b..5d802d15d24 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenHappinessHandler.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenHappinessHandler.java @@ -77,8 +77,8 @@ public CitizenHappinessHandler(final ICitizenData data) new DynamicHappinessSupplier(IDLEATJOB_FUNCTION), new Tuple<>(IDLE_AT_JOB_COMPLAINS_DAYS, 0.5), new Tuple<>(IDLE_AT_JOB_DEMANDS_DAYS, 0.1))); - addModifier(new ExpirationBasedHappinessModifier(SLEPTTONIGHT, 1.5, new DynamicHappinessSupplier(SLEPTTONIGHT_FUNCTION), 3, true)); - addModifier(new ExpirationBasedHappinessModifier(HADDECENTFOOD, 3.0, new DynamicHappinessSupplier(FOOD_FUNCTION), 7, true)); + addModifier(new TimeBasedHappinessModifier(SLEPTTONIGHT, 1.5, new DynamicHappinessSupplier(SLEPTTONIGHT_FUNCTION), (modifier, d) -> true, new Tuple<>(0, 2d), new Tuple<>(2, 1.6d), new Tuple<>(3, 1d))); + addModifier(new TimeBasedHappinessModifier(HADDECENTFOOD, 3.0, new DynamicHappinessSupplier(FOOD_FUNCTION), (modifier, d) -> true, new Tuple<>(0, 2d), new Tuple<>(4, 1.6d), new Tuple<>(7, 1d))); } /** @@ -158,7 +158,7 @@ public double getHappiness(final IColony colony, final ICitizenData citizenData) } @Override - public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compound) + public void read(@NotNull final HolderLookup.Provider provider, final CompoundTag compound, final boolean persist) { // Only deserialize for new version. Old can keep the above defaults just fine. if (compound.contains(TAG_NEW_HAPPINESS)) @@ -170,11 +170,11 @@ public void read(@NotNull final HolderLookup.Provider provider, final CompoundTa final String id = compoundTag.getString(TAG_ID); if (happinessFactors.containsKey(id)) { - happinessFactors.get(id).read(provider, compoundTag); + happinessFactors.get(id).read(provider, compoundTag, persist); } else if (VALID_HAPPINESS_MODIFIERS.contains(id)) { - final IHappinessModifier modifier = HappinessRegistry.loadFrom(provider, compoundTag); + final IHappinessModifier modifier = HappinessRegistry.loadFrom(provider, compoundTag, persist); if (modifier != null) { happinessFactors.put(modifier.getId(), modifier); @@ -185,13 +185,13 @@ else if (VALID_HAPPINESS_MODIFIERS.contains(id)) } @Override - public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compound) + public void write(@NotNull final HolderLookup.Provider provider, final CompoundTag compound, final boolean persist) { final ListTag listTag = new ListTag(); for (final IHappinessModifier happinessModifier : happinessFactors.values()) { final CompoundTag compoundNbt = new CompoundTag(); - happinessModifier.write(provider, compoundNbt); + happinessModifier.write(provider, compoundNbt, persist); listTag.add(compoundNbt); }