2018-09-12 01:29:49 +02:00
|
|
|
package com.minelittlepony.unicopia.spell;
|
|
|
|
|
2019-01-20 00:07:59 +01:00
|
|
|
import java.util.Random;
|
2019-01-26 22:20:35 +01:00
|
|
|
import java.util.UUID;
|
2019-01-20 00:07:59 +01:00
|
|
|
import java.util.function.Consumer;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
import com.minelittlepony.unicopia.player.IOwned;
|
2019-01-20 00:07:59 +01:00
|
|
|
import com.minelittlepony.util.shape.IShape;
|
|
|
|
import com.minelittlepony.util.vector.VecHelper;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2018-09-24 21:37:16 +02:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2019-01-20 00:07:59 +01:00
|
|
|
import net.minecraft.util.math.Vec3d;
|
2018-09-24 21:37:16 +02:00
|
|
|
import net.minecraft.world.World;
|
2018-09-12 01:29:49 +02:00
|
|
|
|
2018-09-26 17:53:12 +02:00
|
|
|
public interface ICaster<E extends EntityLivingBase> extends IOwned<E>, ILevelled {
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
void setEffect(IMagicEffect effect);
|
|
|
|
|
|
|
|
IMagicEffect getEffect();
|
|
|
|
|
2019-01-22 17:39:30 +01:00
|
|
|
SpellAffinity getAffinity();
|
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
default boolean hasEffect() {
|
|
|
|
return getEffect() != null;
|
|
|
|
}
|
|
|
|
|
2018-09-21 17:53:33 +02:00
|
|
|
/**
|
|
|
|
* Gets the entity directly responsible for casting.
|
|
|
|
*/
|
2018-09-12 01:29:49 +02:00
|
|
|
default Entity getEntity() {
|
|
|
|
return getOwner();
|
|
|
|
}
|
2018-09-24 21:37:16 +02:00
|
|
|
|
2019-01-26 22:20:35 +01:00
|
|
|
default UUID getUniqueId() {
|
|
|
|
return getEntity().getUniqueID();
|
|
|
|
}
|
|
|
|
|
2018-09-24 21:37:16 +02:00
|
|
|
default World getWorld() {
|
|
|
|
return getEntity().getEntityWorld();
|
|
|
|
}
|
|
|
|
|
|
|
|
default BlockPos getOrigin() {
|
|
|
|
return getEntity().getPosition();
|
|
|
|
}
|
2019-01-20 00:07:59 +01:00
|
|
|
|
2019-02-01 00:07:19 +01:00
|
|
|
default Vec3d getOriginVector() {
|
|
|
|
return getEntity().getPositionVector();
|
|
|
|
}
|
|
|
|
|
2019-01-20 00:07:59 +01:00
|
|
|
default void spawnParticles(IShape area, int count, Consumer<Vec3d> particleSpawner) {
|
|
|
|
Random rand = getWorld().rand;
|
|
|
|
|
2019-01-26 18:27:47 +01:00
|
|
|
double x = getEntity().posX;
|
|
|
|
double y = getEntity().posY;
|
|
|
|
double z = getEntity().posZ;
|
2019-01-20 00:07:59 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
particleSpawner.accept(area.computePoint(rand).add(x, y, z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
default Stream<Entity> findAllEntitiesInRange(double radius) {
|
|
|
|
return VecHelper.findAllEntitiesInRange(getEntity(), getWorld(), getOrigin(), radius);
|
|
|
|
}
|
2018-09-12 01:29:49 +02:00
|
|
|
}
|