mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
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:
parent
263acc9a9c
commit
16d9b95b5a
2 changed files with 38 additions and 13 deletions
|
@ -47,7 +47,9 @@ public enum ConfigBoolValues{
|
||||||
ENABLE_SEASONAL("Seasonal Mode", ConfigCategories.OTHER, true, "If Seasonal Mode is enabled"),
|
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"),
|
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 name;
|
||||||
public final String category;
|
public final String category;
|
||||||
|
|
|
@ -45,7 +45,9 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ClientProxy implements IProxy{
|
public class ClientProxy implements IProxy{
|
||||||
|
@ -56,26 +58,49 @@ public class ClientProxy implements IProxy{
|
||||||
public static int bookletWordCount;
|
public static int bookletWordCount;
|
||||||
public static int bookletCharCount;
|
public static int bookletCharCount;
|
||||||
|
|
||||||
private static final List<Item> colorProdividingItemsForRegistering = new ArrayList<Item>();
|
private static final List<Item> COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING = new ArrayList<Item>();
|
||||||
private static final Map<ItemStack, ModelResourceLocation> modelLocationsForRegistering = new HashMap<ItemStack, ModelResourceLocation>();
|
private static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<ItemStack, ModelResourceLocation>();
|
||||||
|
|
||||||
private static void countBookletWords(){
|
private static void countBookletWords(){
|
||||||
bookletWordCount = 0;
|
bookletWordCount = 0;
|
||||||
bookletCharCount = 0;
|
bookletCharCount = 0;
|
||||||
|
String bookletText = "";
|
||||||
|
|
||||||
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
|
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()){
|
for(IBookletChapter chapter : entry.getChapters()){
|
||||||
|
bookletWordCount += chapter.getLocalizedName().split(" ").length;
|
||||||
|
bookletCharCount += chapter.getLocalizedName().length();
|
||||||
|
bookletText+=chapter.getLocalizedName()+"\n";
|
||||||
|
|
||||||
for(BookletPage page : chapter.getPages()){
|
for(BookletPage page : chapter.getPages()){
|
||||||
if(page.getText() != null){
|
if(page.getText() != null){
|
||||||
bookletWordCount += page.getText().split(" ").length;
|
bookletWordCount += page.getText().split(" ").length;
|
||||||
bookletCharCount += page.getText().length();
|
bookletCharCount += page.getText().length();
|
||||||
|
bookletText +=page.getText()+"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bookletWordCount += chapter.getLocalizedName().split(" ").length;
|
bookletText+="\n";
|
||||||
bookletCharCount += chapter.getLocalizedName().length();
|
|
||||||
|
}
|
||||||
|
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"));
|
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());
|
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"));
|
//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){
|
if(item instanceof IColorProvidingItem){
|
||||||
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem)item).getColor(), item);
|
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem)item).getColor(), item);
|
||||||
}
|
}
|
||||||
|
@ -150,17 +175,15 @@ public class ClientProxy implements IProxy{
|
||||||
ModUtil.LOGGER.info("PostInitializing ClientProxy...");
|
ModUtil.LOGGER.info("PostInitializing ClientProxy...");
|
||||||
|
|
||||||
SpecialRenderInit.init();
|
SpecialRenderInit.init();
|
||||||
|
|
||||||
countBookletWords();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRenderRegister(ItemStack stack, ModelResourceLocation location){
|
public void addRenderRegister(ItemStack stack, ModelResourceLocation location){
|
||||||
modelLocationsForRegistering.put(stack, location);
|
MODEL_LOCATIONS_FOR_REGISTERING.put(stack, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addColoredItem(Item item){
|
public void addColoredItem(Item item){
|
||||||
colorProdividingItemsForRegistering.add(item);
|
COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue