More work on the implementation of events

This commit is contained in:
WayofTime 2014-11-07 13:45:02 -05:00
parent dd3a093825
commit 39b4243a82
27 changed files with 217 additions and 259 deletions

View file

@ -0,0 +1,20 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.eventhandler.Event;
public class ItemBindEvent extends Event
{
public final EntityPlayer player;
public String key;
public ItemStack itemStack;
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack)
{
super();
this.player = player;
this.key = key;
this.itemStack = itemStack;
}
}

View file

@ -1,6 +1,8 @@
package WayofTime.alchemicalWizardry.api.rituals;
import net.minecraft.world.World;
public interface IRitualStone
{
public int getRuneType(World world, int x, int y, int z, int meta);
}

View file

@ -35,6 +35,16 @@ public class RitualComponent
{
return this.z;
}
public int getX(int direction)
{
return this.x;
}
public int getZ(int direction)
{
return this.z;
}
public int getStoneType()
{

View file

@ -158,7 +158,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ())) != rc.getStoneType())
{
return false;
}
@ -176,7 +176,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX())) != rc.getStoneType())
{
return false;
}
@ -194,7 +194,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ())) != rc.getStoneType())
{
return false;
}
@ -212,7 +212,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX())) != rc.getStoneType())
{
return false;
}

View file

@ -11,6 +11,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import WayofTime.alchemicalWizardry.api.event.ItemBindEvent;
import WayofTime.alchemicalWizardry.api.event.ItemDrainNetworkEvent;
import com.mojang.authlib.GameProfile;
@ -286,7 +287,12 @@ public class SoulNetworkHandler
if (item.stackTagCompound.getString("ownerName").equals(""))
{
item.stackTagCompound.setString("ownerName", SoulNetworkHandler.getUsername(player));
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
if(!MinecraftForge.EVENT_BUS.post(event))
{
item.stackTagCompound.setString("ownerName", event.key);
}
}
}

View file

@ -118,4 +118,10 @@ public class RitualStone extends Block implements IRitualStone
return blankIcon;
}
}
@Override
public int getRuneType(World world, int x, int y, int z, int meta)
{
return meta;
}
}

View file

@ -74,7 +74,10 @@ public class BlankSpell extends EnergyItems
if (homHeart.canCastSpell(par1ItemStack, par2World, par3EntityPlayer))
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, homHeart.castSpell(par1ItemStack, par2World, par3EntityPlayer));
if(EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, homHeart.getCostForSpell()))
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, homHeart.castSpell(par1ItemStack, par2World, par3EntityPlayer));
}
} else
{
return par1ItemStack;

View file

@ -1,87 +0,0 @@
package WayofTime.alchemicalWizardry.common.items;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.util.List;
public class BloodboundSword extends EnergyItems
{
private float weaponDamage;
private NBTTagCompound data;
public BloodboundSword(int id)
{
super();
this.maxStackSize = 1;
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
setEnergyUsed(100);
setFull3D();
weaponDamage = 10.0F;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergySword");
}
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
{
if (par3EntityLivingBase instanceof EntityPlayer)
{
EnergyItems.checkAndSetItemOwner(par1ItemStack, (EntityPlayer) par3EntityLivingBase);
if (!this.syphonBatteries(par1ItemStack, (EntityPlayer) par3EntityLivingBase, this.getEnergyUsed()))
{
}
}
return true;
}
public float func_82803_g()
{
return 4.0F;
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Caution: may cause");
par3List.add("a bad day...");
if (!(par1ItemStack.stackTagCompound == null))
{
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
}
}
@Override
public float getDigSpeed(ItemStack par1ItemStack, Block par2Block, int meta)
{
if (par2Block.equals(Blocks.web))
{
return 15.0F;
} else
{
Material material = par2Block.getMaterial();
return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
}
}
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
return false;
}
}

View file

@ -375,8 +375,10 @@ public class BoundArmour extends ItemArmor implements IAlchemyGoggles, ISpecialA
if (!player.capabilities.isCreativeMode)
{
if( EnergyItems.syphonBatteries(itemStack, player, itemStack.getItemDamage() * 75))
if(EnergyItems.syphonBatteries(itemStack, player, itemStack.getItemDamage() * 75))
{
itemStack.setItemDamage(0);
}
}
}

View file

