Search in sources :

Example 1 with FluidParticleData

use of com.simibubi.create.content.contraptions.fluids.particle.FluidParticleData in project Create by Creators-of-Create.

the class BasinTileEntity method createMovingFluidParticles.

private void createMovingFluidParticles(float surface, int segments) {
    Vec3 pointer = new Vec3(1, 0, 0).scale(1 / 16f);
    float interval = 360f / segments;
    Vec3 centerOf = VecHelper.getCenterOf(worldPosition);
    float intervalOffset = (AnimationTickHolder.getTicks() * 18) % 360;
    int currentSegment = 0;
    for (SmartFluidTankBehaviour behaviour : getTanks()) {
        if (behaviour == null)
            continue;
        for (TankSegment tankSegment : behaviour.getTanks()) {
            if (tankSegment.isEmpty(0))
                continue;
            float angle = interval * (1 + currentSegment) + intervalOffset;
            Vec3 vec = centerOf.add(VecHelper.rotate(pointer, angle, Axis.Y));
            level.addAlwaysVisibleParticle(new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), vec.x(), surface, vec.z(), 1, 0, 0);
            currentSegment++;
        }
    }
}
Also used : FluidParticleData(com.simibubi.create.content.contraptions.fluids.particle.FluidParticleData) SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) Vec3(net.minecraft.world.phys.Vec3) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)

Example 2 with FluidParticleData

use of com.simibubi.create.content.contraptions.fluids.particle.FluidParticleData in project Create by Creators-of-Create.

the class BasinTileEntity method createFluidParticles.

private void createFluidParticles() {
    Random r = level.random;
    if (!visualizedOutputFluids.isEmpty())
        createOutputFluidParticles(r);
    if (!areFluidsMoving && r.nextFloat() > 1 / 8f)
        return;
    int segments = 0;
    for (SmartFluidTankBehaviour behaviour : getTanks()) {
        if (behaviour == null)
            continue;
        for (TankSegment tankSegment : behaviour.getTanks()) if (!tankSegment.isEmpty(0))
            segments++;
    }
    if (segments < 2)
        return;
    float totalUnits = getTotalFluidUnits(0);
    if (totalUnits == 0)
        return;
    float fluidLevel = Mth.clamp(totalUnits / 2000, 0, 1);
    float rim = 2 / 16f;
    float space = 12 / 16f;
    float surface = worldPosition.getY() + rim + space * fluidLevel + 1 / 32f;
    if (areFluidsMoving) {
        createMovingFluidParticles(surface, segments);
        return;
    }
    for (SmartFluidTankBehaviour behaviour : getTanks()) {
        if (behaviour == null)
            continue;
        for (TankSegment tankSegment : behaviour.getTanks()) {
            if (tankSegment.isEmpty(0))
                continue;
            float x = worldPosition.getX() + rim + space * r.nextFloat();
            float z = worldPosition.getZ() + rim + space * r.nextFloat();
            level.addAlwaysVisibleParticle(new FluidParticleData(AllParticleTypes.BASIN_FLUID.get(), tankSegment.getRenderedFluid()), x, surface, z, 0, 0, 0);
        }
    }
}
Also used : FluidParticleData(com.simibubi.create.content.contraptions.fluids.particle.FluidParticleData) Random(java.util.Random) SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)

Aggregations

FluidParticleData (com.simibubi.create.content.contraptions.fluids.particle.FluidParticleData)2 SmartFluidTankBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour)2 TankSegment (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)2 Random (java.util.Random)1 Vec3 (net.minecraft.world.phys.Vec3)1