BloodMagic/1.7.10/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectEllipsoid.java

157 lines
7.1 KiB
Java
Raw Normal View History

2014-07-31 23:45:40 +00:00
package WayofTime.alchemicalWizardry.common.rituals;
2014-10-13 20:33:20 +00:00
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralBlock;
2014-07-31 23:45:40 +00:00
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
2014-10-13 20:33:20 +00:00
import java.util.ArrayList;
import java.util.List;
2014-07-31 23:45:40 +00:00
public class RitualEffectEllipsoid extends RitualEffect
{
@Override
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
2014-07-31 23:45:40 +00:00
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
2014-10-13 20:33:20 +00:00
TileEntity tile = world.getTileEntity(x, y + 1, z);
if (!(tile instanceof IInventory) || ((IInventory) tile).getSizeInventory() < 3)
2014-07-31 23:45:40 +00:00
{
2014-10-13 20:33:20 +00:00
return;
2014-07-31 23:45:40 +00:00
}
2014-10-13 20:33:20 +00:00
ItemStack item1 = ((IInventory) tile).getStackInSlot(0);
ItemStack item2 = ((IInventory) tile).getStackInSlot(1);
ItemStack item3 = ((IInventory) tile).getStackInSlot(2);
int xSize = item1 == null ? 0 : item1.stackSize;
int ySize = item2 == null ? 0 : item2.stackSize;
int zSize = item3 == null ? 0 : item3.stackSize;
int cost = (int) Math.pow((xSize + 1) * (ySize + 1) * (zSize + 1), 0.333);
2014-07-31 23:45:40 +00:00
if (currentEssence < cost)
{
EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner);
if (entityOwner == null)
{
return;
}
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
} else
{
2014-10-13 20:33:20 +00:00
int refresh = 1000;
int j = (int) (world.getWorldTime() % (ySize * 2 + 1)) - ySize;
for (int i = -xSize; i <= xSize; i++)
2014-07-31 23:45:40 +00:00
{
{
2014-10-13 20:33:20 +00:00
for (int k = -zSize; k <= zSize; k++)
2014-07-31 23:45:40 +00:00
{
2014-10-13 20:33:20 +00:00
if (Math.pow(i * (ySize - 0.50f) * (zSize - 0.50f), 2) + Math.pow(j * (xSize - 0.50f) * (zSize - 0.50f), 2) + Math.pow(k * (xSize - 0.50f) * (ySize - 0.50f), 2) <= Math.pow((xSize - 1 + 0.50f) * (ySize - 1 + 0.50f) * (zSize - 1 + 0.50f), 2))
2014-07-31 23:45:40 +00:00
{
2014-10-13 20:33:20 +00:00
continue;
}
if (Math.pow(i * (ySize + 0.50f) * (zSize + 0.50f), 2) + Math.pow(j * (xSize + 0.50f) * (zSize + 0.50f), 2) + Math.pow(k * (xSize + 0.50f) * (ySize + 0.50f), 2) >= Math.pow((xSize + 0.50f) * (ySize + 0.50f) * (zSize + 0.50f), 2))
{
continue;
}
Block block = world.getBlock(x + i, y + j, z + k);
if (block.isAir(world, x + i, y + j, z + k))
{
TESpectralBlock.createSpectralBlockAtLocation(world, x + i, y + j, z + k, refresh);
} else
{
TileEntity tile1 = world.getTileEntity(x + i, y + j, z + k);
if (tile instanceof TESpectralBlock)
2014-07-31 23:45:40 +00:00
{
2014-10-13 20:33:20 +00:00
((TESpectralBlock) tile1).resetDuration(refresh);
2014-07-31 23:45:40 +00:00
}
}
}
}
}
2014-10-13 20:33:20 +00:00
SoulNetworkHandler.syphonFromNetwork(owner, cost);
2014-07-31 23:45:40 +00:00
}
}
@Override
public int getCostPerRefresh()
{
return 0;
}
@Override
2014-10-13 20:33:20 +00:00
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> ellipsoidRitual = new ArrayList();
ellipsoidRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.DUSK));
ellipsoidRitual.add(new RitualComponent(-1, 0, 1, RitualComponent.DUSK));
ellipsoidRitual.add(new RitualComponent(1, 0, -1, RitualComponent.DUSK));
ellipsoidRitual.add(new RitualComponent(1, 0, 1, RitualComponent.DUSK));
ellipsoidRitual.add(new RitualComponent(4, 0, 0, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(5, 0, 0, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(5, 0, -1, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(5, 0, -2, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(-4, 0, 0, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(-5, 0, 0, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(-5, 0, 1, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(-5, 0, 2, RitualComponent.FIRE));
ellipsoidRitual.add(new RitualComponent(0, 0, 4, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(0, 0, 5, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(1, 0, 5, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(2, 0, 5, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(0, 0, -4, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(0, 0, -5, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(-1, 0, -5, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(-2, 0, -5, RitualComponent.AIR));
ellipsoidRitual.add(new RitualComponent(3, 0, 1, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(3, 0, 2, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(3, 0, 3, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(2, 0, 3, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(-3, 0, -1, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(-3, 0, -2, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(-3, 0, -3, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(-2, 0, -3, RitualComponent.EARTH));
ellipsoidRitual.add(new RitualComponent(1, 0, -3, RitualComponent.WATER));
ellipsoidRitual.add(new RitualComponent(2, 0, -3, RitualComponent.WATER));
ellipsoidRitual.add(new RitualComponent(3, 0, -3, RitualComponent.WATER));
ellipsoidRitual.add(new RitualComponent(3, 0, -2, RitualComponent.WATER));
ellipsoidRitual.add(new RitualComponent(-1, 0, 3, RitualComponent.WATER));
ellipsoidRitual.add(new RitualComponent(-2, 0, 3, RitualComponent.WATER));
ellipsoidRitual.add(new RitualComponent(-3, 0, 3, RitualComponent.WATER));
ellipsoidRitual.add(new RitualComponent(-3, 0, 2, RitualComponent.WATER));
2014-07-31 23:45:40 +00:00
return ellipsoidRitual;
2014-10-13 20:33:20 +00:00
}
2014-07-31 23:45:40 +00:00
}