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

@ -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

@ -0,0 +1,12 @@
package WayofTime.alchemicalWizardry.api.spell;
import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public interface IDigAreaEffect
{
public abstract int digSurroundingArea(ItemStack container, World world, EntityPlayer player, MovingObjectPosition blockPos, String usedToolClass, float blockHardness, int harvestLvl, ItemSpellMultiTool itemTool);
}

View file

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.item.ItemStack;
import java.util.List;
public interface IItemManipulator
{
public List<ItemStack> handleItemsOnBlockBroken(ItemStack toolStack, List<ItemStack> itemList);
}

View file

@ -0,0 +1,9 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface ILeftClickEffect
{
public abstract int onLeftClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder);
}

View file

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IOnBanishTool
{
public abstract int onBanishTool(ItemStack toolStack, World world, Entity entity, int invSlot, boolean inHand);
}

View file

@ -0,0 +1,12 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IOnBreakBlock
{
public abstract int onBlockBroken(ItemStack container, World world, EntityPlayer player, Block block, int meta, int x, int y, int z, ForgeDirection sideBroken);
}

View file

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IOnSummonTool
{
public abstract int onSummonTool(ItemStack toolStack, World world, Entity entity);
}

View file

@ -0,0 +1,15 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public interface IRightClickEffect
{
//public abstract int onRightClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder);
public abstract int onRightClickBlock(ItemStack stack, EntityLivingBase weilder, World world, MovingObjectPosition mop);
public abstract int onRightClickAir(ItemStack stack, EntityLivingBase weilder);
}

View file

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
public interface ISpecialDamageEffect
{
public float getDamageForEntity(Entity entity);
public String getKey();
}

View file

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IToolUpdateEffect
{
public abstract int onUpdate(ItemStack toolStack, World world, Entity par3Entity, int invSlot, boolean inHand);
}

View file

@ -1,13 +1,13 @@
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.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
{
private List<IMeleeSpellEntityEffect> entityEffectList;
@ -30,7 +30,7 @@ public class SpellParadigmMelee extends SpellParadigm
{
int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost))
if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost))
{
return;
}

View file

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

View file

@ -1,13 +1,13 @@
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.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 List<ISelfSpellEffect> selfSpellEffectList;
@ -30,7 +30,7 @@ public class SpellParadigmSelf extends SpellParadigm
int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost))
if(!SoulNetworkHandler.syphonAndDamageFromNetwork(itemStack, entityPlayer, cost))
{
return;
}

View file

@ -1,25 +1,23 @@
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.LinkedList;
import java.util.List;
import java.util.Map.Entry;
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
{
private List<ILeftClickEffect> leftClickEffectList;
@ -45,6 +43,8 @@ public class SpellParadigmTool extends SpellParadigm
private boolean silkTouch;
private int duration;
public static Item customTool;
public SpellParadigmTool()
{
@ -99,7 +99,7 @@ public class SpellParadigmTool extends SpellParadigm
int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(crystal, entityPlayer, cost))
if(!SoulNetworkHandler.syphonAndDamageFromNetwork(crystal, entityPlayer, cost))
{
return;
}
@ -117,9 +117,9 @@ public class SpellParadigmTool extends SpellParadigm
*/
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());
@ -148,12 +148,12 @@ public class SpellParadigmTool extends SpellParadigm
if (this.getSilkTouch())
{
this.addToolString("SilkTouch", "Silk Touch" + " " + SpellHelper.getNumeralForInt(1));
this.addToolString("SilkTouch", "Silk Touch" + " " + APISpellHelper.getNumeralForInt(1));
}
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);
@ -175,7 +175,7 @@ public class SpellParadigmTool extends SpellParadigm
itemTool.setDuration(toolStack, world, this.duration);
itemTool.loadParadigmIntoStack(toolStack, this.bufferedEffectList);
EnergyItems.checkAndSetItemOwner(toolStack, EnergyItems.getOwnerName(crystalStack));
SoulNetworkHandler.checkAndSetItemOwner(toolStack, SoulNetworkHandler.getOwnerName(crystalStack));
itemTool.setContainedCrystal(toolStack, crystalStack);