2020-04-22 16:28:20 +02:00
|
|
|
package com.minelittlepony.unicopia.particles;
|
2020-01-27 11:05:22 +01:00
|
|
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
2020-04-15 18:12:00 +02:00
|
|
|
import com.minelittlepony.unicopia.util.shape.Shape;
|
2020-01-27 11:05:22 +01:00
|
|
|
|
2020-04-15 14:22:03 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
2020-01-27 11:05:22 +01:00
|
|
|
import net.minecraft.particle.ParticleEffect;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2020-04-15 14:22:03 +02:00
|
|
|
public interface ParticleSource {
|
2020-01-27 11:05:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gets the minecraft world
|
|
|
|
*/
|
|
|
|
World getWorld();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the center position where this caster is located.
|
|
|
|
*/
|
|
|
|
Vec3d getOriginVector();
|
|
|
|
|
2020-04-15 14:22:03 +02:00
|
|
|
Entity getEntity();
|
|
|
|
|
2020-01-27 11:05:22 +01:00
|
|
|
default void spawnParticles(ParticleEffect particleId, int count) {
|
2020-04-15 14:22:03 +02:00
|
|
|
ParticleUtils.spawnParticles(particleId, getEntity(), count);
|
2020-01-27 11:05:22 +01:00
|
|
|
}
|
|
|
|
|
2020-04-15 18:12:00 +02:00
|
|
|
default void spawnParticles(Shape area, int count, Consumer<Vec3d> particleSpawner) {
|
2020-01-27 11:05:22 +01:00
|
|
|
Vec3d pos = getOriginVector();
|
|
|
|
|
|
|
|
area.randomPoints(count, getWorld().random).stream()
|
|
|
|
.map(point -> point.add(pos))
|
|
|
|
.forEach(particleSpawner);
|
|
|
|
}
|
|
|
|
|
|
|
|
default void addParticle(ParticleEffect effect, Vec3d position, Vec3d velocity) {
|
|
|
|
getWorld().addParticle(effect, position.x, position.y, position.z, velocity.x, velocity.y, velocity.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|