2016-01-11 18:07:06 -05:00
|
|
|
package WayofTime.bloodmagic.ritual;
|
|
|
|
|
2017-08-14 20:53:42 -07:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
2018-02-05 17:04:38 -08:00
|
|
|
import WayofTime.bloodmagic.apibutnotreally.ritual.*;
|
|
|
|
import WayofTime.bloodmagic.apibutnotreally.util.helper.PlayerHelper;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2016-01-11 18:07:06 -05:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class RitualInterdiction extends Ritual {
|
2016-01-11 18:07:06 -05:00
|
|
|
public static final String INTERDICTION_RANGE = "interdictionRange";
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public RitualInterdiction() {
|
2017-08-14 20:53:42 -07:00
|
|
|
super("ritualInterdiction", 0, 1000, "ritual." + BloodMagic.MODID + ".interdictionRitual");
|
2016-01-11 18:07:06 -05:00
|
|
|
addBlockRange(INTERDICTION_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 0, -2), 5));
|
2016-11-19 17:06:11 -05:00
|
|
|
setMaximumVolumeAndDistanceOfRange(INTERDICTION_RANGE, 0, 10, 10);
|
2016-01-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void performRitual(IMasterRitualStone masterRitualStone) {
|
2016-01-11 18:07:06 -05:00
|
|
|
World world = masterRitualStone.getWorldObj();
|
2017-02-12 17:00:18 -08:00
|
|
|
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
|
2016-01-11 18:07:06 -05:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
if (currentEssence < getRefreshCost()) {
|
2017-02-12 17:00:18 -08:00
|
|
|
masterRitualStone.getOwnerNetwork().causeNausea();
|
2016-01-11 18:07:06 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AreaDescriptor interdictionRange = getBlockRange(INTERDICTION_RANGE);
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, interdictionRange.getAABB(masterRitualStone.getBlockPos()))) {
|
2016-01-11 18:07:06 -05:00
|
|
|
if (entity instanceof EntityPlayer && (((EntityPlayer) entity).capabilities.isCreativeMode || PlayerHelper.getUUIDFromPlayer((EntityPlayer) entity).toString().equals(masterRitualStone.getOwner())))
|
|
|
|
continue;
|
|
|
|
|
2016-11-19 17:06:11 -05:00
|
|
|
double xDif = entity.posX - (masterRitualStone.getBlockPos().getX() + 0.5);
|
2016-01-11 18:07:06 -05:00
|
|
|
double yDif = entity.posY - masterRitualStone.getBlockPos().getY() + 1;
|
2016-11-19 17:06:11 -05:00
|
|
|
double zDif = entity.posZ - (masterRitualStone.getBlockPos().getZ() + 0.5);
|
2016-01-11 18:07:06 -05:00
|
|
|
|
2016-04-11 08:26:41 -04:00
|
|
|
entity.motionX = 0.1 * xDif;
|
|
|
|
entity.motionY = 0.1 * yDif;
|
|
|
|
entity.motionZ = 0.1 * zDif;
|
2016-01-11 18:07:06 -05:00
|
|
|
entity.fallDistance = 0;
|
2016-11-19 17:06:11 -05:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
if (entity instanceof EntityPlayer) {
|
2016-11-19 17:06:11 -05:00
|
|
|
entity.velocityChanged = true;
|
|
|
|
}
|
2016-01-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public int getRefreshTime() {
|
2016-01-11 18:07:06 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public int getRefreshCost() {
|
2016-01-11 18:07:06 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public ArrayList<RitualComponent> getComponents() {
|
2016-01-11 18:07:06 -05:00
|
|
|
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
|
|
|
|
|
|
|
|
this.addCornerRunes(components, 1, 0, EnumRuneType.AIR);
|
|
|
|
this.addParallelRunes(components, 1, 0, EnumRuneType.AIR);
|
|
|
|
|
|
|
|
return components;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public Ritual getNewCopy() {
|
2016-01-11 18:07:06 -05:00
|
|
|
return new RitualInterdiction();
|
|
|
|
}
|
|
|
|
}
|