Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TelepathicGrunt/fb7df8d6f2c2096e197c6065b127217a to your computer and use it in GitHub Desktop.
Save TelepathicGrunt/fb7df8d6f2c2096e197c6065b127217a to your computer and use it in GitHub Desktop.
Gson gson = new GsonBuilder().setPrettyPrinting().create();
// Will print the stuff into the runs/config folder
try {
for(Map.Entry<RegistryKey<StructureProcessorList>, StructureProcessorList> processorListEntry : BuiltinRegistries.STRUCTURE_PROCESSOR_LIST.getEntries()){
if(!processorListEntry.getKey().getValue().getNamespace().equals(RepurposedStructures.MODID)) continue;
for(StructureProcessor processorEntry : processorListEntry.getValue().getList()) {
String filePath = FabricLoader.getInstance().getConfigDir()+"\\processor_list\\"+processorListEntry.getKey().getValue().getPath()+".json";
File file = new File(filePath);
file.getParentFile().mkdirs();
FileWriter writer = new FileWriter(file);
Optional<JsonElement> structureProcessorJSON = RuleStructureProcessor.CODEC.encode((RuleStructureProcessor)processorEntry, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()).get().left();
gson.toJson(structureProcessorJSON.get(), writer);
writer.flush();
writer.close();
}
}
for(Map.Entry<RegistryKey<StructurePool>, StructurePool> structurePool : BuiltinRegistries.STRUCTURE_POOL.getEntries()) {
if(!structurePool.getKey().getValue().getNamespace().equals(RepurposedStructures.MODID)) continue;
String filePath = FabricLoader.getInstance().getConfigDir()+"\\template_pool\\"+structurePool.getKey().getValue().getPath()+".json";
File file = new File(filePath);
file.getParentFile().mkdirs();
FileWriter writer = new FileWriter(file);
Optional<JsonElement> structurePoolsJSON = StructurePool.CODEC.encode(structurePool.getValue(), JsonOps.INSTANCE, JsonOps.INSTANCE.empty()).get().left();
gson.toJson(structurePoolsJSON.get(), writer);
writer.flush();
writer.close();
}
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment