Working on The Architect book - working out well~

This commit is contained in:
WayofTime 2015-02-16 07:26:03 -05:00
parent 1c806c4328
commit f87da36775
13 changed files with 499 additions and 298 deletions

View file

@ -77,7 +77,6 @@ import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry;
import WayofTime.alchemicalWizardry.common.block.ArmourForge;
import WayofTime.alchemicalWizardry.common.bloodAltarUpgrade.UpgradedAltars;
import WayofTime.alchemicalWizardry.common.book.BUEntries;
import WayofTime.alchemicalWizardry.common.book.SpecialEntryRegistry;
import WayofTime.alchemicalWizardry.common.commands.CommandBind;
import WayofTime.alchemicalWizardry.common.commands.CommandSN;
import WayofTime.alchemicalWizardry.common.commands.CommandUnbind;
@ -298,7 +297,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class AlchemicalWizardry
{
public static boolean parseTextFiles = true;
public static boolean parseTextFiles = false;
public static boolean doMeteorsDestroyBlocks = true;
public static String[] diamondMeteorArray;
@ -671,19 +670,12 @@ public class AlchemicalWizardry
ItemStack magicalesStack = new ItemStack(ModItems.magicales);
//All crafting goes here
GameRegistry.addRecipe(sacrificialDaggerStack, "ggg", " dg", "i g", 'g', glassStack, 'd', goldIngotStack, 'i', ironIngotStack);
SpecialEntryRegistry.registerLatestIRecipe("sacrificialKnife");
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(lavaCrystalStackCrafted, "glg", "lbl", "odo", 'g', glassStack, 'l', lavaBucketStack, 'b', weakBloodOrbStack, 'd', diamondStack, 'o', obsidianStack));
SpecialEntryRegistry.registerLatestIRecipe("lavaCrystal");
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(waterSigilStackCrafted, "www", "wbw", "wow", 'w', waterBucketStack, 'b', blankSlateStack, 'o', weakBloodOrbStack));
SpecialEntryRegistry.registerLatestIRecipe("waterSigil");
GameRegistry.addRecipe(lavaSigilStackCrafted, "lml", "lbl", "lcl", 'l', lavaBucketStack, 'b', blankSlateStack, 'm', magmaCreamStack, 'c', lavaCrystalStack);
SpecialEntryRegistry.registerLatestIRecipe("lavaSigil");
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(voidSigilStackCrafted, "ese", "ere", "eoe", 'e', emptyBucketStack, 'r', reinforcedSlateStack, 'o', apprenticeBloodOrbStack, 's', stringStack));
SpecialEntryRegistry.registerLatestIRecipe("voidSigil");
GameRegistry.addRecipe(bloodAltarStack, "s s", "scs", "gdg", 's', stoneStack, 'c', furnaceStack, 'd', diamondStack, 'g', goldIngotStack);
SpecialEntryRegistry.registerLatestIRecipe("bloodAltar");
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(bloodRuneCraftedStack, "sss", "ror", "sss", 's', stoneStack, 'o', weakBloodOrbStack, 'r', blankSlateStack));
SpecialEntryRegistry.registerLatestIRecipe("blankRune");
GameRegistry.addRecipe(speedRuneStack, "sbs", "uru", "sbs", 'u', sugarStack, 's', stoneStack, 'r', bloodRuneStack, 'b', blankSlateStack);
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(ModBlocks.bloodRune, 1, 1), "sbs", "bob", "srs", 's', stoneStack, 'o', magicianBloodOrbStack, 'b', emptyBucketStack, 'r', new ItemStack(ModItems.imbuedSlate)));
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(ModBlocks.bloodRune, 1, 2), "sbs", "bob", "srs", 's', stoneStack, 'o', magicianBloodOrbStack, 'b', waterBucketStack, 'r', new ItemStack(ModItems.imbuedSlate)));

View file

@ -1,13 +1,16 @@
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
import net.minecraft.item.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
public class AltarRecipeRegistry
{
public static List<AltarRecipe> altarRecipes = new LinkedList();
public static Map<Integer, ItemStack> orbMap = new HashMap();
public static void registerAltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
{
@ -21,6 +24,10 @@ public class AltarRecipeRegistry
public static void registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate)
{
if(!orbMap.containsKey(minTier))
{
orbMap.put(minTier, orbStack);
}
registerAltarRecipe(null, orbStack, minTier, 0, consumptionRate, 0, true);
}

View file

@ -8,7 +8,10 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
@ -16,6 +19,7 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
public class APISpellHelper
{
@ -247,4 +251,75 @@ public class APISpellHelper
return "";
}
}
public static Block getBlockForString(String str)
{
String[] parts = str.split(":");
String modId = parts[0];
String name = parts[1];
return GameRegistry.findBlock(modId, name);
}
public static Item getItemForString(String str)
{
String[] parts = str.split(":");
String modId = parts[0];
String name = parts[1];
return GameRegistry.findItem(modId, name);
}
public static ItemStack getItemStackForString(String str)
{
String[] parts = str.split(":");
int meta = 0;
if(parts.length >= 3)
{
meta = Integer.decode(parts[2]);
}else if(parts.length < 2)
{
return null;
}
String modId = parts[0];
String name = parts[1];
String itemString = modId + ":" + name;
Item item = APISpellHelper.getItemForString(itemString);
if(item != null)
{
return new ItemStack(item, 1, meta);
}
Block block = APISpellHelper.getBlockForString(itemString);
if(block != null)
{
return new ItemStack(block, 1, meta);
}
return null;
}
public static IRecipe getRecipeForItemStack(ItemStack reqStack) //Does not match NBT. Durrr! -smack-
{
if(reqStack == null)
{
return null; //Why are you even doing this to yourself!? You know this can't be healthy!
}
List craftingList = CraftingManager.getInstance().getRecipeList();
for(Object posRecipe : craftingList)
{
if(posRecipe instanceof IRecipe)
{
ItemStack outputStack = ((IRecipe) posRecipe).getRecipeOutput();
if(outputStack != null)
{
if(outputStack.getItem() == reqStack.getItem() && (outputStack.getItem().getHasSubtypes() ? outputStack.getItemDamage() == reqStack.getItemDamage() : true))
{
return (IRecipe)posRecipe;
}
}
}
}
return null;
}
}

