Removed redundant book code.

This commit is contained in:
WayofTime 2015-07-08 22:03:38 -04:00
parent 723a8b4a7e
commit 786498e615
36 changed files with 7 additions and 2510 deletions

View file

@ -1,357 +0,0 @@
package WayofTime.alchemicalWizardry.common.book;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.book.compact.Category;
import WayofTime.alchemicalWizardry.book.compact.Entry;
import WayofTime.alchemicalWizardry.book.entries.EntryImage;
import WayofTime.alchemicalWizardry.book.entries.EntryItemText;
import WayofTime.alchemicalWizardry.book.entries.EntryRitualInfo;
import WayofTime.alchemicalWizardry.book.entries.EntryText;
import WayofTime.alchemicalWizardry.book.entries.IEntry;
import WayofTime.alchemicalWizardry.book.enums.EnumType;
import WayofTime.alchemicalWizardry.book.registries.EntryRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BUEntries
{
public void postInit()
{
initCategories();
initEntries();
}
public void initCategories(){
categoryBasics = new Category("Basics", new ItemStack(ModItems.weakBloodOrb), EnumType.ITEM);
categoryRituals = new Category("Rituals", new ItemStack(ModItems.itemRitualDiviner), EnumType.ITEM);
catagoryArchitect = new Category("The Architect", new ItemStack(ModBlocks.blockAltar), EnumType.BLOCK);
categoryTest = new Category("Test", new ItemStack(ModItems.aether), EnumType.ITEM);
registerCategories();
}
public static Category categoryBasics;
public static Category categoryRituals;
public static Category catagoryArchitect;
public static Category categoryTest;
public void registerCategories(){
EntryRegistry.registerCategories(BUEntries.categoryBasics);
EntryRegistry.registerCategories(BUEntries.categoryRituals);
EntryRegistry.registerCategories(BUEntries.catagoryArchitect);
EntryRegistry.registerCategories(BUEntries.categoryTest);
}
@SideOnly(Side.CLIENT)
public void initEntries()
{
HashMap<Integer, IEntry> aIntroMap = new HashMap();
aIntroMap.put(0, new EntryImage("bloodutils:textures/misc/screenshots/t1.png", 854, 480));
/* The Architect */
aIntro = this.getMixedTextEntry(6, "Your classic tragic backstory", 1, aIntroMap);
aBloodAltar = this.getPureTextEntry(3, "The Blood Altar", 1);
aSoulNetwork = this.getPureTextEntry(3, "The Soul Network", 1);
aBasicsOfSigils = this.getPureTextEntry(4, "Basics of sigils and a glimpse into the soul", 1);
aTrainingAndWaterSigil = this.getPureTextEntry(6, "Training, and water sigils", 1);
aLavaCrystal = this.getPureTextEntry(5, "The Lava crystal", 1);
aLavaSigil = this.getPureTextEntry(8, "The perversion of the Nether, and a sigil of lava", 1);
aBlankRunes = this.getPureTextEntry(5, "Blank runes, the building blocks of the future", 1);
aSpeedRune = this.getPureTextEntry(2, "Speed runes", 1);
aApprenticeOrb = this.getPureTextEntry(4, "A shining green orb", 1);
aVoidSigil = this.getPureTextEntry(2, "The void sigil", 1);
aAirSigil = this.getPureTextEntry(2, "Air sigil", 1);
aSightSigil = this.getPureTextEntry(2, "Sigil of Sight", 1);
aAdvancedAltar = this.getPureTextEntry(5, "Advanced altar mechanics", 1);
aFastMinder = this.getPureTextEntry(2, "Sigil of the fast miner", 2);
aSoulFray = this.getPureTextEntry(2, "Soul Fray, a few thin threads", 2);
aGreenGrove = this.getPureTextEntry(2, "Green grove, a farmers friend", 2);
aDaggerOfSacrifice = this.getPureTextEntry(9, "Dagger of sacrifice, an alternative energy source", 2);
aRunesOfSacrifice = this.getPureTextEntry(10, "Runes of Sacrifice", 2);
aBloodLetterPack = this.getPureTextEntry(4, "The blood letters pack", 2);
aNewFriends = this.getPureTextEntry(18, "And then there was five", 2);
aUpgradedAltar = this.getPureTextEntry(4, "An altar upgraded, and orb formed", 2);
aNewRunes = this.getPureTextEntry(5, "New runes", 2);
aPhandomBridge = this.getPureTextEntry(8, "The Phantom bridge", 2);
aHolding = this.getPureTextEntry(2, "Sigil of holding", 2);
aElementalAffinity = this.getPureTextEntry(2, "Elemental affinity, a spell casters best friend", 2);
aRitualStones = this.getPureTextEntry(2, "Recreating ritual stones", 2);
aBloodLamp = this.getPureTextEntry(3, "Shining a blood lamp sigil", 2);
aBoundArmour = this.getPureTextEntry(8, "Bound armor, the walking fortress", 3);
aSanguineArmour = this.getPureTextEntry(2, "Sanguine armor", 3);
aSoulSuppressing = this.getPureTextEntry(1, "Suppressing the soul", 3);
aRitualDiviner = this.getPureTextEntry(5, "The ritual diviner", 3);
aBloodShards = this.getPureTextEntry(5, "Blood shards", 3);
aLifeOfMage = this.getPureTextEntry(9, "he life of a Mage", 3);
aT4 = this.getPureTextEntry(5, "The T4 altar, and a master's orb", 3);
aSigilOfWhirlwind = this.getPureTextEntry(2, "The sigil of whirlwinds", 3);
aSigilOfCompression = this.getPureTextEntry(2, "The sigil of compression", 3);
aEnderDivergence = this.getPureTextEntry(3, "The Ender divergence", 3);
aTeleposer = this.getPureTextEntry(9, "The Teleposer", 3);
aSuppression = this.getPureTextEntry(2, "The sigil of suppression", 3);
aSuperiorCapacity = this.getPureTextEntry(2, "The superior capacity rune", 3);
aRuneOfOrb = this.getPureTextEntry(3, "The rune of the orb", 3);
aFieldTrip = this.getPureTextEntry(19, "A field trip", 4);
aKeyOfBinding = this.getPureTextEntry(4, "The key of binding", 4);
aT5 = this.getPureTextEntry(4, "The trials of a T5 altar", 4);
aPriceOfPower = this.getPureTextEntry(2, "The price of power", 4);
aDemonicOrb = this.getPureTextEntry(1, "Demonic orb", 4);
aEnergyBazooka = this.getPureTextEntry(2, "The unspeakable power of the energy bazooka", 4);
aAccelerationRune = this.getPureTextEntry(2, "Acceleration runes", 4);
aHarvestSigil = this.getPureTextEntry(3, "The sigil of the Harvest goddess", 4);
aDemons = this.getPureTextEntry(6, "Solving a demon problem with more demons", 4);
aT6 = this.getPureTextEntry(3, "The T6 altar already", 4);
rIntro = new Entry(new IEntry[]{new EntryText(), new EntryText(), new EntryText()}, "Introduction", 1);
rWeakRituals = new Entry(new IEntry[]{new EntryText(), new EntryText(), new EntryText(), new EntryText()}, "Weak Rituals", 1);
rRituals = new Entry(new IEntry[]{new EntryText(), new EntryText(), new EntryText(), new EntryText()}, "Rituals", 1);
rRitualWater = this.getPureTextEntry(2, "Ritual of the Full Spring", 1);
theAltar = new Entry(new IEntry[]{new EntryItemText(new ItemStack(ModBlocks.blockAltar), "Blood Altar")}, EnumChatFormatting.BLUE + "Blood Altar", 1);
runes = new Entry(new IEntry[]{new EntryItemText(new ItemStack(ModBlocks.runeOfSelfSacrifice)), new EntryItemText(new ItemStack(ModBlocks.runeOfSacrifice)), new EntryItemText(new ItemStack(ModBlocks.speedRune))}, "Runes", 1);
/** Page 1 */
ritualWater = new Entry(new IEntry[]{new EntryText()}, "Full Spring", 1);
ritualLava = new Entry(new IEntry[]{new EntryText(), new EntryText()}, "Nether", 1);
ritualGreenGrove = new Entry(new IEntry[]{new EntryText(), new EntryText()}, "Green Grove", 1);
ritualInterdiction = new Entry(new IEntry[]{new EntryText(), new EntryText()}, "Interdiction", 1);
ritualContainment = new Entry(new IEntry[]{new EntryText()}, "Containment", 1);
ritualHighJump = new Entry(new IEntry[]{new EntryText()}, "High Jump", 1);
ritualSpeed = new Entry(new IEntry[]{new EntryText()}, "Speed", 1);
ritualMagnet = new Entry(new IEntry[]{new EntryText()}, "Magnetism", 1);
ritualCrusher = new Entry(new IEntry[]{new EntryText()}, "Crusher", 1);
ritualShepherd = new Entry(new IEntry[]{new EntryText()}, "Shepherd", 1);
ritualRegeneration = new Entry(new IEntry[]{new EntryText(), new EntryText(), new EntryText()}, "Regeneration", 1);
ritualFeatheredKnife = new Entry(new IEntry[]{new EntryText(), new EntryText(), new EntryText(), new EntryText()}, "Feathered Knife", 1);
ritualMoon = new Entry(new IEntry[]{new EntryText()}, "Harvest Moon", 1);
ritualSoul = new Entry(new IEntry[]{new EntryText(), new EntryText()}, "Eternal Soul", 2);
ritualCure = new Entry(new IEntry[]{new EntryText(), new EntryRitualInfo(500)}, "Curing", 1);
// blockDivination = new Entry(new IEntry[]{new EntryItemText(new ItemStack(BUBlocks.altarProgress)), new EntryCraftingRecipe(BURecipes.altarProgress)}, "Divination Block", 1);
// sigilAdvancedDivination = new Entry(new IEntry[]{new EntryItemText(new ItemStack(BUItems.sigil_advancedDivination)), new EntryAltarRecipe(BURecipes.advancedSigil)}, "Advanced Divination", 1);
//
// elementRituals = new Entry(new IEntry[]{new EntryItemText(new ItemStack(BUBlocks.darknessArea)), new EntryText(), new EntryCraftingRecipe(BURecipes.gemEmpty), new EntryAltarRecipe(BURecipes.diamondBlood)}, "Elemental Rituals", 1);
// reviving = new Entry(new IEntry[]{new EntryText(), new EntryCraftingRecipe(BURecipes.reviver)}, "Reviving", 1);
/** Debug */
debug = new Entry(new IEntry[]{new EntryText("Debug"), new EntryImage("bloodutils:textures/misc/screenshots/t1.png", 854, 480, "Debug")}, EnumChatFormatting.AQUA + "De" + EnumChatFormatting.RED + "bug", 1);
registerEntries();
}
public Entry getPureTextEntry(int numberOfPages, String name, int pageNumber)
{
IEntry[] entries = new IEntry[numberOfPages];
for(int i=0; i<numberOfPages; i++)
{
entries[i] = new EntryText();
}
return new Entry(entries, name, pageNumber);
}
public Entry getMixedTextEntry(int numberOfPages, String name, int pageNumber, Map<Integer, IEntry> map)
{
IEntry[] entries = new IEntry[numberOfPages];
for(int i=0; i<numberOfPages; i++)
{
entries[i] = new EntryText();
}
for(Map.Entry<Integer, IEntry> ent : map.entrySet())
{
if(ent.getKey() < entries.length)
{
entries[ent.getKey()] = ent.getValue();
}
}
return new Entry(entries, name, pageNumber);
}
/* Architect */
public static Entry aIntro;
public static Entry aBloodAltar;
public static Entry aSoulNetwork;
public static Entry aBasicsOfSigils;
public static Entry aTrainingAndWaterSigil;
public static Entry aLavaCrystal;
public static Entry aLavaSigil;
public static Entry aBlankRunes;
public static Entry aSpeedRune;
public static Entry aApprenticeOrb;
public static Entry aVoidSigil;
public static Entry aAirSigil;
public static Entry aSightSigil;
public static Entry aAdvancedAltar;
public static Entry aFastMinder;
public static Entry aSoulFray;
public static Entry aGreenGrove;
public static Entry aDaggerOfSacrifice;
public static Entry aRunesOfSacrifice;
public static Entry aBloodLetterPack;
public static Entry aNewFriends;
public static Entry aUpgradedAltar;
public static Entry aNewRunes;
public static Entry aPhandomBridge;
public static Entry aHolding;
public static Entry aElementalAffinity;
public static Entry aRitualStones;
public static Entry aBloodLamp;
public static Entry aBoundArmour;
public static Entry aSanguineArmour;
public static Entry aSoulSuppressing;
public static Entry aRitualDiviner;
public static Entry aBloodShards;
public static Entry aLifeOfMage;
public static Entry aT4;
public static Entry aSigilOfWhirlwind;
public static Entry aSigilOfCompression;
public static Entry aEnderDivergence;
public static Entry aTeleposer;
public static Entry aSuppression;
public static Entry aSuperiorCapacity;
public static Entry aRuneOfOrb;
public static Entry aFieldTrip;
public static Entry aKeyOfBinding;
public static Entry aT5;
public static Entry aPriceOfPower;
public static Entry aDemonicOrb;
public static Entry aEnergyBazooka;
public static Entry aAccelerationRune;
public static Entry aHarvestSigil;
public static Entry aDemons;
public static Entry aT6;
public static Entry rIntro;
public static Entry rWeakRituals;
public static Entry rRituals;
public static Entry rRitualWater;
public static Entry theAltar;
public static Entry runes;
public static Entry ritualCure;
public static Entry sigilAdvancedDivination;
public static Entry blockDivination;
public static Entry ritualWater;
public static Entry ritualLava;
public static Entry ritualGreenGrove;
public static Entry ritualInterdiction;
public static Entry ritualContainment;
public static Entry ritualHighJump;
public static Entry ritualSpeed;
public static Entry ritualMagnet;
public static Entry ritualCrusher;
public static Entry ritualShepherd;
public static Entry ritualRegeneration;
public static Entry ritualFeatheredKnife;
public static Entry ritualMoon;
public static Entry ritualSoul;
public static Entry elementRituals;
public static Entry reviving;
public static Entry debug;
public void registerEntries()
{
/* Architect */
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aIntro);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aBloodAltar);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSoulNetwork);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aBasicsOfSigils);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aTrainingAndWaterSigil);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aLavaCrystal);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aLavaSigil);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aBlankRunes);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSpeedRune);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aApprenticeOrb);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aVoidSigil);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aAirSigil);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSightSigil);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aAdvancedAltar);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aFastMinder);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSoulFray);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aGreenGrove);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aDaggerOfSacrifice);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aRunesOfSacrifice);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aBloodLetterPack);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aNewFriends);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aUpgradedAltar);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aNewRunes);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aPhandomBridge);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aHolding);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aElementalAffinity);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aRitualStones);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aBloodLamp);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aBoundArmour);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSanguineArmour);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSoulSuppressing);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aRitualDiviner);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aBloodShards);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aLifeOfMage);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aT4);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSigilOfWhirlwind);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSigilOfCompression);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aEnderDivergence);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aTeleposer);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSuppression);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aSuperiorCapacity);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aRuneOfOrb);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aFieldTrip);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aKeyOfBinding);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aT5);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aPriceOfPower);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aDemonicOrb);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aEnergyBazooka);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aAccelerationRune);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aHarvestSigil);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aDemons);
EntryRegistry.registerEntry(BUEntries.catagoryArchitect, EntryRegistry.architect, BUEntries.aT6);
EntryRegistry.registerEntry(BUEntries.categoryBasics, EntryRegistry.basics, BUEntries.theAltar);
EntryRegistry.registerEntry(BUEntries.categoryBasics, EntryRegistry.basics, BUEntries.runes);
EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.rIntro);
EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.rWeakRituals);
EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.rRituals);
EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.rRitualWater);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualWater);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualLava);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualGreenGrove);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualInterdiction);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualContainment);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualHighJump);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualSpeed);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualMagnet);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualCrusher);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualShepherd);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualRegeneration);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualFeatheredKnife);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualMoon);
// EntryRegistry.registerEntry(BUEntries.categoryRituals, EntryRegistry.rituals, BUEntries.ritualSoul);
/** Debug */
EntryRegistry.registerEntry(BUEntries.categoryBasics, EntryRegistry.basics, BUEntries.debug);
// this.registerCategory(BUEntries.categoryTest, EntryRegistry.test, BookParser.parseTextFile("/assets/alchemicalwizardryBooks/books/book.txt"));
}
public void registerCategory(Category cat, HashMap<String, Entry> entryMap, List<Entry> entries)
{
for(Entry entry : entries)
{
EntryRegistry.registerEntry(cat, entryMap, entry);
}
}
}

