Search in sources :

Example 1 with FluidParticleData

use of slimeknights.tconstruct.shared.particle.FluidParticleData in project TinkersConstruct by SlimeKnights.

the class SlurpingModifier method addFluidParticles.

/**
 * Adds the given number of fluid particles
 */
private static void addFluidParticles(Player player, FluidStack fluid, int count) {
    for (int i = 0; i < count; ++i) {
        Vec3 motion = new Vec3((RANDOM.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
        motion = motion.xRot(-player.getXRot() * DEGREE_TO_RADIANS);
        motion = motion.yRot(-player.getYRot() * DEGREE_TO_RADIANS);
        Vec3 position = new Vec3((RANDOM.nextFloat() - 0.5D) * 0.3D, (-RANDOM.nextFloat()) * 0.6D - 0.3D, 0.6D);
        position = position.xRot(-player.getXRot() * DEGREE_TO_RADIANS);
        position = position.yRot(-player.getYRot() * DEGREE_TO_RADIANS);
        position = position.add(player.getX(), player.getEyeY(), player.getZ());
        FluidParticleData data = new FluidParticleData(TinkerCommons.fluidParticle.get(), fluid);
        if (player.level instanceof ServerLevel) {
            ((ServerLevel) player.level).sendParticles(data, position.x, position.y, position.z, 1, motion.x, motion.y + 0.05D, motion.z, 0.0D);
        } else {
            player.level.addParticle(data, position.x, position.y, position.z, motion.x, motion.y + 0.05D, motion.z);
        }
    }
}
Also used : FluidParticleData(slimeknights.tconstruct.shared.particle.FluidParticleData) ServerLevel(net.minecraft.server.level.ServerLevel) Vec3(net.minecraft.world.phys.Vec3)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)1 Vec3 (net.minecraft.world.phys.Vec3)1 FluidParticleData (slimeknights.tconstruct.shared.particle.FluidParticleData)1