Renderer/src/main/java/electrosphere/server/macro/MacroDataLoader.java
austin 7f33ba6348
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
moving data classes around
2025-05-11 16:32:37 -04:00

40 lines
1.1 KiB
Java

package electrosphere.server.macro;
import java.io.File;
import electrosphere.data.block.BlockFab;
import electrosphere.server.macro.structure.Structure;
import electrosphere.util.FileUtils;
/**
* Loads macro data
*/
public class MacroDataLoader {
/**
* Loads macro data from a save
* @param saveName The name of the save
* @return The macro data
*/
public static MacroData loadFromSave(String saveName){
MacroData rVal = FileUtils.loadObjectFromSavePath(saveName, "macro.json", MacroData.class);
//preload and assign structure fabs
for(Structure structure : rVal.getStructures()){
File fabFile = FileUtils.getAssetFile(structure.getFabPath());
if(!fabFile.exists()){
throw new Error("Failed to locate structure that does not exist! " + fabFile.getAbsolutePath());
}
BlockFab fab = BlockFab.read(fabFile);
if(fab == null){
throw new Error("Failed to read fab!");
}
structure.setFab(fab);
}
return rVal;
}
}