Added a config option to print all of the booklet text to file on startup.

For debug purposes.
And because it's cool.
This commit is contained in:
Ellpeck 2016-05-26 22:49:47 +02:00
parent 263acc9a9c
commit 16d9b95b5a
2 changed files with 38 additions and 13 deletions

View file

@ -47,7 +47,9 @@ public enum ConfigBoolValues{
ENABLE_SEASONAL("Seasonal Mode", ConfigCategories.OTHER, true, "If Seasonal Mode is enabled"),
DUNGEON_LOOT("Dungeon Loot", ConfigCategories.OTHER, true, "Should Actually Additions Loot spawn in Dungeons"),
GEN_LUSH_CAVES("Generate Lush Caves", ConfigCategories.WORLD_GEN, true, "Should caves with trees and grass randomly generate underground");
GEN_LUSH_CAVES("Generate Lush Caves", ConfigCategories.WORLD_GEN, true, "Should caves with trees and grass randomly generate underground"),
BOOKLET_TEXT_TO_FILE("Booklet Text to File", ConfigCategories.OTHER, false, "Should the entire text of the booklet be put into a new file in the Minecraft Folder on startup or resource reload. This is for debug purposes only and shouldn't really ever be needed.");
public final String name;
public final String category;

View file

@ -45,7 +45,9 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import javax.annotation.Nonnull;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.*;
public class ClientProxy implements IProxy{
@ -56,26 +58,49 @@ public class ClientProxy implements IProxy{
public static int bookletWordCount;
public static int bookletCharCount;
private static final List<Item> colorProdividingItemsForRegistering = new ArrayList<Item>();
private static final Map<ItemStack, ModelResourceLocation> modelLocationsForRegistering = new HashMap<ItemStack, ModelResourceLocation>();
private static final List<Item> COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING = new ArrayList<Item>();
private static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<ItemStack, ModelResourceLocation>();
private static void countBookletWords(){
bookletWordCount = 0;
bookletCharCount = 0;
String bookletText = "";
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
bookletWordCount += entry.getLocalizedName().split(" ").length;
bookletCharCount += entry.getLocalizedName().length();
bookletText+=entry.getLocalizedName()+"\n\n";
for(IBookletChapter chapter : entry.getChapters()){
bookletWordCount += chapter.getLocalizedName().split(" ").length;
bookletCharCount += chapter.getLocalizedName().length();
bookletText+=chapter.getLocalizedName()+"\n";
for(BookletPage page : chapter.getPages()){
if(page.getText() != null){
bookletWordCount += page.getText().split(" ").length;
bookletCharCount += page.getText().length();
bookletText +=page.getText()+"\n";
}
}
bookletWordCount += chapter.getLocalizedName().split(" ").length;
bookletCharCount += chapter.getLocalizedName().length();
bookletText+="\n";
}
bookletText+="\n";
}
if(ConfigBoolValues.BOOKLET_TEXT_TO_FILE.isEnabled()){
File file = new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"booklettext.txt");
try{
file.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write(bookletText);
writer.close();
ModUtil.LOGGER.info("Wrote booklet text to file!");
}
catch(Exception e){
ModUtil.LOGGER.error("Couldn't write booklet text to file!", e);
}
bookletWordCount += entry.getLocalizedName().split(" ").length;
bookletCharCount += entry.getLocalizedName().length();
}
}
@ -95,7 +120,7 @@ public class ClientProxy implements IProxy{
PersistentClientData.setTheFile(new File(Minecraft.getMinecraft().mcDataDir, ModUtil.MOD_ID+"data.dat"));
for(Map.Entry<ItemStack, ModelResourceLocation> entry : modelLocationsForRegistering.entrySet()){
for(Map.Entry<ItemStack, ModelResourceLocation> entry : MODEL_LOCATIONS_FOR_REGISTERING.entrySet()){
ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), entry.getValue());
}
@ -138,7 +163,7 @@ public class ClientProxy implements IProxy{
//VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID, "textures/entity/villager/jamVillager.png"));
for(Item item : colorProdividingItemsForRegistering){
for(Item item : COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING){
if(item instanceof IColorProvidingItem){
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem)item).getColor(), item);
}
@ -150,17 +175,15 @@ public class ClientProxy implements IProxy{
ModUtil.LOGGER.info("PostInitializing ClientProxy...");
SpecialRenderInit.init();
countBookletWords();
}
@Override
public void addRenderRegister(ItemStack stack, ModelResourceLocation location){
modelLocationsForRegistering.put(stack, location);
MODEL_LOCATIONS_FOR_REGISTERING.put(stack, location);
}
@Override
public void addColoredItem(Item item){
colorProdividingItemsForRegistering.add(item);
COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING.add(item);
}
}