diff --git a/src/com/spiteful/forbidden/Compat.java b/src/com/spiteful/forbidden/Compat.java index 473f089..495e4ee 100644 --- a/src/com/spiteful/forbidden/Compat.java +++ b/src/com/spiteful/forbidden/Compat.java @@ -34,6 +34,7 @@ import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; import kihira.playerbeacons.common.PlayerBeacons; import vazkii.botania.api.BotaniaAPI; +import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipeRegistry; public class Compat { @@ -175,7 +176,7 @@ public class Compat { } } - catch(LinkageError e) + catch(Throwable e) { FMLLog.log(Level.INFO, e, "Player Beacons showed Forbidden Magic who the Alpha Fox is."); //e.printStackTrace(); @@ -208,9 +209,7 @@ public class Compat { InfusionRecipe blood_recipe = ThaumcraftApi.addInfusionCraftingRecipe("ROD_blood", new ItemStack(ForbiddenItems.wandCore, 1, 6), 2, (new AspectList()).add(Aspect.LIFE, 32).add(Aspect.MAGIC, 12).add(Aspect.WATER, 16), new ItemStack(masterOrb), new ItemStack[]{new ItemStack(magicales), new ItemStack(imbuedSlate), new ItemStack(imbuedSlate), new ItemStack(tennebrae), new ItemStack(sanctus), new ItemStack(aquasalus), new ItemStack(incendium), new ItemStack(terrae), new ItemStack(aether)}); (new DarkResearchItem("ROD_blood", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 5).add(Aspect.WATER, 4).add(Aspect.WEAPON, 3), -5, -3, 3, new ItemStack(ForbiddenItems.wandCore, 1, 3))).setPages(new ResearchPage[]{new ResearchPage("forbidden.research_page.ROD_blood.1"), new ResearchPage(blood_recipe), new ResearchPage("forbidden.research_page.ROD_blood.2")}).setParents(new String[]{"ROD_silverwood", "INFAUXSION"}).setAspectTriggers(new Aspect[]{Aspect.LIFE}).setConcealed().registerResearchItem(); - Class altar = Class.forName("WayofTime.alchemicalWizardry.common.altarRecipeRegistry.AltarRecipeRegistry"); - Method register = altar.getDeclaredMethod("registerAltarRecipe", new Class[] {ItemStack.class, ItemStack.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Boolean.TYPE}); - register.invoke(null, new ItemStack(ForbiddenItems.wandCore, 1, 3), new ItemStack(ForbiddenItems.wandCore, 1, 6), 4, 20000, 15, 20, false); + AltarRecipeRegistry.registerAltarRecipe(new ItemStack(ForbiddenItems.wandCore, 1, 3), new ItemStack(ForbiddenItems.wandCore, 1, 6), 4, 20000, 15, 20, false); InfusionRecipe alchemical_recipe = ThaumcraftApi.addInfusionCraftingRecipe("CAP_alchemical", new ItemStack(ForbiddenItems.wandCap, 1, 0), 3, (new AspectList()).add(Aspect.LIFE, 12).add(Aspect.WATER, 6), ItemApi.getItem("itemWandCap", 1), new ItemStack[]{new ItemStack(magicales), new ItemStack(magicales), new ItemStack(magicales)}); (new DarkResearchItem("CAP_alchemical", "FORBIDDEN", "[BM]", (new AspectList()).add(Aspect.LIFE, 4).add(Aspect.TOOL, 1).add(Aspect.WATER, 3), -5, -5, 2, new ItemStack(ForbiddenItems.wandCap, 1, 0))).setPages(new ResearchPage[]{new ResearchPage("forbidden.research_page.CAP_alchemical.1"), new ResearchPage(alchemical_recipe)}).setParents(new String[]{"ROD_blood", "CAP_gold"}).setSecondary().setConcealed().registerResearchItem(); @@ -302,7 +301,7 @@ public class Compat { list = (new AspectList()).add(Aspect.ENTROPY, 6).add(Aspect.ENERGY, 3); aspectBloodItem("crepitous", -1, list); } - catch(Exception e) + catch(Throwable e) { FMLLog.log(Level.INFO, e, "Forbidden Magic tried to do some Blood Magic, but bled out."); e.printStackTrace(); diff --git a/src/com/spiteful/forbidden/items/ItemBloodwell.java b/src/com/spiteful/forbidden/items/ItemBloodwell.java index 95939df..bffecd2 100644 --- a/src/com/spiteful/forbidden/items/ItemBloodwell.java +++ b/src/com/spiteful/forbidden/items/ItemBloodwell.java @@ -17,15 +17,14 @@ import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import thaumcraft.api.IScribeTools; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; -public class ItemBloodwell extends Item implements IScribeTools { +public class ItemBloodwell extends Item implements IScribeTools, IBindable { @SideOnly(Side.CLIENT) public Icon icon; - Method checkOwner; - Method syphon; - public ItemBloodwell(int id) { super(id); maxStackSize = 1; @@ -33,17 +32,6 @@ public class ItemBloodwell extends Item implements IScribeTools { setMaxDamage(100); setCreativeTab(Forbidden.tab); setHasSubtypes(false); - - try - { - Class energyItems; - energyItems = Class.forName("WayofTime.alchemicalWizardry.common.items.EnergyItems"); - - checkOwner = energyItems.getDeclaredMethod("checkAndSetItemOwner", new Class[] {ItemStack.class, EntityPlayer.class}); - syphon = energyItems.getDeclaredMethod("syphonWhileInContainer", new Class[] {ItemStack.class, Integer.TYPE}); - } - catch(Exception e){ - e.printStackTrace(); } } @SideOnly(Side.CLIENT) @@ -74,7 +62,7 @@ public class ItemBloodwell extends Item implements IScribeTools { { if(player.capabilities.isCreativeMode) stack.setItemDamage(0); - else if(((Boolean)(syphon.invoke(null, stack, 25))).booleanValue()) + else if(SoulNetworkHandler.syphonFromNetwork(stack, 25) > 0) stack.setItemDamage(stack.getItemDamage() - 1); else if(player.getHealth() > 6) { @@ -82,19 +70,22 @@ public class ItemBloodwell extends Item implements IScribeTools { stack.setItemDamage(stack.getItemDamage() - 1); } } - catch(Exception e){} + catch(Throwable e){} } } @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + public ItemStack onItemRightClick(ItemStack itemstack, World par2World, EntityPlayer player) { - try + if(Compat.bm) { - checkOwner.invoke(null, par1ItemStack, par3EntityPlayer); + try + { + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); + } + catch (Throwable e){} } - catch (Exception e){} - return par1ItemStack; + return itemstack; } @Override diff --git a/src/com/spiteful/forbidden/items/ItemDivineOrb.java b/src/com/spiteful/forbidden/items/ItemDivineOrb.java index 2d1702d..1785274 100644 --- a/src/com/spiteful/forbidden/items/ItemDivineOrb.java +++ b/src/com/spiteful/forbidden/items/ItemDivineOrb.java @@ -2,19 +2,25 @@ package com.spiteful.forbidden.items; import com.spiteful.forbidden.*; -import WayofTime.alchemicalWizardry.common.items.EnergyBattery; -import WayofTime.alchemicalWizardry.common.altarRecipeRegistry.AltarRecipeRegistry; +import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; +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.api.altarRecipeRegistry.AltarRecipeRegistry; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb; +import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; -public class ItemDivineOrb extends EnergyBattery +public class ItemDivineOrb extends Item implements IBloodOrb, IBindable { public ItemDivineOrb(int id) { - super(id, 70000000); - orbLevel = 5; + super(id); setCreativeTab(Forbidden.tab); AltarRecipeRegistry.registerAltarOrbRecipe(new ItemStack(this),5,140); } @@ -25,4 +31,57 @@ public class ItemDivineOrb extends EnergyBattery { this.itemIcon = iconRegister.registerIcon("forbidden:divineorb"); } + + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + par3List.add("Stores raw Life Essence"); + + if (!(par1ItemStack.stackTagCompound == null)) + { + par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName")); + } + + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) + { + if(Compat.bm) + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); + + if (world != null) + { + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; + world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + } + if(!world.isRemote) + { + return itemstack; + } + + NBTTagCompound itemTag = itemstack.stackTagCompound; + + if (itemTag == null || itemTag.getString("ownerName").equals("")) + { + return itemstack; + } + + player.setHealth(player.getHealth() - 1); + SoulNetworkHandler.addCurrentEssenceToMaximum(itemTag.getString("ownerName"), 200, 700000000); + + return itemstack; + } + + public int getMaxEssence() + { + return 70000000; + } + + public int getOrbLevel() + { + return 5; + } } \ No newline at end of file diff --git a/src/com/spiteful/forbidden/items/wands/BloodStaffUpdate.java b/src/com/spiteful/forbidden/items/wands/BloodStaffUpdate.java index d213f98..6cf4171 100644 --- a/src/com/spiteful/forbidden/items/wands/BloodStaffUpdate.java +++ b/src/com/spiteful/forbidden/items/wands/BloodStaffUpdate.java @@ -10,28 +10,12 @@ import thaumcraft.api.wands.IWandRodOnUpdate; import thaumcraft.common.items.wands.ItemWandCasting; import java.lang.reflect.Field; import java.lang.reflect.Method; -//import WayofTime.alchemicalWizardry.common.EnergyItems; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; public class BloodStaffUpdate implements IWandRodOnUpdate { Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]); - Method checkOwner; - Method syphon; - public BloodStaffUpdate() - { - try - { - Class energyItems; - energyItems = Class.forName("WayofTime.alchemicalWizardry.common.items.EnergyItems"); - - checkOwner = energyItems.getDeclaredMethod("checkAndSetItemOwner", new Class[] {ItemStack.class, EntityPlayer.class}); - syphon = energyItems.getDeclaredMethod("syphonWhileInContainer", new Class[] {ItemStack.class, Integer.TYPE}); - } - catch(Exception e){ - e.printStackTrace(); } - } - public void onUpdate(ItemStack itemstack, EntityPlayer player) { if(Compat.bm && player.ticksExisted % 25 == 0) @@ -41,7 +25,7 @@ public class BloodStaffUpdate implements IWandRodOnUpdate { if(!checkHotbar(itemstack, player)) return; - checkOwner.invoke(null, itemstack, player); + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); int cost; if(((ItemWandCasting)itemstack.getItem()).getCap(itemstack).getTag().equals("alchemical")) @@ -55,7 +39,7 @@ public class BloodStaffUpdate implements IWandRodOnUpdate { { if(player.capabilities.isCreativeMode) ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); - else if(((Boolean)(syphon.invoke(null, itemstack, cost))).booleanValue()) + else if(SoulNetworkHandler.syphonFromNetwork(itemstack, cost) > 0) ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); else if(syphonHealth(player)) { diff --git a/src/com/spiteful/forbidden/items/wands/BloodWandUpdate.java b/src/com/spiteful/forbidden/items/wands/BloodWandUpdate.java index 65801ee..5815880 100644 --- a/src/com/spiteful/forbidden/items/wands/BloodWandUpdate.java +++ b/src/com/spiteful/forbidden/items/wands/BloodWandUpdate.java @@ -10,35 +10,19 @@ import thaumcraft.api.wands.IWandRodOnUpdate; import thaumcraft.common.items.wands.ItemWandCasting; import java.lang.reflect.Field; import java.lang.reflect.Method; -//import WayofTime.alchemicalWizardry.common.EnergyItems; +import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; public class BloodWandUpdate implements IWandRodOnUpdate { Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]); - Method checkOwner; - Method syphon; - public BloodWandUpdate() - { - try - { - Class energyItems; - energyItems = Class.forName("WayofTime.alchemicalWizardry.common.items.EnergyItems"); - - checkOwner = energyItems.getDeclaredMethod("checkAndSetItemOwner", new Class[] {ItemStack.class, EntityPlayer.class}); - syphon = energyItems.getDeclaredMethod("syphonWhileInContainer", new Class[] {ItemStack.class, Integer.TYPE}); - } - catch(Exception e){ - e.printStackTrace(); } - } - public void onUpdate(ItemStack itemstack, EntityPlayer player) { if(Compat.bm && player.ticksExisted % 100 == 0) { try { - checkOwner.invoke(null, itemstack, player); + SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); int cost; if(((ItemWandCasting)itemstack.getItem()).getCap(itemstack).getTag().equals("alchemical")) @@ -52,7 +36,7 @@ public class BloodWandUpdate implements IWandRodOnUpdate { { if(player.capabilities.isCreativeMode) ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); - else if(((Boolean)(syphon.invoke(null, itemstack, cost))).booleanValue()) + else if(SoulNetworkHandler.syphonFromNetwork(itemstack, cost) > 0) ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); else if(syphonHealth(player)) { @@ -65,7 +49,7 @@ public class BloodWandUpdate implements IWandRodOnUpdate { } } - catch(Exception e) + catch(Throwable e) { return; }