mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
dumper code + temporary dumped results
This commit is contained in:
1 parent
218fb4c2c7
commit
0e187f0756
227 files changed
+7235
-39
No files matched your search
@@ -10,15 +10,42 @@
|
||||
*/
|
||||
package vazkii.botania.api.lexicon;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.lexicon.page.PageBrew;
|
||||
import vazkii.botania.common.lexicon.page.PageCraftingRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageElvenRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageImage;
|
||||
import vazkii.botania.common.lexicon.page.PageManaInfusionRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PagePetalRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageRuneRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageTerrasteel;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
import vazkii.botania.common.lib.LibLexicon;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LexiconEntry implements Comparable<LexiconEntry> {
|
||||
|
||||
@@ -90,6 +117,69 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
File dir = Paths.get(".", "entries", category.getUnlocalizedName().substring(LibLexicon.CATEGORY_PREFIX.length())).toFile();
|
||||
if(!dir.exists())
|
||||
dir.mkdirs();
|
||||
File f = new File(dir, this.unlocalizedName + ".json");
|
||||
if (f.exists())
|
||||
throw new RuntimeException("preexisting file " + f.getAbsolutePath());
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
Type typ = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
try (OutputStreamWriter os = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(f)))) {
|
||||
Map<String, Object> entry = new LinkedHashMap<>();
|
||||
entry.put("name", this.getUnlocalizedName());
|
||||
entry.put("category", category.getUnlocalizedName());
|
||||
entry.put("icon", getIcon().getItem().getRegistryName().toString());
|
||||
if (isPriority())
|
||||
entry.put("priority", true);
|
||||
List<Object> pages = new ArrayList<>();
|
||||
for(LexiconPage page : this.pages) {
|
||||
Map<String, Object> json = new LinkedHashMap<>();
|
||||
if (page instanceof PageText) {
|
||||
json.put("type", "text");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
} else if (page instanceof PageImage) {
|
||||
json.put("type", "image");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
json.put("images", Collections.singletonList(((PageImage) page).resource.toString()));
|
||||
} else if (page instanceof PageCraftingRecipe) {
|
||||
json.put("type", "crafting_multi");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
json.put("recipes", ((PageCraftingRecipe) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.toList()));
|
||||
} else if (page instanceof PageManaInfusionRecipe) {
|
||||
json.put("type", "mana_infusion");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
json.put("recipes", ((PageManaInfusionRecipe) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.toList()));
|
||||
} else if (page instanceof PagePetalRecipe) {
|
||||
json.put("type", "petal_apothecary");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
json.put("recipes", ((PagePetalRecipe) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.toList()));
|
||||
} else if (page instanceof PageRuneRecipe) {
|
||||
json.put("type", "runic_altar");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
json.put("recipes", ((PageRuneRecipe) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.toList()));
|
||||
} else if (page instanceof PageElvenRecipe) {
|
||||
json.put("type", "elven_trade");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
json.put("recipes", ((PageElvenRecipe) page).getRecipes().stream().map(r -> r.getId().toString()).collect(Collectors.toList()));
|
||||
} else if (page instanceof PageBrew) {
|
||||
json.put("type", "brew");
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
json.put("recipe", ((PageBrew) page).recipe.getId());
|
||||
} else {
|
||||
json.put("type", "_unknown_" + page.getClass().getSimpleName());
|
||||
json.put("text", page.getUnlocalizedName());
|
||||
}
|
||||
pages.add(json);
|
||||
}
|
||||
entry.put("pages", pages);
|
||||
os.write(gson.toJson(entry));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets what pages you want this entry to have.
|
||||
*/
|
||||
|
||||
@@ -1438,10 +1438,10 @@ public final class LexiconData {
|
||||
bcIntegration.setLexiconPages(new PageText("0")).setIcon(new ItemStack(Items.REDSTONE));
|
||||
}
|
||||
|
||||
if(Botania.thaumcraftLoaded) {
|
||||
if(true || Botania.thaumcraftLoaded) {
|
||||
tcIntegration = new CompatLexiconEntry(LibLexicon.MISC_TC_INTEGRATION, BotaniaAPI.categoryMisc, "Thaumcraft");
|
||||
|
||||
if(ConfigHandler.COMMON.enableThaumcraftStablizers.get())
|
||||
if(true || ConfigHandler.COMMON.enableThaumcraftStablizers.get())
|
||||
tcIntegration.setLexiconPages(new PageText("0"), new PageText("1"),
|
||||
new PageCraftingRecipe("2", ModItems.manasteelHelmRevealing, ModItems.elementiumHelmRevealing, ModItems.terrasteelHelmRevealing), new PageText("3"),
|
||||
new PageManaInfusionRecipe("4", ModItems.manaInkwell), new PageText("5"),
|
||||
@@ -1455,6 +1455,11 @@ public final class LexiconData {
|
||||
.setIcon(new ItemStack(ModItems.manaInkwell));
|
||||
}
|
||||
Botania.LOGGER.info("Reloaded lexicon in {}", stopwatch.stop());
|
||||
|
||||
Botania.LOGGER.info("Dumping lexicon entries");
|
||||
for (LexiconEntry e : BotaniaAPI.getAllEntries()) {
|
||||
e.dump();
|
||||
}
|
||||
}
|
||||
|
||||
private static Predicate<IRecipe<?>> GOG_RECIPE = recipe -> recipe.getId().getPath().contains("garden_of_glass");
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
public class PageBrew extends PageRecipe implements ITwoNamedPage {
|
||||
private static final RecipeBrew DUMMY = new RecipeBrew(new ResourceLocation(LibMisc.MOD_ID, "dummy"), BotaniaAPI.fallbackBrew);
|
||||
|
||||
private final RecipeBrew recipe;
|
||||
public final RecipeBrew recipe;
|
||||
private String text;
|
||||
|
||||
public PageBrew(Brew brew, String unlocalizedName, String bottomText) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import vazkii.botania.api.lexicon.LexiconPage;
|
||||
|
||||
public class PageImage extends LexiconPage {
|
||||
|
||||
final ResourceLocation resource;
|
||||
public final ResourceLocation resource;
|
||||
|
||||
public PageImage(String unlocalizedName, String resource) {
|
||||
super(unlocalizedName);
|
||||
|
||||
Reference in new issue
Block a user