View file

@ -1,333 +0,0 @@
package WayofTime.alchemicalWizardry.common.book;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import WayofTime.alchemicalWizardry.book.compact.Entry;
import WayofTime.alchemicalWizardry.book.entries.EntryCraftingRecipeCustomText;
import WayofTime.alchemicalWizardry.book.entries.EntryImageCustomText;
import WayofTime.alchemicalWizardry.book.entries.EntryItemCustomText;
import WayofTime.alchemicalWizardry.book.entries.EntryTextCustomText;
import WayofTime.alchemicalWizardry.book.entries.IEntryCustomText;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BookParser
{
@SideOnly(Side.CLIENT)
public static List<Entry> parseTextFile(String location)
{
// File textFiles = new File("config/BloodMagic/bookDocs");
ArrayList<Entry> entryList = new ArrayList();
//if(textFiles.exists())
{
try {
System.out.println("I am in an island of files!");
InputStream input = AlchemicalWizardry.class.getResourceAsStream(location);
Minecraft.getMinecraft().fontRenderer.setUnicodeFlag(true);
if(input != null)
{
DataInputStream in = new DataInputStream(input);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
int defMaxLines = 16;
int maxLines = defMaxLines;
int currentPage = 0;
int pageIndex = 1;
String currentTitle = "aw.entry.Magnus";
String[] strings = new String[1];
strings[0] = "";
//New entry stuff
ArrayList<IEntryCustomText> iEntryList = new ArrayList();
IEntryCustomText currentIEntry = new EntryTextCustomText();
boolean lastPageWasSpecial = true;
int entriesPerPage = 14;
while ((strLine = br.readLine()) != null)
{
if(strLine.trim().isEmpty())
{
continue;
}
if(strLine.startsWith("//TITLE ")) //New entry~
{
lastPageWasSpecial = false;
String[] newStrings = new String[currentPage + 1 + 1]; //Just to show that it is increasing
for(int i=0; i<strings.length; i++)
{
newStrings[i] = strings[i];
}
if(currentPage != 0) /* New stuff */
{
currentIEntry.setText(strings[currentPage]);
iEntryList.add(currentIEntry);
Entry entry = new Entry(BookParser.getArrayForList(iEntryList), currentTitle, entryList.size() / entriesPerPage + 1);
entryList.add(entry);
iEntryList.clear();
currentIEntry = new EntryTextCustomText();
}
currentPage++;
newStrings[currentPage - 1] = currentTitle + "." + pageIndex + "=" + newStrings[currentPage - 1];
newStrings[currentPage] = "";
strings = newStrings;
pageIndex = 1;
String title = strLine.replaceFirst("//TITLE ", " ").trim();
currentTitle = title;
continue;
}else if(BookParser.containsSpecialInfo(strLine))
{
if(!strings[currentPage].isEmpty() || lastPageWasSpecial)
{
String[] newStrings = new String[currentPage + 1 + 1]; //Just to show that it is increasing
for(int i=0; i<strings.length; i++)
{
newStrings[i] = strings[i];
}
currentIEntry.setText(strings[currentPage]);
iEntryList.add(currentIEntry);
currentPage++;
newStrings[currentPage - 1] = currentTitle + "." + pageIndex + "=" + newStrings[currentPage - 1];
newStrings[currentPage] = "";
strings = newStrings;
}
currentIEntry = BookParser.getEntryForStringTitle(strLine);
maxLines = BookParser.getlineLimitForStringTitle(strLine, defMaxLines);
lastPageWasSpecial = true;
continue;
}
strLine = strLine.replace('”', '"').replace('“','"').replace("", "...").replace('', '\'').replace('', '-');
if(Minecraft.getMinecraft() != null && Minecraft.getMinecraft().fontRenderer != null)
{
List list = Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(strLine, 110);
// if(list != null)
{
//System.out.println("Number of lines: " + list.size());
}
}
String[] cutStrings = strLine.split(" ");
for(String word : cutStrings)
{
lastPageWasSpecial = true;
boolean changePage = false;
// int length = word.length();
word = word.replace('\t', ' ');
List list = Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(strings[currentPage] + " " + word, 110);
if(list.size() > maxLines)
{
changePage = true;
}
if(changePage) //Encode into current entry, then move to next entry
{
String[] newStrings = new String[currentPage + 1 + 1]; //Just to show that it is increasing
for(int i=0; i<strings.length; i++)
{
newStrings[i] = strings[i];
}
currentIEntry.setText(strings[currentPage]);
iEntryList.add(currentIEntry);
currentIEntry = new EntryTextCustomText();
currentPage++;
newStrings[currentPage - 1] = currentTitle + "." + pageIndex + "=" + newStrings[currentPage - 1];
newStrings[currentPage] = word;
strings = newStrings;
pageIndex++;
maxLines = defMaxLines;
changePage = false;
}else
{
strings[currentPage] = strings[currentPage] + " " + word;
}
}
int currentLines = Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(strings[currentPage], 110).size();
while(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(strings[currentPage] + " ", 110).size() <= currentLines)
{
{
strings[currentPage] = strings[currentPage] + " ";
}
}
//System.out.println("" + strLine);
}
strings[currentPage] = strings[currentPage];
//
currentIEntry.setText(strings[currentPage]);
iEntryList.add(currentIEntry);
Entry entry = new Entry(BookParser.getArrayForList(iEntryList), currentTitle, entryList.size() / entriesPerPage + 1);
entryList.add(entry);
iEntryList.clear();
//
// File bmDirectory = new File("src/main/resources/assets/alchemicalwizardryBooks");
// if(!bmDirectory.exists())
// {
// bmDirectory.mkdirs();
// }
//
// File file = new File(bmDirectory, "books.txt");
//// if (file.exists() && file.length() > 3L)
//// {
////
//// }else
// {
// PrintWriter writer = new PrintWriter(file);
// for(String stri : strings)
// {
// writer.println(stri);
// }
// writer.close();
// }
//
}
Minecraft.getMinecraft().fontRenderer.setUnicodeFlag(false);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return entryList;
}
public static IEntryCustomText[] getArrayForList(List<IEntryCustomText> list)
{
Object[] tempArray = list.toArray();
IEntryCustomText[] customTextArray = new IEntryCustomText[tempArray.length];
for(int i=0; i<tempArray.length; i++)
{
if(tempArray[i] instanceof IEntryCustomText)
{
customTextArray[i] = (IEntryCustomText)tempArray[i];
}
}
return customTextArray;
}
public static boolean containsSpecialInfo(String unparsedString)
{
return unparsedString.startsWith("//IMAGE") || unparsedString.startsWith("//CRAFTING") || unparsedString.startsWith("//ITEM");
}
public static IEntryCustomText getEntryForStringTitle(String unparsedString)
{
if(unparsedString.startsWith("//IMAGE ")) //Format is //IMAGE maxLines xSize ySize ImageString (optional)Title
{
String lines = unparsedString.replaceFirst("//IMAGE ", "");
String[] arguments = lines.split(" ");
if(arguments.length < 4)
{
return null;
}
int xSize = Integer.decode(arguments[1]);
int ySize = Integer.decode(arguments[2]);
if(arguments.length >= 5)
{
return new EntryImageCustomText(arguments[3], xSize, ySize, arguments[4]);
}else
{
return new EntryImageCustomText(arguments[3], xSize, ySize);
}
}else if(unparsedString.startsWith("//CRAFTING "))
{
String lines = unparsedString.replaceFirst("//CRAFTING ", "");
ItemStack stack = APISpellHelper.getItemStackForString(lines);
IRecipe recipe = APISpellHelper.getRecipeForItemStack(stack);
if(recipe != null)
{
return new EntryCraftingRecipeCustomText(recipe);
}
}else if(unparsedString.startsWith("//ITEM "))
{
String lines = unparsedString.replaceFirst("//ITEM ", "");
ItemStack stack = APISpellHelper.getItemStackForString(lines);
if(stack != null)
{
return new EntryItemCustomText(stack);
}
}
return new EntryTextCustomText();
}
public static int getlineLimitForStringTitle(String unparsedString, int def)
{
if(unparsedString.startsWith("//IMAGE "))
{
String lines = unparsedString.replaceFirst("//IMAGE ", "");
String[] arguments = lines.split(" ");
if(arguments.length < 4)
{
return def;
}
return Integer.decode(arguments[0]);
}else if(unparsedString.startsWith("//CRAFTING "))
{
return 0;
}else if(unparsedString.startsWith("//ITEM "))
{
return 9;
}
return def;
}
}

View file

@ -1,62 +0,0 @@
package WayofTime.alchemicalWizardry.common.book;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.entity.mob.BookEntityItem;
public class ItemBMBook extends Item
{
public ItemBMBook()
{
super();
setMaxStackSize(1);
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
public void registerIcons(IIconRegister ir)
{
itemIcon = ir.registerIcon("AlchemicalWizardry" + ":" + "guide");
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
player.openGui(AlchemicalWizardry.instance, 2, world, (int)player.posX, (int)player.posY, (int)player.posZ);
return stack;
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
super.onUpdate(stack, world, entity, par4, par5);
if(!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
}
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player)
{
super.onCreated(stack, world, player);
if(!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
}
@Override
public boolean hasCustomEntity(ItemStack stack)
{
return true;
}
@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack)
{
return new BookEntityItem(world, location, itemstack);
}
}

View file

@ -1,27 +0,0 @@
package WayofTime.alchemicalWizardry.common.book;
import java.util.HashMap;
import java.util.Map;
import WayofTime.alchemicalWizardry.book.registries.RecipeRegistry;
import net.minecraft.item.crafting.IRecipe;
public class SpecialEntryRegistry
{
public static Map<String, IRecipe> recipeStringMap = new HashMap();
public static void registerIRecipeKey(IRecipe recipe, String key)
{
recipeStringMap.put(key, recipe);
}
public static IRecipe getIRecipeForKey(String str)
{
return recipeStringMap.get(str);
}
public static void registerLatestIRecipe(String key)
{
SpecialEntryRegistry.registerIRecipeKey(RecipeRegistry.getLatestCraftingRecipe(), key);
}
}

View file

@ -37,7 +37,8 @@ public class ItemRitualDismantler extends EnergyItems
public void addInformation(ItemStack stack, EntityPlayer player, List par3List, boolean x)
{
par3List.add(StatCollector.translateToLocal("tooltip.dismatler.desc"));
par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + stack.getTagCompound().getString("ownerName"));
if(stack.hasTagCompound())
par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + stack.getTagCompound().getString("ownerName"));
}
@Override

View file

@ -1,17 +1,12 @@
package WayofTime.alchemicalWizardry.common.tileEntity.gui;
import WayofTime.alchemicalWizardry.common.items.sigil.holding.ContainerHolding;
import WayofTime.alchemicalWizardry.common.items.sigil.holding.GuiHolding;
import WayofTime.alchemicalWizardry.common.items.sigil.holding.InventoryHolding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.book.classes.guide.GuiCategories;
import WayofTime.alchemicalWizardry.book.classes.guide.GuiEntry;
import WayofTime.alchemicalWizardry.book.classes.guide.GuiIndex;
import WayofTime.alchemicalWizardry.book.compact.Category;
import WayofTime.alchemicalWizardry.book.registries.EntryRegistry;
import WayofTime.alchemicalWizardry.common.items.sigil.holding.ContainerHolding;
import WayofTime.alchemicalWizardry.common.items.sigil.holding.GuiHolding;
import WayofTime.alchemicalWizardry.common.items.sigil.holding.InventoryHolding;
import WayofTime.alchemicalWizardry.common.tileEntity.TETeleposer;
import WayofTime.alchemicalWizardry.common.tileEntity.TEWritingTable;
import WayofTime.alchemicalWizardry.common.tileEntity.container.ContainerTeleposer;
@ -82,28 +77,7 @@ public class GuiHandler implements IGuiHandler
break;
case 2:
if(held.hasTagCompound() && held.getTagCompound().getString("CATEGORY") != null){
if(held.hasTagCompound() && held.getTagCompound().getString("KEY") != null && held.getTagCompound().getString("KEY") != "0"){
String cate = held.getTagCompound().getString("CATEGORY");
String key = held.getTagCompound().getString("KEY");
int page = held.getTagCompound().getInteger("PAGE");
if(EntryRegistry.categoryMap.containsKey(cate)){
Category category = EntryRegistry.categoryMap.get(cate);
return new GuiEntry(key, player, category, page);
}else{
return new GuiCategories(player);
}
}else if(held.hasTagCompound() && held.getTagCompound().getString("CATEGORY") != null){
String cate = held.getTagCompound().getString("CATEGORY");
int page = held.getTagCompound().getInteger("PAGE");
if(EntryRegistry.categoryMap.containsKey(cate)){
Category category = EntryRegistry.categoryMap.get(cate);
return new GuiIndex(category, player, page);
}
}
}
return new GuiCategories(player);
case 3:
return new GuiHolding(player, new InventoryHolding(player.getHeldItem()));