11package com .mewo .hbmenhanced .Util ;
22
3+ import com .google .gson .reflect .TypeToken ;
34import com .hbm .items .ModItems ;
45import com .mewo .hbmenhanced .ResearchBlocks .ResearchController .TileEntityResearchController ;
56import com .mewo .hbmenhanced .ResearchBlocks .Tier1 .TileEntityT1 ;
1213import net .minecraft .nbt .NBTTagCompound ;
1314import net .minecraft .tileentity .TileEntity ;
1415
16+ import java .io .File ;
17+ import java .lang .reflect .Type ;
1518import java .util .*;
1619
1720public class getItemValues {
1821
1922 public static Map <String , Map <String , Integer >> researchCounts = new HashMap <>();
2023 public static Map <String , ResearchValue > Values = new HashMap <>();
2124
25+ public static void loadDiminish () {
26+ File file = new File ("config/hbmenhanced/research_diminish.json" );
27+ Type type = new TypeToken <Map <String , Map <String , Integer >>>() {}.getType ();
28+ Map <String , Map <String , Integer >> loaded = JsonUtil .read (file , type );
29+ if (loaded != null ) {
30+ researchCounts = loaded ;
31+ System .out .println ("[getItemValues] Loaded diminishing values for all teams." );
32+ } else {
33+ System .out .println ("[getItemValues] No existing diminishing data found, starting fresh." );
34+ }
35+ }
36+
37+ public static void saveDiminish () {
38+ File file = new File ("config/hbmenhanced/research_diminish.json" );
39+ JsonUtil .write (file , researchCounts );
40+ System .out .println ("[getItemValues] Saved diminishing values for all teams." );
41+ }
42+
2243 // Creates a truly unique identifier for an item including metadata
2344 private static String getUniqueItemKey (Item item , int meta ) {
2445 return Item .itemRegistry .getNameForObject (item ) + ":" + meta ;
@@ -165,6 +186,11 @@ public static void setValues(ResearchValue value, ItemStack outStack, String tea
165186
166187 Map <PointManager .ResearchType , Integer > map = value .getAllPoints ();
167188 System .out .println ("Map size: " + map .size ());
189+ System .out .println (team );
190+ if (team == null ) {
191+ System .err .println ("[getItemValues] Cannot apply diminishing: team is null. Stack=" + sourceStack );
192+ return ;
193+ }
168194 researchCounts .computeIfAbsent (team , t -> new HashMap <>());
169195
170196 for (Map .Entry <PointManager .ResearchType , Integer > entry : map .entrySet ()) {
@@ -174,6 +200,7 @@ public static void setValues(ResearchValue value, ItemStack outStack, String tea
174200
175201 int current = researchCounts .get (team ).getOrDefault (sourceKey , 0 );
176202 researchCounts .get (team ).put (sourceKey , current + 1 );
203+ getItemValues .saveDiminish ();
177204 System .out .println ("Applied diminishing for source item: " + sourceKey + " for team: " + team );
178205 }
179206}
0 commit comments