@ -85,7 +85,10 @@ public class EnergyBazooka extends EnergyItems
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
this.syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed());
if(!this.syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed()))
{
return par1ItemStack;
}
}
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
@ -131,7 +134,10 @@ public class EnergyBazooka extends EnergyItems
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50);
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50))
{
this.setActivated(par1ItemStack, false);
}
}
}

View file

@ -85,7 +85,10 @@ public class EnergyBlast extends EnergyItems
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
this.syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed());
if(!this.syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed()))
{
return par1ItemStack;
}
}
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
@ -123,7 +126,10 @@ public class EnergyBlast extends EnergyItems
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50);
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50))
{
this.setActivated(par1ItemStack, false);
}
}
}

View file

@ -185,17 +185,7 @@ public class EnergyItems extends Item implements IBindable
//Global static methods
public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player)
{
if (item.stackTagCompound == null)
{
item.setTagCompound(new NBTTagCompound());
}
if (item.stackTagCompound.getString("ownerName").equals(""))
{
item.stackTagCompound.setString("ownerName", SoulNetworkHandler.getUsername(player));
}
initializePlayer(player);
SoulNetworkHandler.checkAndSetItemOwner(item, player);
}
public static void setItemOwner(ItemStack item, String ownerName)
@ -221,16 +211,6 @@ public class EnergyItems extends Item implements IBindable
}
}
public static void initializePlayer(EntityPlayer player)
{
NBTTagCompound tag = player.getEntityData();
if (tag.getInteger("currentEssence") == 0)
{
tag.setInteger("currentEssence", 0);
}
}
public static String getOwnerName(ItemStack item)
{
if (item.stackTagCompound == null)

View file

@ -90,6 +90,7 @@ public class EnergySword extends ItemSword
if (!EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3EntityLivingBase, this.getEnergyUsed()))
{
return false;
}
}
@ -142,7 +143,10 @@ public class EnergySword extends ItemSword
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50);
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50))
{
this.setActivated(par1ItemStack, false);
}
}
}

View file

@ -135,6 +135,8 @@ public class ItemRitualDiviner extends EnergyItems
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
int direction = 1;
EnergyItems.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer);
ItemStack[] playerInventory = par2EntityPlayer.inventory.mainInventory;
TileEntity tileEntity = par3World.getTileEntity(par4, par5, par6);
@ -166,7 +168,7 @@ public class ItemRitualDiviner extends EnergyItems
for (RitualComponent rc : ritualList)
{
if (par3World.isAirBlock(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ()))
if (par3World.isAirBlock(par4 + rc.getX(direction), par5 + rc.getY(), par6 + rc.getZ(direction)))
{
if (playerInvRitualStoneLocation >= 0)
{
@ -181,36 +183,41 @@ public class ItemRitualDiviner extends EnergyItems
par2EntityPlayer.inventory.decrStackSize(playerInvRitualStoneLocation, 1);
}
par3World.setBlock(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ(), ModBlocks.ritualStone, rc.getStoneType(), 3);
if (par3World.isRemote)
if(EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed()))
{
par3World.playAuxSFX(2005, par4, par5 + 1, par6, 0);
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
return true;
par3World.setBlock(par4 + rc.getX(direction), par5 + rc.getY(), par6 + rc.getZ(direction), ModBlocks.ritualStone, rc.getStoneType(), 3);
if (par3World.isRemote)
{
par3World.playAuxSFX(2005, par4, par5 + 1, par6, 0);
return true;
}
}
return true;
}
} else
{
Block block = par3World.getBlock(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ());
Block block = par3World.getBlock(par4 + rc.getX(direction), par5 + rc.getY(), par6 + rc.getZ(direction));
if (block == ModBlocks.ritualStone)
{
int metadata = par3World.getBlockMetadata(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ());
int metadata = par3World.getBlockMetadata(par4 + rc.getX(direction), par5 + rc.getY(), par6 + rc.getZ(direction));
if (metadata != rc.getStoneType())
{
if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(par1ItemStack))
{
par3World.playAuxSFX(200, par4, par5 + 1, par6, 0);
return true;
}
par3World.setBlockMetadataWithNotify(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ(), rc.getStoneType(), 3);
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
return true;
if(EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed()))
{
if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(par1ItemStack))
{
par3World.playAuxSFX(200, par4, par5 + 1, par6, 0);
return true;
}
par3World.setBlockMetadataWithNotify(par4 + rc.getX(direction), par5 + rc.getY(), par6 + rc.getZ(direction), rc.getStoneType(), 3);
return true;
}
}
} else
{

View file

@ -40,7 +40,6 @@ public class ScribeTool extends EnergyItems
if (par1ItemStack.getItemDamage() > 0)
{
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1);
syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed());
}
return par1ItemStack;

