2015-12-31 04:00:49 +00:00
|
|
|
package WayofTime.bloodmagic.ritual;
|
|
|
|
|
2016-03-17 20:00:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2016-06-12 20:41:02 +00:00
|
|
|
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
2016-03-17 20:00:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.ritual.*;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
2016-04-13 15:05:17 +00:00
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2015-12-31 04:00:49 +00:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-17 20:00:44 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-12-31 04:00:49 +00:00
|
|
|
import net.minecraft.world.World;
|
2016-03-17 20:00:44 +00:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2015-12-31 04:00:49 +00:00
|
|
|
|
|
|
|
public class RitualJumping extends Ritual
|
|
|
|
{
|
|
|
|
public static final String JUMP_RANGE = "jumpRange";
|
|
|
|
|
|
|
|
public RitualJumping()
|
|
|
|
{
|
2016-01-02 22:15:33 +00:00
|
|
|
super("ritualJump", 0, 5000, "ritual." + Constants.Mod.MODID + ".jumpRitual");
|
2015-12-31 16:25:24 +00:00
|
|
|
addBlockRange(JUMP_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 1, -1), 3, 1, 3));
|
2016-04-11 19:36:27 +00:00
|
|
|
setMaximumVolumeAndDistanceOfRange(JUMP_RANGE, 0, 5, 5);
|
2015-12-31 04:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void performRitual(IMasterRitualStone masterRitualStone)
|
|
|
|
{
|
2016-01-03 13:30:59 +00:00
|
|
|
World world = masterRitualStone.getWorldObj();
|
2016-01-01 01:10:57 +00:00
|
|
|
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
|
2015-12-31 04:00:49 +00:00
|
|
|
int currentEssence = network.getCurrentEssence();
|
|
|
|
|
|
|
|
if (currentEssence < getRefreshCost())
|
2016-01-01 01:47:01 +00:00
|
|
|
{
|
2016-06-12 20:41:02 +00:00
|
|
|
network.causeNausea();
|
2015-12-31 04:00:49 +00:00
|
|
|
return;
|
2016-01-01 01:47:01 +00:00
|
|
|
}
|
2015-12-31 04:00:49 +00:00
|
|
|
|
2015-12-31 15:05:38 +00:00
|
|
|
int maxEffects = currentEssence / getRefreshCost();
|
|
|
|
int totalEffects = 0;
|
|
|
|
|
2015-12-31 04:00:49 +00:00
|
|
|
AreaDescriptor jumpRange = getBlockRange(JUMP_RANGE);
|
2016-01-03 13:30:59 +00:00
|
|
|
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, jumpRange.getAABB(masterRitualStone.getBlockPos()));
|
2015-12-31 04:00:49 +00:00
|
|
|
if (entities != null)
|
|
|
|
{
|
|
|
|
for (EntityLivingBase entity : entities)
|
|
|
|
{
|
2015-12-31 15:05:38 +00:00
|
|
|
if (totalEffects >= maxEffects)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2015-12-31 04:00:49 +00:00
|
|
|
|
|
|
|
double motionY = 1.5;
|
|
|
|
|
2016-04-13 15:05:17 +00:00
|
|
|
entity.fallDistance = 0;
|
|
|
|
if (entity.isSneaking())
|
2015-12-31 04:00:49 +00:00
|
|
|
{
|
2016-04-13 15:05:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
entity.motionY = motionY;
|
|
|
|
totalEffects++;
|
|
|
|
|
|
|
|
if (entity instanceof EntityPlayer)
|
2015-12-31 04:00:49 +00:00
|
|
|
{
|
2016-04-13 15:05:17 +00:00
|
|
|
Utils.setPlayerSpeedFromServer((EntityPlayer) entity, entity.motionX, entity.motionY, entity.motionZ);
|
2015-12-31 04:00:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-31 15:05:38 +00:00
|
|
|
|
|
|
|
network.syphon(getRefreshCost() * totalEffects);
|
2015-12-31 04:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRefreshTime()
|
|
|
|
{
|
2015-12-31 15:05:38 +00:00
|
|
|
return 1;
|
2015-12-31 04:00:49 +00: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;
|
|
|
|
}
|
2015-12-31 15:05:38 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Ritual getNewCopy()
|
|
|
|
{
|
|
|
|
return new RitualJumping();
|
|
|
|
}
|
2015-12-31 04:00:49 +00:00
|
|
|
}
|