Moved more spell stuff, created localized APISpellHelper, created RitualActivatedEvent

This commit is contained in:
WayofTime 2014-11-13 09:24:29 -05:00
parent 8c1396421a
commit f39db196ca
30 changed files with 284 additions and 121 deletions

View file

@ -3,6 +3,8 @@ package WayofTime.alchemicalWizardry;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool;
import WayofTime.alchemicalWizardry.common.book.ItemBMBook; import WayofTime.alchemicalWizardry.common.book.ItemBMBook;
import WayofTime.alchemicalWizardry.common.items.AWBaseItems; import WayofTime.alchemicalWizardry.common.items.AWBaseItems;
import WayofTime.alchemicalWizardry.common.items.ActivationCrystal; import WayofTime.alchemicalWizardry.common.items.ActivationCrystal;
@ -77,7 +79,6 @@ import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfTheFastMiner;
import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfWind; import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfWind;
import WayofTime.alchemicalWizardry.common.items.sigil.VoidSigil; import WayofTime.alchemicalWizardry.common.items.sigil.VoidSigil;
import WayofTime.alchemicalWizardry.common.items.sigil.WaterSigil; import WayofTime.alchemicalWizardry.common.items.sigil.WaterSigil;
import WayofTime.alchemicalWizardry.common.items.spell.ItemSpellMultiTool;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
/** /**
@ -282,6 +283,9 @@ public class ModItems
itemFluidSigil = new ItemFluidSigil().setUnlocalizedName("itemFluidSigil"); itemFluidSigil = new ItemFluidSigil().setUnlocalizedName("itemFluidSigil");
itemSeerSigil = new ItemSeerSigil().setUnlocalizedName("itemSeerSigil"); itemSeerSigil = new ItemSeerSigil().setUnlocalizedName("itemSeerSigil");
customTool = new ItemSpellMultiTool().setUnlocalizedName("multiTool"); customTool = new ItemSpellMultiTool().setUnlocalizedName("multiTool");
SpellParadigmTool.customTool = customTool;
itemCombinationalCatalyst = new CombinationalCatalyst().setUnlocalizedName("itemCombinationalCatalyst"); itemCombinationalCatalyst = new CombinationalCatalyst().setUnlocalizedName("itemCombinationalCatalyst");
itemAttunedCrystal = new ItemAttunedCrystal().setUnlocalizedName("itemAttunedCrystal"); itemAttunedCrystal = new ItemAttunedCrystal().setUnlocalizedName("itemAttunedCrystal");
itemTankSegmenter = new ItemTankSegmenter().setUnlocalizedName("itemTankSegmenter"); itemTankSegmenter = new ItemTankSegmenter().setUnlocalizedName("itemTankSegmenter");

View file

@ -0,0 +1,23 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import cpw.mods.fml.common.eventhandler.Cancelable;
@Cancelable
public class RitualActivatedEvent extends RitualEvent
{
public final EntityPlayer player;
public final ItemStack crystalStack;
public int crystalTier;
public RitualActivatedEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey, EntityPlayer player, ItemStack activationCrystal, int crystalTier)
{
super(mrs, ownerKey, ritualKey);
this.player = player;
this.crystalStack = activationCrystal;
this.crystalTier = crystalTier;
}
}

View file

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.api.event;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import cpw.mods.fml.common.eventhandler.Event;
public class RitualEvent extends Event
{
public final IMasterRitualStone mrs;
public String ownerKey;
public final String ritualKey;
public RitualEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey)
{
this.mrs = mrs;
this.ownerKey = ownerKey;
this.ritualKey = ritualKey;
}
}

View file

@ -1,9 +1,11 @@
package WayofTime.alchemicalWizardry.common.items.spell; package WayofTime.alchemicalWizardry.api.items;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import WayofTime.alchemicalWizardry.api.spell.SpellEffect;
import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@ -21,8 +23,10 @@ import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import java.util.*; import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import WayofTime.alchemicalWizardry.api.spell.SpellEffect;
import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool;
public class ItemSpellMultiTool extends Item public class ItemSpellMultiTool extends Item
{ {
@ -107,7 +111,7 @@ public class ItemSpellMultiTool extends Item
int hlvl = -1; int hlvl = -1;
float blockHardness = block.getBlockHardness(world, x, y, z); float blockHardness = block.getBlockHardness(world, x, y, z);
MovingObjectPosition mop = SpellHelper.raytraceFromEntity(world, player, true, 5.0D); MovingObjectPosition mop = APISpellHelper.raytraceFromEntity(world, player, true, 5.0D);
Block localBlock = world.getBlock(x, y, z); Block localBlock = world.getBlock(x, y, z);
int localMeta = world.getBlockMetadata(x, y, z); int localMeta = world.getBlockMetadata(x, y, z);
@ -153,14 +157,14 @@ public class ItemSpellMultiTool extends Item
if (blockHardness > 0f) if (blockHardness > 0f)
onBlockDestroyed(stack, world, localBlock, x, y, z, player); onBlockDestroyed(stack, world, localBlock, x, y, z, player);
List<ItemStack> items = SpellHelper.getItemsFromBlock(world, localBlock, x, y, z, localMeta, this.getSilkTouch(stack), this.getFortuneLevel(stack)); List<ItemStack> items = APISpellHelper.getItemsFromBlock(world, localBlock, x, y, z, localMeta, this.getSilkTouch(stack), this.getFortuneLevel(stack));
SpellParadigmTool parad = this.loadParadigmFromStack(stack); SpellParadigmTool parad = this.loadParadigmFromStack(stack);
List<ItemStack> newItems = parad.handleItemList(stack, items); List<ItemStack> newItems = parad.handleItemList(stack, items);
if (!world.isRemote) if (!world.isRemote)
{ {
SpellHelper.spawnItemListInWorld(newItems, world, x + 0.5f, y + 0.5f, z + 0.5f); APISpellHelper.spawnItemListInWorld(newItems, world, x + 0.5f, y + 0.5f, z + 0.5f);
} }
world.func_147479_m(x, y, z); world.func_147479_m(x, y, z);
@ -173,7 +177,7 @@ public class ItemSpellMultiTool extends Item
if (cost > 0) if (cost > 0)
{ {
EnergyItems.syphonAndDamageWhileInContainer(stack, player, cost); SoulNetworkHandler.syphonAndDamageFromNetwork(stack, player, cost);
} }
} else } else
{ {
@ -340,14 +344,14 @@ public class ItemSpellMultiTool extends Item
int cost = parad.onUpdate(toolStack, world, par3Entity, par4, par5); int cost = parad.onUpdate(toolStack, world, par3Entity, par4, par5);
if (par3Entity instanceof EntityPlayer && cost > 0) if (par3Entity instanceof EntityPlayer && cost > 0)
EnergyItems.syphonAndDamageWhileInContainer(toolStack, (EntityPlayer) par3Entity, cost); SoulNetworkHandler.syphonAndDamageFromNetwork(toolStack, (EntityPlayer) par3Entity, cost);
int duration = Math.max(this.getDuration(toolStack, world), 0); int duration = Math.max(this.getDuration(toolStack, world), 0);
if (duration <= 0 && par3Entity instanceof EntityPlayer) if (duration <= 0 && par3Entity instanceof EntityPlayer)
{ {
int banishCost = parad.onBanishTool(toolStack, world, par3Entity, par4, par5); int banishCost = parad.onBanishTool(toolStack, world, par3Entity, par4, par5);
EnergyItems.syphonAndDamageWhileInContainer(toolStack, (EntityPlayer) par3Entity, banishCost); SoulNetworkHandler.syphonAndDamageFromNetwork(toolStack, (EntityPlayer) par3Entity, banishCost);
((EntityPlayer) par3Entity).inventory.mainInventory[par4] = this.getContainedCrystal(toolStack); ((EntityPlayer) par3Entity).inventory.mainInventory[par4] = this.getContainedCrystal(toolStack);
} }
} }
@ -377,7 +381,7 @@ public class ItemSpellMultiTool extends Item
if (cost > 0) if (cost > 0)
{ {
EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, cost); SoulNetworkHandler.syphonAndDamageFromNetwork(par1ItemStack, par3EntityPlayer, cost);
} }
return par1ItemStack; return par1ItemStack;

View file

@ -121,6 +121,16 @@ public class SoulNetworkHandler
return false; return false;
} }
World world = player.worldObj;
if (world != null)
{
double posX = player.posX;
double posY = player.posY;
double posZ = player.posZ;
world.playSoundEffect((double) ((float) player.posX + 0.5F), (double) ((float) player.posY + 0.5F), (double) ((float) player.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
}
int amount = SoulNetworkHandler.syphonFromNetwork(ownerName, damageToBeDone); int amount = SoulNetworkHandler.syphonFromNetwork(ownerName, damageToBeDone);
hurtPlayer(player, damageToBeDone - amount); hurtPlayer(player, damageToBeDone - amount);
@ -355,4 +365,14 @@ public class SoulNetworkHandler
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80)); entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
} }
public static String getOwnerName(ItemStack item)
{
if (item.stackTagCompound == null)
{
item.setTagCompound(new NBTTagCompound());
}
return item.stackTagCompound.getString("ownerName");
}
} }

View file

@ -0,0 +1,101 @@
package WayofTime.alchemicalWizardry.api.spell;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
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.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class APISpellHelper
{
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range)
{
float f = 1.0F;
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f;
if (!world.isRemote && player instanceof EntityPlayer)
d1 += 1.62D;
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
double d3 = range;
if (player instanceof EntityPlayerMP)
{
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
}
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
}
public static List<ItemStack> getItemsFromBlock(World world, Block block, int x, int y, int z, int meta, boolean silkTouch, int fortune)
{
boolean canSilk = block.canSilkHarvest(world, null, x, y, z, meta);
if (canSilk && silkTouch)
{
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
ItemStack item = new ItemStack(block, 1, meta);
items.add(item);
return items;
} else
{
return block.getDrops(world, x, y, z, meta, fortune);
}
}
public static void spawnItemListInWorld(List<ItemStack> items, World world, float x, float y, float z)
{
for (ItemStack stack : items)
{
EntityItem itemEntity = new EntityItem(world, x, y, z, stack);
itemEntity.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(itemEntity);
}
}
public static String getNumeralForInt(int num)
{
switch (num)
{
case 1:
return "I";
case 2:
return "II";
case 3:
return "III";
case 4:
return "IV";
case 5:
return "V";
case 6:
return "VI";
case 7:
return "VII";
case 8:
return "VIII";
case 9:
return "IX";
case 10:
return "X";
default:
return "";
}
}
}

View file

@ -1,6 +1,6 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import WayofTime.alchemicalWizardry.common.items.spell.ItemSpellMultiTool; import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;

View file

@ -1,4 +1,4 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,13 +1,13 @@
package WayofTime.alchemicalWizardry.api.spell; package WayofTime.alchemicalWizardry.api.spell;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
public class SpellParadigmMelee extends SpellParadigm public class SpellParadigmMelee extends SpellParadigm
{ {
private List<IMeleeSpellEntityEffect> entityEffectList; private List<IMeleeSpellEntityEffect> entityEffectList;
@ -30,7 +30,7 @@ public class SpellParadigmMelee extends SpellParadigm
{ {
int cost = this.getTotalCost(); int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost)) if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost))
{ {
return; return;
} }

View file

@ -1,5 +1,6 @@
package WayofTime.alchemicalWizardry.api.spell; package WayofTime.alchemicalWizardry.api.spell;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.items.EnergyItems; import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -43,7 +44,7 @@ public class SpellParadigmProjectile extends SpellParadigm
{ {
int cost = this.getTotalCost(); int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost)) if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost))
{ {
return; return;
} }

View file

@ -1,13 +1,13 @@
package WayofTime.alchemicalWizardry.api.spell; package WayofTime.alchemicalWizardry.api.spell;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
public class SpellParadigmSelf extends SpellParadigm public class SpellParadigmSelf extends SpellParadigm
{ {
public List<ISelfSpellEffect> selfSpellEffectList; public List<ISelfSpellEffect> selfSpellEffectList;
@ -30,7 +30,7 @@ public class SpellParadigmSelf extends SpellParadigm
int cost = this.getTotalCost(); int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost)) if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost))
{ {
return; return;
} }

View file

@ -1,25 +1,23 @@
package WayofTime.alchemicalWizardry.api.spell; package WayofTime.alchemicalWizardry.api.spell;
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import WayofTime.alchemicalWizardry.common.items.spell.ItemSpellMultiTool;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool.*;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
public class SpellParadigmTool extends SpellParadigm public class SpellParadigmTool extends SpellParadigm
{ {
private List<ILeftClickEffect> leftClickEffectList; private List<ILeftClickEffect> leftClickEffectList;
@ -45,6 +43,8 @@ public class SpellParadigmTool extends SpellParadigm
private boolean silkTouch; private boolean silkTouch;
private int duration; private int duration;
public static Item customTool;
public SpellParadigmTool() public SpellParadigmTool()
{ {
@ -99,7 +99,7 @@ public class SpellParadigmTool extends SpellParadigm
int cost = this.getTotalCost(); int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(crystal, entityPlayer, cost)) if(!SoulNetworkHandler.syphonAndDamageFromNetwork(crystal, entityPlayer, cost))
{ {
return; return;
} }
@ -117,9 +117,9 @@ public class SpellParadigmTool extends SpellParadigm
*/ */
public ItemStack prepareTool(ItemStack crystalStack, World world) public ItemStack prepareTool(ItemStack crystalStack, World world)
{ {
ItemStack toolStack = new ItemStack(ModItems.customTool, 1); ItemStack toolStack = new ItemStack(customTool, 1);
ItemSpellMultiTool itemTool = (ItemSpellMultiTool) ModItems.customTool; ItemSpellMultiTool itemTool = (ItemSpellMultiTool) customTool;
itemTool.setItemAttack(toolStack, this.composeMaxDamageFromHash()); itemTool.setItemAttack(toolStack, this.composeMaxDamageFromHash());
@ -148,12 +148,12 @@ public class SpellParadigmTool extends SpellParadigm
if (this.getSilkTouch()) if (this.getSilkTouch())
{ {
this.addToolString("SilkTouch", "Silk Touch" + " " + SpellHelper.getNumeralForInt(1)); this.addToolString("SilkTouch", "Silk Touch" + " " + APISpellHelper.getNumeralForInt(1));
} }
if (this.getFortuneLevel() > 0) if (this.getFortuneLevel() > 0)
{ {
this.addToolString("Fortune", "Fortune" + " " + SpellHelper.getNumeralForInt(this.getFortuneLevel())); this.addToolString("Fortune", "Fortune" + " " + APISpellHelper.getNumeralForInt(this.getFortuneLevel()));
} }
itemTool.setCritChance(toolStack, this.getCritChance() / 100f); itemTool.setCritChance(toolStack, this.getCritChance() / 100f);
@ -175,7 +175,7 @@ public class SpellParadigmTool extends SpellParadigm
itemTool.setDuration(toolStack, world, this.duration); itemTool.setDuration(toolStack, world, this.duration);
itemTool.loadParadigmIntoStack(toolStack, this.bufferedEffectList); itemTool.loadParadigmIntoStack(toolStack, this.bufferedEffectList);
EnergyItems.checkAndSetItemOwner(toolStack, EnergyItems.getOwnerName(crystalStack)); SoulNetworkHandler.checkAndSetItemOwner(toolStack, SoulNetworkHandler.getOwnerName(crystalStack));
itemTool.setContainedCrystal(toolStack, crystalStack); itemTool.setContainedCrystal(toolStack, crystalStack);

View file

@ -81,8 +81,8 @@ public class BlockMasterStone extends BlockContainer
} }
ActivationCrystal acItem = (ActivationCrystal) item; ActivationCrystal acItem = (ActivationCrystal) item;
tileEntity.setOwner(acItem.getOwnerName(playerItem)); // tileEntity.setOwner(acItem.getOwnerName(playerItem));
tileEntity.activateRitual(world, acItem.getCrystalLevel(playerItem), player); tileEntity.activateRitual(world, acItem.getCrystalLevel(playerItem), playerItem, player, acItem.getOwnerName(playerItem));
world.markBlockForUpdate(x, y, z); world.markBlockForUpdate(x, y, z);
return true; return true;
} }

