2014-06-27 23:43:09 +00:00
|
|
|
package WayofTime.alchemicalWizardry.common.rituals;
|
|
|
|
|
2014-09-14 22:21:45 +00:00
|
|
|
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
2014-06-27 23:43:09 +00:00
|
|
|
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
|
|
|
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
|
|
|
|
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
|
2014-10-09 11:48:45 +00:00
|
|
|
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
2014-06-27 23:43:09 +00:00
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
|
|
|
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralContainer;
|
2014-10-13 20:33:20 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.potion.Potion;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2014-06-27 23:43:09 +00:00
|
|
|
|
|
|
|
public class RitualEffectSupression extends RitualEffect
|
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
public static final int aquasalusDrain = 15;
|
|
|
|
public static final int aetherDrain = 15;
|
|
|
|
|
2014-06-27 23:43:09 +00:00
|
|
|
@Override
|
|
|
|
public void performEffect(IMasterRitualStone ritualStone)
|
|
|
|
{
|
|
|
|
String owner = ritualStone.getOwner();
|
|
|
|
|
2014-10-09 11:48:45 +00:00
|
|
|
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
|
2014-06-27 23:43:09 +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
|
|
|
|
|
|
|
Block blockish = world.getBlock(x, y - 1, z);
|
|
|
|
|
2014-09-14 22:21:45 +00:00
|
|
|
boolean hasAquasalus = this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, false);
|
|
|
|
boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false);
|
2014-10-13 20:33:20 +00:00
|
|
|
|
2014-06-27 23:43:09 +00:00
|
|
|
int costMod = this.getCostModifier(blockish);
|
2014-09-14 22:21:45 +00:00
|
|
|
int radius = this.getRadiusForReagents(hasAether, hasAquasalus);
|
2014-06-27 23:43:09 +00:00
|
|
|
int masterRadius = radius;
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
int yIndex = (int) (world.getWorldTime() % (2 * radius + 1)) - radius;
|
2014-06-27 23:43:09 +00:00
|
|
|
boolean expansion = false;
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
if (ritualStone.getVar1() < (radius + 1))
|
2014-06-27 23:43:09 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
expansion = true;
|
|
|
|
radius = ritualStone.getVar1();
|
|
|
|
ritualStone.setVar1(ritualStone.getVar1() + 1);
|
2014-06-27 23:43:09 +00:00
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
if (currentEssence < this.getCostPerRefresh() * costMod)
|
2014-06-27 23:43:09 +00:00
|
|
|
{
|
|
|
|
EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner);
|
|
|
|
|
|
|
|
if (entityOwner == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
for (int i = -radius; i <= radius; i++)
|
|
|
|
{
|
|
|
|
for (int j = (expansion ? -radius : yIndex); j <= (expansion ? radius : yIndex); j++)
|
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
for (int k = -radius; k <= radius; k++)
|
2014-06-27 23:43:09 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f))
|
2014-06-27 23:43:09 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
Block block = world.getBlock(x + i, y + j, z + k);
|
|
|
|
|
|
|
|
|
|
|
|
if (SpellHelper.isBlockFluid(block))
|
|
|
|
{
|
|
|
|
TESpectralContainer.createSpectralBlockAtLocation(world, x + i, y + j, z + k, 3 * masterRadius);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
TileEntity tile = world.getTileEntity(x + i, y + j, z + k);
|
|
|
|
if (tile instanceof TESpectralContainer)
|
|
|
|
{
|
|
|
|
((TESpectralContainer) tile).resetDuration(3 * masterRadius);
|
|
|
|
}
|
|
|
|
}
|
2014-06-27 23:43:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * costMod);
|
|
|
|
|
|
|
|
if (world.getWorldTime() % 100 == 0)
|
2014-09-14 22:21:45 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
if (hasAquasalus)
|
2014-09-14 22:21:45 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, true);
|
2014-09-14 22:21:45 +00:00
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
if (hasAether)
|
2014-09-14 22:21:45 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true);
|
2014-09-14 22:21:45 +00:00
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
}
|
2014-06-27 23:43:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCostPerRefresh()
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2014-10-13 20:33:20 +00:00
|
|
|
@Override
|
|
|
|
public List<RitualComponent> getRitualComponentList()
|
|
|
|
{
|
|
|
|
ArrayList<RitualComponent> supressionRitual = new ArrayList();
|
|
|
|
supressionRitual.add(new RitualComponent(2, 0, 2, RitualComponent.WATER));
|
|
|
|
supressionRitual.add(new RitualComponent(2, 0, -2, RitualComponent.WATER));
|
|
|
|
supressionRitual.add(new RitualComponent(-2, 0, 2, RitualComponent.WATER));
|
|
|
|
supressionRitual.add(new RitualComponent(-2, 0, -2, RitualComponent.WATER));
|
|
|
|
supressionRitual.add(new RitualComponent(-2, 0, -1, RitualComponent.AIR));
|
|
|
|
supressionRitual.add(new RitualComponent(-1, 0, -2, RitualComponent.AIR));
|
|
|
|
supressionRitual.add(new RitualComponent(-2, 0, 1, RitualComponent.AIR));
|
|
|
|
supressionRitual.add(new RitualComponent(1, 0, -2, RitualComponent.AIR));
|
|
|
|
supressionRitual.add(new RitualComponent(2, 0, 1, RitualComponent.AIR));
|
|
|
|
supressionRitual.add(new RitualComponent(1, 0, 2, RitualComponent.AIR));
|
|
|
|
supressionRitual.add(new RitualComponent(2, 0, -1, RitualComponent.AIR));
|
|
|
|
supressionRitual.add(new RitualComponent(-1, 0, 2, RitualComponent.AIR));
|
2014-06-27 23:43:09 +00:00
|
|
|
return supressionRitual;
|
2014-10-13 20:33:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getCostModifier(Block block)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRadiusForReagents(boolean hasAether, boolean hasAquasalus)
|
|
|
|
{
|
|
|
|
if (hasAether)
|
|
|
|
{
|
|
|
|
if (hasAquasalus)
|
|
|
|
{
|
|
|
|
return 30;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (hasAquasalus)
|
|
|
|
{
|
|
|
|
return 15;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-27 23:43:09 +00:00
|
|
|
}
|