View file

@ -50,7 +50,10 @@ public class ItemBloodLightSigil extends EnergyItems implements IHolding
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
EnergyItems.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer);
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
if(!EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed()))
{
return true;
}
if (par3World.isRemote)
{
@ -105,7 +108,10 @@ public class ItemBloodLightSigil extends EnergyItems implements IHolding
par1ItemStack.setTagCompound(new NBTTagCompound());
}
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed() * 5);
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed() * 5))
{
return par1ItemStack;
}
if (!par2World.isRemote)
{
@ -114,30 +120,4 @@ public class ItemBloodLightSigil extends EnergyItems implements IHolding
return par1ItemStack;
}
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
{
if (!(par3Entity instanceof EntityPlayer))
{
return;
}
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
if (par1ItemStack.stackTagCompound == null)
{
par1ItemStack.setTagCompound(new NBTTagCompound());
}
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
{
if (par2World.getWorldTime() % tickDelay == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
{
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3Entity, getEnergyUsed());
}
}
return;
}
}

View file

@ -120,6 +120,7 @@ public class ItemSigilOfEnderSeverance extends EnergyItems implements IHolding
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
tag.setBoolean("isActive", false);
}
}
} else
@ -160,7 +161,10 @@ public class ItemSigilOfEnderSeverance extends EnergyItems implements IHolding
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
par1ItemStack.stackTagCompound.setBoolean("isActive", false);
}
}
}

View file

@ -126,7 +126,10 @@ public class ItemSigilOfSupression extends EnergyItems implements ArmourUpgrade
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
tag.setBoolean("isActive", false);
}
}
} else
{
@ -201,8 +204,10 @@ public class ItemSigilOfSupression extends EnergyItems implements ArmourUpgrade
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
par1ItemStack.stackTagCompound.setBoolean("isActive", false);
}
}
}

View file

@ -110,15 +110,9 @@ public class LavaSigil extends ItemBucket implements ArmourUpgrade
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, false);
if (amount > 0)
if (amount > 0 && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true);
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
}
}
}
return par1ItemStack;
@ -158,17 +152,9 @@ public class LavaSigil extends ItemBucket implements ArmourUpgrade
return par1ItemStack;
}
if (this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !par3EntityPlayer.capabilities.isCreativeMode)
if(this.canPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
}
} else
{
return par1ItemStack;
}
this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k);
}
}
@ -193,6 +179,20 @@ public class LavaSigil extends ItemBucket implements ArmourUpgrade
return true;
}
}
public boolean canPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
{
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
{
return false;
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.lava || par1World.getBlock(par8, par9, par10) == Blocks.flowing_lava) && par1World.getBlockMetadata(par8, par9, par10) == 0)
{
return false;
} else
{
return true;
}
}
protected void setEnergyUsed(int par1int)
{

View file

@ -117,15 +117,9 @@ public class VoidSigil extends ItemBucket implements ArmourUpgrade
{
FluidStack amount = ((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), 1000, false);
if (amount != null && amount.amount > 0)
if (amount != null && amount.amount > 0 && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), 1000, true);
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
}
}
}
return par1ItemStack;
@ -138,19 +132,9 @@ public class VoidSigil extends ItemBucket implements ArmourUpgrade
return par1ItemStack;
}
if (par2World.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid)
if (par2World.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
par2World.setBlockToAir(i, j, k);
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
}
} else
{
return par1ItemStack;
}
}
}
}

View file

