2020-09-22 15:11:20 +02:00
|
|
|
package com.minelittlepony.unicopia.particle;
|
2020-01-27 11:05:22 +01:00
|
|
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
2022-10-01 23:53:18 +02:00
|
|
|
import com.minelittlepony.unicopia.util.shape.PointGenerator;
|
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-24 22:40:02 +02:00
|
|
|
public interface ParticleSource extends ParticleSpawner {
|
2020-01-27 11:05:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gets the minecraft world
|
|
|
|
*/
|
2022-06-23 16:24:45 +02:00
|
|
|
World getReferenceWorld();
|
2020-01-27 11:05:22 +01:00
|
|
|
|
2020-10-02 09:39:00 +02:00
|
|
|
Entity getEntity();
|
|
|
|
|
2020-01-27 11:05:22 +01:00
|
|
|
/**
|
|
|
|
* Gets the center position where this caster is located.
|
|
|
|
*/
|
2020-10-02 09:39:00 +02:00
|
|
|
default Vec3d getOriginVector() {
|
|
|
|
return getEntity().getPos();
|
|
|
|
}
|
2020-04-15 14:22:03 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-10-01 23:53:18 +02:00
|
|
|
default void spawnParticles(PointGenerator area, int count, Consumer<Vec3d> particleSpawner) {
|
2021-03-03 19:03:16 +01:00
|
|
|
spawnParticles(getOriginVector(), area, count, particleSpawner);
|
|
|
|
}
|
2020-01-27 11:05:22 +01:00
|
|
|
|
2022-10-01 23:53:18 +02:00
|
|
|
default void spawnParticles(Vec3d pos, PointGenerator area, int count, Consumer<Vec3d> particleSpawner) {
|
2022-10-08 10:57:16 +02:00
|
|
|
area.translate(pos).randomPoints(count, getReferenceWorld().random).forEach(particleSpawner);
|
2020-01-27 11:05:22 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 22:40:02 +02:00
|
|
|
@Override
|
2020-01-27 11:05:22 +01:00
|
|
|
default void addParticle(ParticleEffect effect, Vec3d position, Vec3d velocity) {
|
2022-10-03 23:44:30 +02:00
|
|
|
ParticleUtils.spawnParticle(getReferenceWorld(), effect, position, velocity);
|
2020-01-27 11:05:22 +01:00
|
|
|
}
|
|
|
|
}
|