2014-07-31 19:45:40 -04:00
|
|
|
package WayofTime.alchemicalWizardry.common.rituals;
|
|
|
|
|
2015-07-29 14:26:37 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-10-13 22:33:20 +02:00
|
|
|
import net.minecraft.block.Block;
|
2015-07-29 14:26:37 -04:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2014-10-13 22:33:20 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.potion.Potion;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
2015-07-29 08:23:01 -04:00
|
|
|
import net.minecraft.util.BlockPos;
|
2015-07-29 14:26:37 -04:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2014-10-13 22:33:20 +02:00
|
|
|
import net.minecraft.world.World;
|
2015-07-29 14:26:37 -04:00
|
|
|
import WayofTime.alchemicalWizardry.ModBlocks;
|
|
|
|
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;
|
2014-07-31 19:45:40 -04:00
|
|
|
|
|
|
|
public class RitualEffectEvaporation extends RitualEffect
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void performEffect(IMasterRitualStone ritualStone)
|
|
|
|
{
|
|
|
|
String owner = ritualStone.getOwner();
|
|
|
|
|
2014-10-03 10:08:21 -04:00
|
|
|
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
|
2015-07-29 08:23:01 -04:00
|
|
|
World world = ritualStone.getWorldObj();
|
|
|
|
BlockPos pos = ritualStone.getPosition();
|
2014-10-13 22:33:20 +02:00
|
|
|
|
2014-07-31 19:45:40 -04:00
|
|
|
if (currentEssence < 0)
|
|
|
|
{
|
|
|
|
EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner);
|
|
|
|
|
|
|
|
if (entityOwner == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
|
|
|
} else
|
|
|
|
{
|
2015-07-29 14:26:37 -04:00
|
|
|
IBlockState state1 = world.getBlockState(pos.offsetDown());
|
|
|
|
Block block1 = state1.getBlock();
|
2014-10-13 22:33:20 +02:00
|
|
|
int range = this.getRadiusForModifierBlock(block1);
|
|
|
|
|
|
|
|
boolean[][][] boolList = new boolean[range * 2 + 1][range * 2 + 1][range * 2 + 1];
|
2014-07-31 19:45:40 -04:00
|
|
|
|
|
|
|
for (int i = 0; i < 2 * range + 1; i++)
|
|
|
|
{
|
|
|
|
for (int j = 0; j < 2 * range + 1; j++)
|
|
|
|
{
|
2014-10-13 22:33:20 +02:00
|
|
|
for (int k = 0; k < 2 * range + 1; k++)
|
|
|
|
{
|
2014-07-31 19:45:40 -04:00
|
|
|
boolList[i][j][k] = false;
|
2014-10-13 22:33:20 +02:00
|
|
|
}
|
2014-07-31 19:45:40 -04:00
|
|
|
}
|
|
|
|
}
|
2014-10-13 22:33:20 +02:00
|
|
|
|
2014-07-31 19:45:40 -04:00
|
|
|
boolList[range][range][range] = true;
|
|
|
|
boolean isReady = false;
|
|
|
|
|
|
|
|
while (!isReady)
|
|
|
|
{
|
|
|
|
isReady = true;
|
|
|
|
|
|
|
|
for (int i = 0; i < 2 * range + 1; i++)
|
|
|
|
{
|
|
|
|
for (int j = 0; j < 2 * range + 1; j++)
|
|
|
|
{
|
2014-10-13 22:33:20 +02:00
|
|
|
for (int k = 0; k < 2 * range + 1; k++)
|
|
|
|
{
|
2014-07-31 19:45:40 -04:00
|
|
|
if (boolList[i][j][k])
|
|
|
|
{
|
2015-07-29 14:26:37 -04:00
|
|
|
BlockPos position = pos.add(i - range, j - range, k - range);
|
|
|
|
|
|
|
|
for(EnumFacing face : EnumFacing.VALUES)
|
|
|
|
{
|
|
|
|
int iP = i + face.getFrontOffsetX();
|
|
|
|
int jP = j + face.getFrontOffsetY();
|
|
|
|
int kP = k + face.getFrontOffsetZ();
|
|
|
|
|
|
|
|
if(iP >= 0 && iP <= 2 * range && jP >= 0 && jP <= 2 * range && kP >= 0 && kP <= 2 * range && !boolList[iP][jP][kP])
|
|
|
|
{
|
|
|
|
BlockPos newPos = position.add(face.getDirectionVec());
|
|
|
|
IBlockState state = world.getBlockState(newPos);
|
|
|
|
Block block = state.getBlock();
|
|
|
|
if (world.isAirBlock(newPos) || block == ModBlocks.blockSpectralContainer)
|
|
|
|
{
|
|
|
|
boolList[iP][jP][kP] = true;
|
|
|
|
isReady = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-31 19:45:40 -04:00
|
|
|
}
|
2014-10-13 22:33:20 +02:00
|
|
|
}
|
2014-07-31 19:45:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-13 22:33:20 +02:00
|
|
|
|
2014-07-31 19:45:40 -04:00
|
|
|
for (int i = 0; i < 2 * range + 1; i++)
|
|
|
|
{
|
|
|
|
for (int j = 0; j < 2 * range + 1; j++)
|
|
|
|
{
|
2014-10-13 22:33:20 +02:00
|
|
|
for (int k = 0; k < 2 * range + 1; k++)
|
|
|
|
{
|
|
|
|
if (!boolList[i][j][k])
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-07-29 14:26:37 -04:00
|
|
|
BlockPos newPos = pos.add(i - range, j - range, k - range);
|
|
|
|
IBlockState state = world.getBlockState(newPos);
|
|
|
|
Block block = state.getBlock();
|
2014-10-13 22:33:20 +02:00
|
|
|
|
|
|
|
if (block == ModBlocks.blockSpectralContainer)
|
|
|
|
{
|
2015-07-29 14:26:37 -04:00
|
|
|
world.setBlockToAir(newPos);
|
2014-10-13 22:33:20 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-31 19:45:40 -04:00
|
|
|
}
|
|
|
|
}
|
2014-10-13 22:33:20 +02:00
|
|
|
|
2014-10-03 10:08:21 -04:00
|
|
|
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh());
|
2014-10-13 22:33:20 +02:00
|
|
|
|
|
|
|
ritualStone.setActive(false);
|
2014-07-31 19:45:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCostPerRefresh()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-10-13 22:33:20 +02:00
|
|
|
public List<RitualComponent> getRitualComponentList()
|
|
|
|
{
|
2015-07-30 14:52:39 -04:00
|
|
|
ArrayList<RitualComponent> ellipsoidRitual = new ArrayList<RitualComponent>();
|
2014-10-13 22:33:20 +02:00
|
|
|
|
|
|
|
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.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(5, 0, 0, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(5, 0, -1, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(5, 0, -2, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-4, 0, 0, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-5, 0, 0, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-5, 0, 1, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-5, 0, 2, RitualComponent.DUSK));
|
|
|
|
|
|
|
|
ellipsoidRitual.add(new RitualComponent(0, 0, 4, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(0, 0, 5, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(1, 0, 5, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(2, 0, 5, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(0, 0, -4, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(0, 0, -5, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-1, 0, -5, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-2, 0, -5, RitualComponent.DUSK));
|
|
|
|
|
|
|
|
ellipsoidRitual.add(new RitualComponent(3, 0, 1, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(3, 0, 2, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(3, 0, 3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(2, 0, 3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-3, 0, -1, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-3, 0, -2, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-3, 0, -3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-2, 0, -3, RitualComponent.DUSK));
|
|
|
|
|
|
|
|
ellipsoidRitual.add(new RitualComponent(1, 0, -3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(2, 0, -3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(3, 0, -3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(3, 0, -2, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-1, 0, 3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-2, 0, 3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-3, 0, 3, RitualComponent.DUSK));
|
|
|
|
ellipsoidRitual.add(new RitualComponent(-3, 0, 2, RitualComponent.DUSK));
|
|
|
|
|
2014-07-31 19:45:40 -04:00
|
|
|
return ellipsoidRitual;
|
2014-10-13 22:33:20 +02:00
|
|
|
}
|
|
|
|
|
2014-07-31 19:45:40 -04:00
|
|
|
public int getRadiusForModifierBlock(Block block)
|
2014-10-13 22:33:20 +02:00
|
|
|
{
|
|
|
|
if (block == null)
|
|
|
|
{
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (block == Blocks.diamond_block)
|
|
|
|
{
|
|
|
|
return 30;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (block == Blocks.gold_block)
|
|
|
|
{
|
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (block == Blocks.iron_block)
|
|
|
|
{
|
|
|
|
return 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 10;
|
|
|
|
}
|
2014-07-31 19:45:40 -04:00
|
|
|
}
|