2014-06-27 23:43:09 +00:00
|
|
|
package WayofTime.alchemicalWizardry.common.rituals;
|
|
|
|
|
2014-10-13 20:33:20 +00:00
|
|
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
|
|
|
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
|
|
|
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.block.BlockSpectralContainer;
|
|
|
|
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
2014-06-27 23:43:09 +00:00
|
|
|
import net.minecraft.block.Block;
|
2014-08-25 11:58:39 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2014-06-27 23:43:09 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
2014-08-25 11:58:39 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-06-27 23:43:09 +00:00
|
|
|
import net.minecraft.world.World;
|
2014-08-25 11:58:39 +00:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
import net.minecraftforge.fluids.FluidRegistry;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
import net.minecraftforge.fluids.IFluidHandler;
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2014-06-27 23:43:09 +00:00
|
|
|
|
|
|
|
public class RitualEffectWater extends RitualEffect
|
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
public static final int aquasalusDrain = 5;
|
|
|
|
public static final int offensaDrain = 20;
|
|
|
|
public static final int sanctusDrain = 5;
|
|
|
|
public static final int reductusDrain = 2;
|
|
|
|
public static final int crystallosDrain = 10;
|
|
|
|
|
2014-06-27 23:43:09 +00:00
|
|
|
public void performEffect(IMasterRitualStone ritualStone)
|
|
|
|
{
|
|
|
|
String owner = ritualStone.getOwner();
|
2014-10-13 20:33:20 +00:00
|
|
|
|
2014-10-03 14:08:21 +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
|
|
|
|
2014-08-25 11:58:39 +00:00
|
|
|
boolean hasCrystallos = this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, false);
|
|
|
|
boolean hasAquasalus = this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, false);
|
|
|
|
boolean hasOffensa = this.canDrainReagent(ritualStone, ReagentRegistry.offensaReagent, offensaDrain, false);
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
if (hasAquasalus)
|
2014-08-25 11:58:39 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
int hydrationRange = 4;
|
|
|
|
int vertRange = 3;
|
|
|
|
|
|
|
|
for (int i = -hydrationRange; i <= hydrationRange; i++)
|
|
|
|
{
|
|
|
|
for (int j = -vertRange; j <= vertRange; j++)
|
|
|
|
{
|
|
|
|
for (int k = -hydrationRange; k <= hydrationRange; k++)
|
|
|
|
{
|
|
|
|
if (SpellHelper.hydrateSoil(world, x + i, y + j, z + k))
|
|
|
|
{
|
|
|
|
this.canDrainReagent(ritualStone, ReagentRegistry.aquasalusReagent, aquasalusDrain, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-25 11:58:39 +00:00
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
if (hasOffensa)
|
2014-08-25 11:58:39 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
boolean hasReductus = this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
|
|
|
|
boolean drainReductus = world.getWorldTime() % 100 == 0;
|
|
|
|
|
|
|
|
int range = 10;
|
|
|
|
List<Entity> list = SpellHelper.getEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range);
|
|
|
|
for (Entity entity : list)
|
|
|
|
{
|
|
|
|
if (entity instanceof EntityLivingBase)
|
|
|
|
{
|
|
|
|
EntityLivingBase livingEntity = (EntityLivingBase) entity;
|
|
|
|
|
|
|
|
if (livingEntity == SpellHelper.getPlayerForUsername(owner))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasReductus && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false))
|
|
|
|
{
|
|
|
|
if (livingEntity instanceof EntityPlayer)
|
|
|
|
{
|
|
|
|
if (drainReductus)
|
|
|
|
{
|
|
|
|
this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionDrowning))
|
|
|
|
{
|
|
|
|
livingEntity.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionDrowning.id, 100, 0));
|
|
|
|
this.canDrainReagent(ritualStone, ReagentRegistry.offensaReagent, offensaDrain, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-25 11:58:39 +00:00
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
|
2014-06-27 23:43:09 +00:00
|
|
|
Block block = world.getBlock(x, y + 1, z);
|
2014-10-13 20:33:20 +00:00
|
|
|
|
2014-06-27 23:43:09 +00:00
|
|
|
if (world.isAirBlock(x, y + 1, z) && !(block instanceof BlockSpectralContainer))
|
|
|
|
{
|
|
|
|
if (currentEssence < this.getCostPerRefresh())
|
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
SoulNetworkHandler.causeNauseaToPlayer(owner);
|
2014-06-27 23:43:09 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
SpellHelper.sendIndexedParticleToAllAround(world, x, y, z, 20, world.provider.dimensionId, 3, x, y, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
world.setBlock(x, y + 1, z, Blocks.water, 0, 3);
|
2014-10-03 14:08:21 +00:00
|
|
|
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh());
|
2014-06-27 23:43:09 +00:00
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
} else
|
2014-08-25 11:58:39 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
|
|
|
|
if (!hasSanctus)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TileEntity tile = world.getTileEntity(x, y + 1, z);
|
|
|
|
if (tile instanceof IFluidHandler)
|
|
|
|
{
|
|
|
|
int amount = ((IFluidHandler) tile).fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.WATER, 1000), false);
|
|
|
|
if (amount >= 1000)
|
|
|
|
{
|
|
|
|
((IFluidHandler) tile).fill(ForgeDirection.DOWN, new FluidStack(FluidRegistry.WATER, 1000), true);
|
|
|
|
|
|
|
|
this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true);
|
|
|
|
|
|
|
|
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh());
|
|
|
|
}
|
|
|
|
}
|
2014-08-25 11:58:39 +00:00
|
|
|
}
|
2014-10-13 20:33:20 +00:00
|
|
|
|
|
|
|
if (hasCrystallos)
|
2014-08-25 11:58:39 +00:00
|
|
|
{
|
2014-10-13 20:33:20 +00:00
|
|
|
int range = 2;
|
|
|
|
for (int i = -range; i <= range; i++)
|
|
|
|
{
|
|
|
|
for (int j = -range; j <= range; j++)
|
|
|
|
{
|
|
|
|
for (int k = -range; k <= range; k++)
|
|
|
|
{
|
|
|
|
hasCrystallos = hasCrystallos && this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, false);
|
|
|
|
|
|
|
|
if (hasCrystallos)
|
|
|
|
{
|
|
|
|
boolean success = false;
|
|
|
|
if (!world.isAirBlock(x + i, y + j, z + k) && SpellHelper.freezeWaterBlock(world, x + i, y + j, z + k))
|
|
|
|
{
|
|
|
|
success = true;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (world.rand.nextInt(100) == 0 && world.isSideSolid(x + i, y + j - 1, z + k, ForgeDirection.UP))
|
|
|
|
{
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
this.canDrainReagent(ritualStone, ReagentRegistry.crystallosReagent, crystallosDrain, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-27 23:43:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCostPerRefresh()
|
|
|
|
{
|
|
|
|
return 25;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-10-13 20:33:20 +00:00
|
|
|
public List<RitualComponent> getRitualComponentList()
|
|
|
|
{
|
|
|
|
ArrayList<RitualComponent> waterRitual = new ArrayList();
|
2014-06-27 23:43:09 +00:00
|
|
|
waterRitual.add(new RitualComponent(-1, 0, 1, 1));
|
|
|
|
waterRitual.add(new RitualComponent(-1, 0, -1, 1));
|
|
|
|
waterRitual.add(new RitualComponent(1, 0, -1, 1));
|
|
|
|
waterRitual.add(new RitualComponent(1, 0, 1, 1));
|
|
|
|
return waterRitual;
|
2014-10-13 20:33:20 +00:00
|
|
|
}
|
2014-06-27 23:43:09 +00:00
|
|
|
}
|