View file

@ -4,6 +4,7 @@ import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.IAlchemyGoggles; import WayofTime.alchemicalWizardry.api.alchemy.energy.IAlchemyGoggles;
import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator; import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler; import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import WayofTime.alchemicalWizardry.common.NewPacketHandler; import WayofTime.alchemicalWizardry.common.NewPacketHandler;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -364,56 +365,17 @@ public class SpellHelper
public static List<ItemStack> getItemsFromBlock(World world, Block block, int x, int y, int z, int meta, boolean silkTouch, int fortune) public static List<ItemStack> getItemsFromBlock(World world, Block block, int x, int y, int z, int meta, boolean silkTouch, int fortune)
{ {
boolean canSilk = block.canSilkHarvest(world, null, x, y, z, meta); return APISpellHelper.getItemsFromBlock(world, block, x, y, z, meta, silkTouch, fortune);
if (canSilk && silkTouch)
{
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
ItemStack item = new ItemStack(block, 1, meta);
items.add(item);
return items;
} else
{
return block.getDrops(world, x, y, z, meta, fortune);
}
} }
public static void spawnItemListInWorld(List<ItemStack> items, World world, float x, float y, float z) public static void spawnItemListInWorld(List<ItemStack> items, World world, float x, float y, float z)
{ {
for (ItemStack stack : items) APISpellHelper.spawnItemListInWorld(items, world, x, y, z);
{
EntityItem itemEntity = new EntityItem(world, x, y, z, stack);
itemEntity.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(itemEntity);
}
} }
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range)
{ {
float f = 1.0F; return APISpellHelper.raytraceFromEntity(world, player, par3, range);
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f;
if (!world.isRemote && player instanceof EntityPlayer)
d1 += 1.62D;
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
double d3 = range;
if (player instanceof EntityPlayerMP)
{
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
}
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
} }
public static String getNumeralForInt(int num) public static String getNumeralForInt(int num)

