180 lines
6.7 KiB
Java
180 lines
6.7 KiB
Java
package WayofTime.alchemicalWizardry.common.spell.simple;
|
|
|
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
|
import WayofTime.alchemicalWizardry.common.PacketHandler;
|
|
import WayofTime.alchemicalWizardry.common.entity.projectile.WaterProjectile;
|
|
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.potion.PotionEffect;
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
import net.minecraft.util.DamageSource;
|
|
import net.minecraft.world.World;
|
|
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
public class SpellWateryGrave extends HomSpell
|
|
{
|
|
Random itemRand = new Random();
|
|
|
|
public SpellWateryGrave()
|
|
{
|
|
super();
|
|
this.setEnergies(250, 350, 500, 750);
|
|
//this.setCreativeTab(CreativeTabs.tabMisc);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack onOffensiveRangedRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
|
{
|
|
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
|
|
|
if (par3EntityPlayer.isSneaking())
|
|
{
|
|
return par1ItemStack;
|
|
}
|
|
|
|
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
|
{
|
|
EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveRangedEnergy());
|
|
}
|
|
|
|
par2World.spawnEntityInWorld(new WaterProjectile(par2World, par3EntityPlayer, 8));
|
|
par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
|
return par1ItemStack;
|
|
}
|
|
|
|
@Override
|
|
public ItemStack onOffensiveMeleeRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
|
{
|
|
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
|
|
|
if (par3EntityPlayer.isSneaking())
|
|
{
|
|
return par1ItemStack;
|
|
}
|
|
|
|
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
|
{
|
|
EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getOffensiveMeleeEnergy());
|
|
}
|
|
|
|
if (!par2World.isRemote)
|
|
{
|
|
for (int i = -1; i <= 1; i++)
|
|
{
|
|
for (int j = -1; j <= 1; j++)
|
|
{
|
|
par2World.spawnEntityInWorld(new WaterProjectile(par2World, par3EntityPlayer, 3, 3, par3EntityPlayer.posX, par3EntityPlayer.posY + par3EntityPlayer.getEyeHeight(), par3EntityPlayer.posZ, par3EntityPlayer.rotationYaw + i * 10F, par3EntityPlayer.rotationPitch + j * 5F));
|
|
}
|
|
}
|
|
}
|
|
|
|
return par1ItemStack;
|
|
}
|
|
|
|
@Override
|
|
public ItemStack onDefensiveRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
|
{
|
|
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
|
|
|
if (par3EntityPlayer.isSneaking())
|
|
{
|
|
return par1ItemStack;
|
|
}
|
|
|
|
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
|
{
|
|
EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getDefensiveEnergy());
|
|
}
|
|
|
|
int d0 = 3;
|
|
AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double) par3EntityPlayer.posX, (double) par3EntityPlayer.posY, (double) par3EntityPlayer.posZ, (double) (par3EntityPlayer.posX + 1), (double) (par3EntityPlayer.posY + 2), (double) (par3EntityPlayer.posZ + 1)).expand(d0, d0, d0);
|
|
//axisalignedbb.maxY = (double)this.worldObj.getHeight();
|
|
List list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
|
|
Iterator iterator = list.iterator();
|
|
|
|
while (iterator.hasNext())
|
|
{
|
|
EntityLivingBase entityLiving = (EntityLivingBase) iterator.next();
|
|
|
|
if (entityLiving instanceof EntityPlayer)
|
|
{
|
|
if (entityLiving.getEntityName().equals(par3EntityPlayer.getEntityName()))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
int x = 1;
|
|
|
|
if (entityLiving.isImmuneToFire())
|
|
{
|
|
x = 2;
|
|
}
|
|
|
|
entityLiving.attackEntityFrom(DamageSource.drown, 2 * x);
|
|
entityLiving.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 100, x - 1));
|
|
}
|
|
|
|
double xCoord = par3EntityPlayer.posX;
|
|
double yCoord = par3EntityPlayer.posY;
|
|
double zCoord = par3EntityPlayer.posZ;
|
|
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 30, par2World.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpell", xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 3, 0.0F, 0.410F, 1.0F));
|
|
}
|
|
|
|
return par1ItemStack;
|
|
}
|
|
|
|
@Override
|
|
public ItemStack onEnvironmentalRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
|
{
|
|
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
|
|
|
if (par3EntityPlayer.isSneaking())
|
|
{
|
|
return par1ItemStack;
|
|
}
|
|
|
|
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
|
{
|
|
EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, this.getEnvironmentalEnergy());
|
|
}
|
|
|
|
int range = 2;
|
|
|
|
if (!par2World.isRemote)
|
|
{
|
|
for (int i = -range; i <= range; i++)
|
|
{
|
|
for (int j = -range; j <= range; j++)
|
|
{
|
|
if (par2World.isAirBlock((int) par3EntityPlayer.posX + i, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ + j))
|
|
{
|
|
par2World.setBlock((int) par3EntityPlayer.posX + i, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ + j, Block.waterStill.blockID);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
double xCoord = par3EntityPlayer.posX;
|
|
double yCoord = par3EntityPlayer.posY;
|
|
double zCoord = par3EntityPlayer.posZ;
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
{
|
|
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 30, par2World.provider.dimensionId, PacketHandler.getCustomParticlePacket("mobSpell", xCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, yCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, zCoord + (itemRand.nextFloat() - itemRand.nextFloat()) * 2, 0.0F, 0.410F, 1.0F));
|
|
}
|
|
|
|
return par1ItemStack;
|
|
}
|
|
}
|