2015-12-31 04:00:49 +00:00
|
|
|
package WayofTime.bloodmagic.ritual;
|
|
|
|
|
2015-12-31 15:05:38 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-31 04:00:49 +00:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
2015-12-31 15:05:38 +00:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
|
|
|
import WayofTime.bloodmagic.api.network.SoulNetwork;
|
|
|
|
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
|
|
|
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
|
|
|
|
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
|
|
|
|
import WayofTime.bloodmagic.api.ritual.Ritual;
|
|
|
|
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
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));
|
2015-12-31 04:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void performRitual(IMasterRitualStone masterRitualStone)
|
|
|
|
{
|
|
|
|
World world = masterRitualStone.getWorld();
|
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
|
|
|
{
|
|
|
|
network.causeNauseaToPlayer();
|
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);
|
|
|
|
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, jumpRange.getAABB(masterRitualStone.getPos()));
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (entity instanceof EntityPlayer && entity instanceof EntityPlayerMP)
|
|
|
|
{
|
|
|
|
((EntityPlayerMP) entity).fallDistance = 0;
|
2015-12-31 15:05:38 +00:00
|
|
|
if (entity.isSneaking())
|
|
|
|
continue;
|
|
|
|
// TODO Packet handlers if needed
|
|
|
|
// BloodMagicPacketHandler.INSTANCE.sendTo();
|
|
|
|
((EntityPlayerMP) entity).motionY = motionY;
|
|
|
|
totalEffects++;
|
|
|
|
} else
|
2015-12-31 04:00:49 +00:00
|
|
|
{
|
|
|
|
entity.fallDistance = 0;
|
2015-12-31 15:05:38 +00:00
|
|
|
if (entity.isSneaking())
|
|
|
|
continue;
|
|
|
|
entity.motionY = motionY;
|
|
|
|
totalEffects++;
|
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
|
|
|
}
|