Unicopia/src/main/java/com/minelittlepony/unicopia/particle/ParticleSource.java

45 lines
1.4 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia.particle;
2020-01-27 11:05:22 +01:00
import java.util.function.Consumer;
import com.minelittlepony.unicopia.util.shape.PointGenerator;
2020-01-27 11:05:22 +01: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-01-27 11:05:22 +01:00
default void spawnParticles(ParticleEffect particleId, int count) {
ParticleUtils.spawnParticles(particleId, getEntity(), count);
2020-01-27 11:05:22 +01: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
default void spawnParticles(Vec3d pos, PointGenerator area, int count, Consumer<Vec3d> particleSpawner) {
area.offset(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-06-23 16:24:45 +02:00
getReferenceWorld().addParticle(effect, position.x, position.y, position.z, velocity.x, velocity.y, velocity.z);
2020-01-27 11:05:22 +01:00
}
}