View file

@ -1,6 +1,6 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.earth; package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.earth;
import WayofTime.alchemicalWizardry.common.items.spell.ItemSpellMultiTool; import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool.DigAreaEffect; import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool.DigAreaEffect;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,7 +1,8 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool;
import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import WayofTime.alchemicalWizardry.api.spell.IDigAreaEffect;
import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool; import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool;
import WayofTime.alchemicalWizardry.common.items.spell.ItemSpellMultiTool;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View file

@ -1,7 +1,7 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool;
import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.items.spell.ItemSpellMultiTool; import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;

View file

@ -4,6 +4,8 @@ import net.minecraft.item.ItemStack;
import java.util.List; import java.util.List;
import WayofTime.alchemicalWizardry.api.spell.IItemManipulator;
public abstract class ItemManipulator implements IItemManipulator public abstract class ItemManipulator implements IItemManipulator
{ {
protected int powerUpgrades; protected int powerUpgrades;

View file

@ -1,5 +1,6 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool;
import WayofTime.alchemicalWizardry.api.spell.ILeftClickEffect;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,5 +1,7 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool;
import WayofTime.alchemicalWizardry.api.spell.IOnBreakBlock;
public abstract class OnBreakBlockEffect implements IOnBreakBlock public abstract class OnBreakBlockEffect implements IOnBreakBlock
{ {
protected int powerUpgrades; protected int powerUpgrades;

View file

@ -1,5 +1,7 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool;
import WayofTime.alchemicalWizardry.api.spell.IRightClickEffect;
public abstract class RightClickEffect implements IRightClickEffect public abstract class RightClickEffect implements IRightClickEffect
{ {
protected int powerUpgrades; protected int powerUpgrades;

View file

@ -1,5 +1,7 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool; package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.tool;
import WayofTime.alchemicalWizardry.api.spell.IOnSummonTool;
public abstract class SummonToolEffect implements IOnSummonTool public abstract class SummonToolEffect implements IOnSummonTool
{ {
protected int powerUpgrades; protected int powerUpgrades;

View file

@ -1,29 +1,35 @@
package WayofTime.alchemicalWizardry.common.tileEntity; package WayofTime.alchemicalWizardry.common.tileEntity;
import WayofTime.alchemicalWizardry.api.alchemy.energy.*; import java.util.HashMap;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone; import java.util.Map;
import WayofTime.alchemicalWizardry.api.rituals.RitualBreakMethod; import java.util.Map.Entry;
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork; import cpw.mods.fml.common.eventhandler.Event;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import java.util.HashMap; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer;
import java.util.Map; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo;
import java.util.Map.Entry; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
import WayofTime.alchemicalWizardry.api.event.RitualActivatedEvent;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualBreakMethod;
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class TEMasterStone extends TileEntity implements IMasterRitualStone public class TEMasterStone extends TileEntity implements IMasterRitualStone
{ {
@ -177,7 +183,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
tag.setTag("customRitualTag", customRitualTag); tag.setTag("customRitualTag", customRitualTag);
} }
public void activateRitual(World world, int crystalLevel, EntityPlayer player) public void activateRitual(World world, int crystalLevel, ItemStack activationCrystal, EntityPlayer player, String crystalOwner)
{ {
if (world.isRemote) if (world.isRemote)
{ {
@ -192,7 +198,20 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
return; return;
} }
boolean testLevel = Rituals.canCrystalActivate(testRitual, crystalLevel); //TODO
RitualActivatedEvent event = new RitualActivatedEvent(this, crystalOwner, testRitual, player, activationCrystal, crystalLevel);
if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
{
player.addChatMessage(new ChatComponentText("Something stopped you in your tracks..."));
return;
}
int eventCrystalTier = event.crystalTier;
String eventRitualKey = event.ritualKey;
String eventOwnerKey = event.ownerKey;
boolean testLevel = Rituals.canCrystalActivate(eventRitualKey, eventCrystalTier);
if (!testLevel) if (!testLevel)
{ {
@ -201,7 +220,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
return; return;
} }
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner); int currentEssence = SoulNetworkHandler.getCurrentEssence(eventOwnerKey);
if (currentEssence < Rituals.getCostForActivation(testRitual)) if (currentEssence < Rituals.getCostForActivation(testRitual))
{ {
@ -219,7 +238,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
return; return;
} else } else
{ {
int drain = SoulNetworkHandler.syphonFromNetwork(owner, Rituals.getCostForActivation(testRitual)); int drain = SoulNetworkHandler.syphonFromNetwork(eventOwnerKey, Rituals.getCostForActivation(testRitual));
if(drain > 0) if(drain > 0)
{ {
@ -242,6 +261,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
{ {
Rituals.onRitualBroken(this, this.currentRitualString, RitualBreakMethod.ACTIVATE); Rituals.onRitualBroken(this, this.currentRitualString, RitualBreakMethod.ACTIVATE);
} }
this.setOwner(eventOwnerKey);
cooldown = Rituals.getInitialCooldown(testRitual); cooldown = Rituals.getInitialCooldown(testRitual);
var1 = 0; var1 = 0;
currentRitualString = testRitual; currentRitualString = testRitual;