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;
|
2023-08-05 16:45:36 +02:00
|
|
|
import java.util.function.Supplier;
|
2020-01-27 11:05:22 +01:00
|
|
|
|
2022-12-19 18:13:15 +01:00
|
|
|
import com.minelittlepony.unicopia.EntityConvertable;
|
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;
|
|
|
|
|
2022-12-19 18:13:15 +01:00
|
|
|
public interface ParticleSource<E extends Entity> extends ParticleSpawner, EntityConvertable<E> {
|
2020-04-15 14:22:03 +02:00
|
|
|
|
2023-08-05 16:45:36 +02:00
|
|
|
default void spawnParticles(ParticleEffect particleId, Supplier<Vec3d> posSupplier, Supplier<Vec3d> velSupplier, int count) {
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
spawnParticle(particleId, posSupplier, velSupplier);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
default void spawnParticle(ParticleEffect particleId, Supplier<Vec3d> posSupplier, Supplier<Vec3d> velSupplier) {
|
|
|
|
addParticle(particleId, getOriginVector().add(posSupplier.get()), velSupplier.get());
|
|
|
|
}
|
|
|
|
|
2020-01-27 11:05:22 +01:00
|
|
|
default void spawnParticles(ParticleEffect particleId, int count) {
|
2022-12-19 18:13:15 +01:00
|
|
|
ParticleUtils.spawnParticles(particleId, asEntity(), 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-12-19 19:50:15 +01:00
|
|
|
area.translate(pos).randomPoints(count, asWorld().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-12-19 19:50:15 +01:00
|
|
|
ParticleUtils.spawnParticle(asWorld(), effect, position, velocity);
|
2020-01-27 11:05:22 +01:00
|
|
|
}
|
|
|
|
}
|