@@ -125,9 +125,13 @@ public class FavorScreen extends ContainerScreen<FavorContainer> {
125125
126126 // Data
127127 private static final List <ResourceLocation > deityList = new ArrayList <>();
128+ // Key: deity ID; Value: Altar Entity instance
128129 private static final Map <ResourceLocation , AltarEntity > entityMap = new HashMap <>();
130+ // Key: deity ID; Value: List of Offerings by ID and value
129131 private static final Map <ResourceLocation , List <ImmutablePair <ResourceLocation , Offering >>> offeringMap = new HashMap ();
132+ // Key: deity ID; Value: List of Trade Offerings by ID and value
130133 private static final Map <ResourceLocation , List <ImmutablePair <ResourceLocation , Offering >>> tradeMap = new HashMap ();
134+ // Key: deity ID; Value: List of Sacrifices by ID and value
131135 private static final Map <ResourceLocation , List <ImmutablePair <ResourceLocation , Sacrifice >>> sacrificeMap = new HashMap ();
132136 // Key: deity ID; Value: Map of perk level to list of available perks
133137 private static final Map <ResourceLocation , Map <Integer , List <Perk >>> perkMap = new HashMap ();
@@ -198,6 +202,17 @@ public FavorScreen(FavorContainer screenContainer, PlayerInventory inv, ITextCom
198202 }
199203 // add deity to list
200204 deityList .add (deityHelper .id );
205+ // add entries to all lists for this deity
206+ offeringMap .put (d .getId (), Lists .newArrayList ());
207+ tradeMap .put (d .getId (), Lists .newArrayList ());
208+ sacrificeMap .put (d .getId (), Lists .newArrayList ());
209+ // add entries to perk map based on favor level min and max
210+ FavorLevel favorLevel = favor .getFavor (d .getId ());
211+ Map <Integer , List <Perk >> perkSubMap = new HashMap <>();
212+ for (int i = favorLevel .getMin (), j = favorLevel .getMax (); i <= j ; i ++) {
213+ perkSubMap .put (i , Lists .newArrayList ());
214+ }
215+ perkMap .put (deityHelper .id , perkSubMap );
201216 // add all offerings to map using deity helper (so we can skip offerings that were invalid)
202217 for (List <ResourceLocation > entry : deityHelper .offeringMap .values ()) {
203218 for (ResourceLocation offeringId : entry ) {
@@ -206,7 +221,7 @@ public FavorScreen(FavorContainer screenContainer, PlayerInventory inv, ITextCom
206221 // determine which map to use (offering or trade)
207222 Map <ResourceLocation , List <ImmutablePair <ResourceLocation , Offering >>> map = offering .getTrade ().isPresent () ? tradeMap : offeringMap ;
208223 // add the offering to the map
209- map .computeIfAbsent ( Offering . getDeity ( deityHelper . id ), id -> Lists . newArrayList ()).add (ImmutablePair .of (deityHelper .id , offering ));
224+ map .get ( d . getId ()).add (ImmutablePair .of (deityHelper .id , offering ));
210225 });
211226 }
212227 }
@@ -216,7 +231,7 @@ public FavorScreen(FavorContainer screenContainer, PlayerInventory inv, ITextCom
216231 Optional <Sacrifice > optional = RPGGods .SACRIFICE .get (sacrificeId );
217232 optional .ifPresent (sacrifice -> {
218233 // add the sacrifice to the map
219- sacrificeMap .computeIfAbsent ( Sacrifice . getDeity ( deityHelper . id ), id -> Lists . newArrayList ()).add (ImmutablePair .of (deityHelper .id , sacrifice ));
234+ sacrificeMap .get ( d . getId ()).add (ImmutablePair .of (deityHelper .id , sacrifice ));
220235 });
221236 }
222237 }
@@ -230,16 +245,6 @@ public FavorScreen(FavorContainer screenContainer, PlayerInventory inv, ITextCom
230245 if (perk .getIcon ().isHidden ()) {
231246 continue ;
232247 }
233- // add entry to perk map if absent
234- if (!perkMap .containsKey (deityHelper .id )) {
235- // add map with keys for all levels
236- FavorLevel favorLevel = favor .getFavor (perk .getDeity ());
237- Map <Integer , List <Perk >> map = new HashMap <>();
238- for (int i = favorLevel .getMin (), j = favorLevel .getMax (); i <= j ; i ++) {
239- map .put (i , Lists .newArrayList ());
240- }
241- perkMap .put (deityHelper .id , map );
242- }
243248 // determine which level to place the perk
244249 int min = perk .getRange ().getMinLevel ();
245250 int max = perk .getRange ().getMaxLevel ();
@@ -248,8 +253,8 @@ public FavorScreen(FavorContainer screenContainer, PlayerInventory inv, ITextCom
248253 else if (min <= 0 && max <= 0 ) unlock = max ;
249254 else unlock = Math .min (Math .abs (min ), Math .abs (max ));
250255 // actually add the perk to the map
251- if (perkMap .get (deityHelper . id ).containsKey (unlock )) {
252- perkMap .get (deityHelper . id ).get (unlock ).add (perk );
256+ if (perkMap .get (d . getId () ).containsKey (unlock )) {
257+ perkMap .get (d . getId () ).get (unlock ).add (perk );
253258 }
254259 }
255260 }
0 commit comments