BloodMagic/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectLeap.java

195 lines
7.6 KiB
Java
Raw Normal View History

package WayofTime.alchemicalWizardry.common.rituals;
2014-08-25 07:58:39 -04: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;
2014-08-25 07:58:39 -04:00
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
2014-10-13 22:33:20 +02:00
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class RitualEffectLeap extends RitualEffect
{
2014-10-13 22:33:20 +02:00
public static final int aetherDrain = 10;
public static final int terraeDrain = 10;
public static final int reductusDrain = 10;
public static final int tenebraeDrain = 10;
public static final int sanctusDrain = 10;
@Override
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
2014-10-09 07:48:45 -04: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 07:58:39 -04:00
double range = 2.0;
2014-10-13 22:33:20 +02:00
List<EntityLivingBase> livingList = SpellHelper.getLivingEntitiesInRange(world, x + 0.5, y + 0.5, z + 0.5, range, range);
if (livingList == null)
{
return;
}
2014-08-25 07:58:39 -04:00
if (currentEssence < this.getCostPerRefresh() * livingList.size())
{
2014-10-13 22:33:20 +02:00
SoulNetworkHandler.causeNauseaToPlayer(owner);
} else
{
2014-10-13 22:33:20 +02:00
boolean hasAether = this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false);
2014-08-25 07:58:39 -04:00
boolean hasTerrae = this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false);
boolean hasReductus = this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
boolean hasTenebrae = this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
boolean hasSanctus = this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
2014-10-13 22:33:20 +02:00
int direction = ritualStone.getDirection();
2014-08-25 07:58:39 -04:00
int flag = 0;
2014-10-13 22:33:20 +02:00
for (EntityLivingBase livingEntity : livingList)
2014-08-25 07:58:39 -04:00
{
2014-10-13 22:33:20 +02:00
if (livingEntity.isSneaking())
{
2014-10-13 22:33:20 +02:00
continue;
2014-08-25 07:58:39 -04:00
}
2014-10-13 22:33:20 +02:00
hasAether = hasAether && this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, false);
2014-08-25 07:58:39 -04:00
hasTerrae = hasTerrae && this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, false);
hasReductus = hasReductus && this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, false);
hasTenebrae = hasTenebrae && this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, false);
hasSanctus = hasSanctus && this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, false);
2014-10-13 22:33:20 +02:00
double motionY = hasTerrae ? 0.6 : 1.2;
double speed = hasAether ? 6.0 : 3.0;
if (!(hasTenebrae || hasSanctus) || livingEntity instanceof EntityPlayer)
2014-08-25 07:58:39 -04:00
{
livingEntity.motionY = motionY;
livingEntity.fallDistance = 0;
switch (direction)
{
case 1:
2014-10-13 22:33:20 +02:00
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, -speed);
break;
case 2:
2014-10-13 22:33:20 +02:00
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, speed, motionY, 0);
break;
case 3:
2014-10-13 22:33:20 +02:00
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, 0, motionY, speed);
break;
case 4:
2014-10-13 22:33:20 +02:00
SpellHelper.setPlayerSpeedFromServer((EntityPlayer) livingEntity, -speed, motionY, 0);
break;
}
2014-08-25 07:58:39 -04:00
flag++;
} else
{
2014-10-13 22:33:20 +02:00
if ((hasSanctus && !livingEntity.isChild()) || (hasTenebrae && livingEntity.isChild()))
{
continue;
}
2014-08-25 07:58:39 -04:00
livingEntity.motionY = motionY;
switch (direction)
{
case 1:
2014-08-25 07:58:39 -04:00
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 2:
2014-08-25 07:58:39 -04:00
livingEntity.motionX = speed;
livingEntity.motionZ = 0.0;
break;
case 3:
2014-08-25 07:58:39 -04:00
livingEntity.motionX = 0.0;
livingEntity.motionZ = -speed;
break;
case 4:
2014-08-25 07:58:39 -04:00
livingEntity.motionX = -speed;
livingEntity.motionZ = 0.0;
break;
}
2014-10-13 22:33:20 +02:00
if (hasTenebrae)
2014-09-14 18:21:45 -04:00
{
2014-10-13 22:33:20 +02:00
this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tenebraeDrain, true);
2014-09-14 18:21:45 -04:00
}
2014-10-13 22:33:20 +02:00
if (hasSanctus)
2014-09-14 18:21:45 -04:00
{
2014-10-13 22:33:20 +02:00
this.canDrainReagent(ritualStone, ReagentRegistry.sanctusReagent, sanctusDrain, true);
2014-09-14 18:21:45 -04:00
}
2014-10-13 22:33:20 +02:00
2014-08-25 07:58:39 -04:00
livingEntity.fallDistance = 0;
flag++;
}
2014-10-13 22:33:20 +02:00
if (hasAether)
2014-08-25 07:58:39 -04:00
{
2014-10-13 22:33:20 +02:00
this.canDrainReagent(ritualStone, ReagentRegistry.aetherReagent, aetherDrain, true);
2014-08-25 07:58:39 -04:00
}
2014-10-13 22:33:20 +02:00
if (hasTerrae)
2014-08-25 07:58:39 -04:00
{
2014-10-13 22:33:20 +02:00
this.canDrainReagent(ritualStone, ReagentRegistry.terraeReagent, terraeDrain, true);
2014-08-25 07:58:39 -04:00
}
2014-10-13 22:33:20 +02:00
if (hasReductus)
2014-08-25 07:58:39 -04:00
{
2014-10-13 22:33:20 +02:00
if (!livingEntity.isPotionActive(AlchemicalWizardry.customPotionFeatherFall))
{
livingEntity.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionFeatherFall.id, 3 * 20, 0));
this.canDrainReagent(ritualStone, ReagentRegistry.reductusReagent, reductusDrain, true);
}
2014-08-25 07:58:39 -04:00
}
2014-10-13 22:33:20 +02:00
}
2014-08-25 07:58:39 -04:00
if (flag > 0)
{
2014-10-09 07:48:45 -04:00
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * flag);
}
}
}
@Override
public int getCostPerRefresh()
{
return 5;
}
@Override
2014-10-13 22:33:20 +02:00
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> leapingRitual = new ArrayList();
leapingRitual.add(new RitualComponent(0, 0, -2, RitualComponent.DUSK));
leapingRitual.add(new RitualComponent(1, 0, -1, RitualComponent.AIR));
leapingRitual.add(new RitualComponent(-1, 0, -1, RitualComponent.AIR));
for (int i = 0; i <= 2; i++)
{
leapingRitual.add(new RitualComponent(2, 0, i, RitualComponent.AIR));
leapingRitual.add(new RitualComponent(-2, 0, i, RitualComponent.AIR));
}
return leapingRitual;
2014-10-13 22:33:20 +02:00
}
}