BloodMagic/src/main/java/WayofTime/bloodmagic/ritual/RitualJumping.java

98 lines
2.6 KiB
Java
Raw Normal View History

2015-12-30 23:00:49 -05:00
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.util.Utils;
2015-12-30 23:00:49 -05:00
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
2015-12-30 23:00:49 -05:00
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
2015-12-30 23:00:49 -05:00
public class RitualJumping extends Ritual
{
public static final String JUMP_RANGE = "jumpRange";
public RitualJumping()
{
super("ritualJump", 0, 5000, "ritual." + BloodMagic.MODID + ".jumpRitual");
addBlockRange(JUMP_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 1, -1), 3, 1, 3));
setMaximumVolumeAndDistanceOfRange(JUMP_RANGE, 0, 5, 5);
2015-12-30 23:00:49 -05:00
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
2016-01-03 08:30:59 -05:00
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
2015-12-30 23:00:49 -05:00
if (currentEssence < getRefreshCost())
{
masterRitualStone.getOwnerNetwork().causeNausea();
2015-12-30 23:00:49 -05:00
return;
}
2015-12-30 23:00:49 -05:00
int maxEffects = currentEssence / getRefreshCost();
int totalEffects = 0;
2015-12-30 23:00:49 -05:00
AreaDescriptor jumpRange = getBlockRange(JUMP_RANGE);
2016-01-03 08:30:59 -05:00
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, jumpRange.getAABB(masterRitualStone.getBlockPos()));
2016-12-12 19:56:36 -08:00
for (EntityLivingBase entity : entities)
2015-12-30 23:00:49 -05:00
{
2016-12-12 19:56:36 -08:00
if (totalEffects >= maxEffects)
2015-12-30 23:00:49 -05:00
{
2016-12-12 19:56:36 -08:00
break;
}
double motionY = 1.5;
entity.fallDistance = 0;
if (entity.isSneaking())
{
continue;
}
entity.motionY = motionY;
totalEffects++;
if (entity instanceof EntityPlayer)
{
Utils.setPlayerSpeedFromServer((EntityPlayer) entity, entity.motionX, entity.motionY, entity.motionZ);
2015-12-30 23:00:49 -05:00
}
}
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
2015-12-30 23:00:49 -05:00
}
@Override
public int getRefreshTime()
{
return 1;
2015-12-30 23:00:49 -05:00
}
@Override
public int getRefreshCost()
{
return 5;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
for (int i = -1; i <= 1; i++)
this.addCornerRunes(components, 1, i, EnumRuneType.AIR);
return components;
}
@Override
public Ritual getNewCopy()
{
return new RitualJumping();
}
2015-12-30 23:00:49 -05:00
}