@ -113,15 +113,9 @@ public class WaterSigil extends ItemBucket implements ArmourUpgrade
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, false);
if (amount > 0)
if (amount > 0 && EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true);
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
}
}
}
return par1ItemStack;
@ -163,17 +157,9 @@ public class WaterSigil extends ItemBucket implements ArmourUpgrade
return par1ItemStack;
}
if (this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !par3EntityPlayer.capabilities.isCreativeMode)
if(this.canPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
}
} else
{
return par1ItemStack;
}
this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k);
}
}
}
@ -211,6 +197,20 @@ public class WaterSigil extends ItemBucket implements ArmourUpgrade
return true;
}
}
public boolean canPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
{
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
{
return false;
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.water || par1World.getBlock(par8, par9, par10) == Blocks.flowing_water) && par1World.getBlockMetadata(par8, par9, par10) == 0)
{
return false;
} else
{
return true;
}
}
protected void setEnergyUsed(int par1int)
{

View file

@ -31,6 +31,13 @@ public class SpellParadigmMelee extends SpellParadigm
@Override
public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack)
{
int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost))
{
return;
}
for (IMeleeSpellEntityEffect effect : entityEffectList)
{
effect.onEntityImpact(world, entityPlayer);
@ -40,10 +47,6 @@ public class SpellParadigmMelee extends SpellParadigm
{
effect.onWorldEffect(world, entityPlayer);
}
int cost = this.getTotalCost();
EnergyItems.syphonBatteries(itemStack, entityPlayer, cost);
}
public void addEntityEffect(IMeleeSpellEntityEffect eff)

View file

@ -45,12 +45,16 @@ public class SpellParadigmProjectile extends SpellParadigm
@Override
public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack)
{
int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost))
{
return;
}
EntitySpellProjectile proj = new EntitySpellProjectile(world, entityPlayer);
this.prepareProjectile(proj);
world.spawnEntityInWorld(proj);
int cost = this.getTotalCost();
EnergyItems.syphonBatteries(itemStack, entityPlayer, cost);
}
public static SpellParadigmProjectile getParadigmForEffectArray(List<SpellEffect> effectList)

View file

@ -29,15 +29,18 @@ public class SpellParadigmSelf extends SpellParadigm
public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack)
{
this.applyAllSpellEffects();
int cost = this.getTotalCost();
if(!EnergyItems.syphonBatteries(itemStack, entityPlayer, cost))
{
return;
}
for (ISelfSpellEffect eff : selfSpellEffectList)
{
eff.onSelfUse(world, entityPlayer);
}
int cost = this.getTotalCost();
EnergyItems.syphonBatteries(itemStack, entityPlayer, cost);
}
public void addSelfSpellEffect(ISelfSpellEffect eff)

View file

@ -100,8 +100,11 @@ public class SpellParadigmTool extends SpellParadigm
}
int cost = this.getTotalCost();
EnergyItems.syphonBatteries(crystal, entityPlayer, cost);
if(!EnergyItems.syphonBatteries(crystal, entityPlayer, cost))
{
return;
}
ItemStack toolStack = this.prepareTool(crystal, world);

View file

@ -22,8 +22,6 @@ public abstract class HomSpell implements ISimpleSpell
@Override
public abstract ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer);
;
@Override
public abstract ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer);

View file

@ -16,6 +16,31 @@ public class TEHomHeart extends TileEntity
{
return true;
}
public int getCostForSpell()
{
HomSpell spell = getSpell();
if (spell != null)
{
switch (getModifiedParadigm())
{
case 0:
return spell.getOffensiveRangedEnergy();
case 1:
return spell.getOffensiveMeleeEnergy();
case 2:
return spell.getDefensiveEnergy();
case 3:
return spell.getEnvironmentalEnergy();
}
}
return 0;
}
public int castSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
@ -27,19 +52,19 @@ public class TEHomHeart extends TileEntity
{
case 0:
spell.onOffensiveRangedRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
return spell.getOffensiveRangedEnergy();
case 1:
spell.onOffensiveMeleeRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
return spell.getOffensiveMeleeEnergy();
case 2:
spell.onDefensiveRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
return spell.getDefensiveEnergy();
case 3:
spell.onEnvironmentalRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
return spell.getEnvironmentalEnergy();
}
}
@ -122,21 +147,6 @@ public class TEHomHeart extends TileEntity
public int getModifiedParadigm()
{
//TODO change so that it works with a Tile Entity for a custom head or whatnot
Block block = worldObj.getBlock(xCoord, yCoord + 1, zCoord);
if (block == Blocks.glowstone)
{
return 0;
} else if (block == Blocks.redstone_block)
{
return 1;
} else if (block == Blocks.anvil)
{
return 2;
} else if (block == Blocks.glass)
{
return 3;
}
TileEntity tileEntity = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);