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

181 lines
8.4 KiB
Java
Raw Normal View History

package WayofTime.alchemicalWizardry.common.rituals;
2014-08-25 11:58:39 +00:00
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;
2014-08-25 11:58:39 +00:00
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
2014-10-13 20:33:20 +00:00
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class RitualEffectHealing extends RitualEffect
{
2014-10-13 20:33:20 +00:00
public static final int reductusDrain = 10;
public static final int virtusDrain = 10;
public static final int praesidiumDrain = 2;
@Override
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
2014-10-09 11:48:45 +00:00
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
2014-08-25 11:58:39 +00:00
int timeDelay = 50;
2014-10-13 20:33:20 +00:00
2014-08-25 11:58:39 +00:00
if (world.getWorldTime() % timeDelay != 0)
{
return;
}
2014-10-13 20:33:20 +00:00
2014-08-25 11:58:39 +00:00
boolean hasPraesidium = this.canDrainReagent(ritualStone, ReagentRegistry.praesidiumReagent, praesidiumDrain, false);
2014-10-13 20:33:20 +00:00
2014-08-25 11:58:39 +00:00
int range = 15 * (hasPraesidium ? 3 : 1);
int vertRange = 15 * (hasPraesidium ? 3 : 1);
2014-10-13 20:33:20 +00:00
List<EntityLivingBase> list = SpellHelper.getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, vertRange);
int entityCount = 0;
boolean flag = false;
2014-10-13 20:33:20 +00:00
for (EntityLivingBase livingEntity : list)
{
2014-08-25 11:58:39 +00:00
if (livingEntity instanceof EntityPlayer)
{
entityCount += 10;
} else
{
entityCount++;
}
}
2014-10-13 20:33:20 +00:00
2014-08-25 11:58:39 +00:00
boolean hasVirtus = this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false);
2014-10-13 20:33:20 +00:00
2014-08-25 11:58:39 +00:00
int cost = this.getCostPerRefresh() * (hasVirtus ? 3 : 1);
2014-10-13 20:33:20 +00:00
int potency = hasVirtus ? 1 : 0;
2014-08-25 11:58:39 +00:00
if (currentEssence < cost * entityCount)
{
2014-08-25 11:58:39 +00:00
SoulNetworkHandler.causeNauseaToPlayer(owner);
} else
{
2014-10-13 20:33:20 +00:00
entityCount = 0;
boolean hasReductus = this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
for (EntityLivingBase livingEntity : list)
{
2014-10-13 20:33:20 +00:00
hasReductus = hasReductus && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
if (hasReductus && !(livingEntity instanceof EntityPlayer))
{
continue;
}
2014-08-25 11:58:39 +00:00
if (livingEntity.getHealth() + 0.1f < livingEntity.getMaxHealth())
{
2014-10-13 20:33:20 +00:00
PotionEffect effect = livingEntity.getActivePotionEffect(Potion.regeneration);
if (effect == null || (effect != null && effect.getAmplifier() <= potency && effect.getDuration() <= timeDelay))
{
if (!hasVirtus || (this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, false)))
{
livingEntity.addPotionEffect(new PotionEffect(Potion.regeneration.id, timeDelay + 2, potency));
if (hasReductus)
{
this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true);
}
if (hasVirtus)
{
this.canDrainReagent(ritualStone, ReagentRegistry.virtusReagent, virtusDrain, true);
}
if (livingEntity instanceof EntityPlayer)
2014-08-25 11:58:39 +00:00
{
entityCount += 10;
} else
{
entityCount++;
}
2014-10-13 20:33:20 +00:00
}
}
}
}
2014-10-13 20:33:20 +00:00
if (entityCount > 0)
2014-08-25 11:58:39 +00:00
{
2014-10-13 20:33:20 +00:00
if (hasPraesidium)
{
this.canDrainReagent(ritualStone, ReagentRegistry.praesidiumReagent, praesidiumDrain, true);
}
2014-10-09 11:48:45 +00:00
SoulNetworkHandler.syphonFromNetwork(owner, cost * entityCount);
2014-08-25 11:58:39 +00:00
}
}
}
@Override
public int getCostPerRefresh()
{
return 20;
}
@Override
2014-10-13 20:33:20 +00:00
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> healingRitual = new ArrayList();
healingRitual.add(new RitualComponent(4, 0, 0, RitualComponent.AIR));
healingRitual.add(new RitualComponent(5, 0, -1, RitualComponent.AIR));
healingRitual.add(new RitualComponent(5, 0, 1, RitualComponent.AIR));
healingRitual.add(new RitualComponent(-4, 0, 0, RitualComponent.AIR));
healingRitual.add(new RitualComponent(-5, 0, -1, RitualComponent.AIR));
healingRitual.add(new RitualComponent(-5, 0, 1, RitualComponent.AIR));
healingRitual.add(new RitualComponent(0, 0, 4, RitualComponent.FIRE));
healingRitual.add(new RitualComponent(-1, 0, 5, RitualComponent.FIRE));
healingRitual.add(new RitualComponent(1, 0, 5, RitualComponent.FIRE));
healingRitual.add(new RitualComponent(0, 0, -4, RitualComponent.FIRE));
healingRitual.add(new RitualComponent(-1, 0, -5, RitualComponent.FIRE));
healingRitual.add(new RitualComponent(1, 0, -5, RitualComponent.FIRE));
healingRitual.add(new RitualComponent(3, 0, 5, RitualComponent.WATER));
healingRitual.add(new RitualComponent(5, 0, 3, RitualComponent.WATER));
healingRitual.add(new RitualComponent(3, 0, -5, RitualComponent.WATER));
healingRitual.add(new RitualComponent(5, 0, -3, RitualComponent.WATER));
healingRitual.add(new RitualComponent(-3, 0, 5, RitualComponent.WATER));
healingRitual.add(new RitualComponent(-5, 0, 3, RitualComponent.WATER));
healingRitual.add(new RitualComponent(-3, 0, -5, RitualComponent.WATER));
healingRitual.add(new RitualComponent(-5, 0, -3, RitualComponent.WATER));
healingRitual.add(new RitualComponent(-3, 0, -3, RitualComponent.DUSK));
healingRitual.add(new RitualComponent(-3, 0, 3, RitualComponent.DUSK));
healingRitual.add(new RitualComponent(3, 0, -3, RitualComponent.DUSK));
healingRitual.add(new RitualComponent(3, 0, 3, RitualComponent.DUSK));
healingRitual.add(new RitualComponent(4, 0, 5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(4, -1, 5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(5, 0, 4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(5, -1, 4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(5, 0, 5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(4, 0, -5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(4, -1, -5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(5, 0, -4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(5, -1, -4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(5, 0, -5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-4, 0, 5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-4, -1, 5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-5, 0, 4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-5, -1, 4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-5, 0, 5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-4, 0, -5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-4, -1, -5, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-5, 0, -4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-5, -1, -4, RitualComponent.EARTH));
healingRitual.add(new RitualComponent(-5, 0, -5, RitualComponent.EARTH));
return healingRitual;
2014-10-13 20:33:20 +00:00
}
}