View file

@ -20,6 +20,7 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry;
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
import WayofTime.alchemicalWizardry.book.classes.guide.GuiEntry;
@ -63,7 +64,11 @@ public class EntryCraftingRecipe implements IEntry{
ItemStack s = null;
if(rec.getInput()[i] instanceof ItemStack){
s = (ItemStack)rec.getInput()[i];
}else if(rec.getInput()[i] instanceof Integer)
{
s = AltarRecipeRegistry.orbMap.get((Integer)rec.getInput()[i]);
}else if(rec.getInput()[i] instanceof Object){
System.out.println(rec.getInput()[i].getClass());
s = new ItemStack(ModItems.masterBloodOrb);
}else{
s = ((ArrayList<ItemStack>)rec.getInput()[i]).get(0);

View file

@ -0,0 +1,52 @@
package WayofTime.alchemicalWizardry.book.entries;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.book.classes.guide.GuiEntry;
public class EntryItemCustomText extends EntryItemText implements IEntryCustomText
{
public EntryItemCustomText(ItemStack stack)
{
super(stack);
}
public EntryItemCustomText(ItemStack stack, String title)
{
super(stack, title);
}
public String str = "";
@Override
public String getText()
{
return str;
}
@Override
public void setText(String str)
{
this.str = str;
}
@Override
public void drawText(GuiEntry entry, int width, int height, int left, int top, EntityPlayer player, String key, int page, int mX, int mY)
{
int x, y;
if(this.entryName == null)
this.entryName = key;
String s = this.str;
x = left + width / 2 - 58;
y = (top + 15);
Minecraft.getMinecraft().fontRenderer.setUnicodeFlag(true);
Minecraft.getMinecraft().fontRenderer.drawSplitString(s, x, y, 110, 0);
Minecraft.getMinecraft().fontRenderer.setUnicodeFlag(false);
}
}

View file

@ -139,7 +139,6 @@ public class BUEntries
/** 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);
registerKeys();
registerEntries();
}
@ -258,11 +257,6 @@ public class BUEntries
public static Entry debug;
public void registerKeys()
{
}
public void registerEntries()
{
/* Architect */
@ -347,7 +341,7 @@ public class BUEntries
this.registerCategory(BUEntries.categoryTest, EntryRegistry.test, BookParser.parseTextFile());
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)

View file

@ -12,11 +12,14 @@ 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;
@ -25,7 +28,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BookParser
{
@SideOnly(Side.CLIENT)
public static List<Entry> parseTextFile()
public static List<Entry> parseTextFile(String location)
{
File textFiles = new File("config/BloodMagic/bookDocs");
ArrayList<Entry> entryList = new ArrayList();
@ -34,7 +37,7 @@ public class BookParser
try {
System.out.println("I am in an island of files!");
InputStream input = AlchemicalWizardry.class.getResourceAsStream("/assets/alchemicalwizardryBooks/books/book.txt");
InputStream input = AlchemicalWizardry.class.getResourceAsStream(location);
Minecraft.getMinecraft().fontRenderer.setUnicodeFlag(true);
@ -138,7 +141,7 @@ public class BookParser
List list = Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(strLine, 110);
if(list != null)
{
System.out.println("Number of lines: " + list.size());
//System.out.println("Number of lines: " + list.size());
}
}
@ -194,7 +197,7 @@ public class BookParser
}
}
System.out.println("" + strLine);
//System.out.println("" + strLine);
}
strings[currentPage] = strings[currentPage];
@ -261,7 +264,7 @@ public class BookParser
public static boolean containsSpecialInfo(String unparsedString)
{
return unparsedString.startsWith("//IMAGE") || unparsedString.startsWith("//CRAFTING");
return unparsedString.startsWith("//IMAGE") || unparsedString.startsWith("//CRAFTING") || unparsedString.startsWith("//ITEM");
}
public static IEntryCustomText getEntryForStringTitle(String unparsedString)
@ -287,11 +290,20 @@ public class BookParser
}else if(unparsedString.startsWith("//CRAFTING "))
{
String lines = unparsedString.replaceFirst("//CRAFTING ", "");
IRecipe recipe = SpecialEntryRegistry.getIRecipeForKey(lines);
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();
@ -312,6 +324,9 @@ public class BookParser
}else if(unparsedString.startsWith("//CRAFTING "))
{
return 0;
}else if(unparsedString.startsWith("//ITEM "))
{
return 9;
}
return def;