Search in sources :

Example 1 with TankSegment

use of com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment in project Create by Creators-of-Create.

the class SpoutRenderer method renderSafe.

@Override
protected void renderSafe(SpoutTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    SmartFluidTankBehaviour tank = te.tank;
    if (tank == null)
        return;
    TankSegment primaryTank = tank.getPrimaryTank();
    FluidStack fluidStack = primaryTank.getRenderedFluid();
    float level = primaryTank.getFluidLevel().getValue(partialTicks);
    if (!fluidStack.isEmpty() && level != 0) {
        level = Math.max(level, 0.175f);
        float min = 2.5f / 16f;
        float max = min + (11 / 16f);
        float yOffset = (11 / 16f) * level;
        ms.pushPose();
        ms.translate(0, yOffset, 0);
        FluidRenderer.renderFluidBox(fluidStack, min, min - yOffset, min, max, min, max, buffer, ms, light, false);
        ms.popPose();
    }
    int processingTicks = te.processingTicks;
    float processingPT = processingTicks - partialTicks;
    float processingProgress = 1 - (processingPT - 5) / 10;
    processingProgress = Mth.clamp(processingProgress, 0, 1);
    float radius = 0;
    if (processingTicks != -1) {
        radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 1);
        AABB bb = new AABB(0.5, .5, 0.5, 0.5, -1.2, 0.5).inflate(radius / 32f);
        FluidRenderer.renderFluidBox(fluidStack, (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true);
    }
    float squeeze = radius;
    if (processingPT < 0)
        squeeze = 0;
    else if (processingPT < 2)
        squeeze = Mth.lerp(processingPT / 2f, 0, -1);
    else if (processingPT < 10)
        squeeze = -1;
    ms.pushPose();
    for (PartialModel bit : BITS) {
        CachedBufferer.partial(bit, te.getBlockState()).light(light).renderInto(ms, buffer.getBuffer(RenderType.solid()));
        ms.translate(0, -3 * squeeze / 32f, 0);
    }
    ms.popPose();
}
Also used : SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) FluidStack(net.minecraftforge.fluids.FluidStack) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment) AABB(net.minecraft.world.phys.AABB) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 2 with TankSegment

use of com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment in project Create by Creators-of-Create.

the class ItemDrainRenderer method renderFluid.

protected void renderFluid(ItemDrainTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light) {
    SmartFluidTankBehaviour tank = te.internalTank;
    if (tank == null)
        return;
    TankSegment primaryTank = tank.getPrimaryTank();
    FluidStack fluidStack = primaryTank.getRenderedFluid();
    float level = primaryTank.getFluidLevel().getValue(partialTicks);
    if (!fluidStack.isEmpty() && level != 0) {
        float yMin = 5f / 16f;
        float min = 2f / 16f;
        float max = min + (12 / 16f);
        float yOffset = (7 / 16f) * level;
        ms.pushPose();
        ms.translate(0, yOffset, 0);
        FluidRenderer.renderFluidBox(fluidStack, min, yMin - yOffset, min, max, yMin, max, buffer, ms, light, false);
        ms.popPose();
    }
    ItemStack heldItemStack = te.getHeldItemStack();
    if (heldItemStack.isEmpty())
        return;
    FluidStack fluidStack2 = EmptyingByBasin.emptyItem(te.getLevel(), heldItemStack, true).getFirst();
    if (fluidStack2.isEmpty()) {
        if (fluidStack.isEmpty())
            return;
        fluidStack2 = fluidStack;
    }
    int processingTicks = te.processingTicks;
    float processingPT = te.processingTicks - partialTicks;
    float processingProgress = 1 - (processingPT - 5) / 10;
    processingProgress = Mth.clamp(processingProgress, 0, 1);
    float radius = 0;
    if (processingTicks != -1) {
        radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 1);
        AABB bb = new AABB(0.5, 1.0, 0.5, 0.5, 0.25, 0.5).inflate(radius / 32f);
        FluidRenderer.renderFluidBox(fluidStack2, (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true);
    }
}
Also used : SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) FluidStack(net.minecraftforge.fluids.FluidStack) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment) TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) ItemStack(net.minecraft.world.item.ItemStack) AABB(net.minecraft.world.phys.AABB)

Example 3 with TankSegment

use of com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment in project Create by Creators-of-Create.

the class BasinRenderer method renderFluids.

protected float renderFluids(BasinTileEntity basin, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    SmartFluidTankBehaviour inputFluids = basin.getBehaviour(SmartFluidTankBehaviour.INPUT);
    SmartFluidTankBehaviour outputFluids = basin.getBehaviour(SmartFluidTankBehaviour.OUTPUT);
    SmartFluidTankBehaviour[] tanks = { inputFluids, outputFluids };
    float totalUnits = basin.getTotalFluidUnits(partialTicks);
    if (totalUnits < 1)
        return 0;
    float fluidLevel = Mth.clamp(totalUnits / 2000, 0, 1);
    fluidLevel = 1 - ((1 - fluidLevel) * (1 - fluidLevel));
    float xMin = 2 / 16f;
    float xMax = 2 / 16f;
    final float yMin = 2 / 16f;
    final float yMax = yMin + 12 / 16f * fluidLevel;
    final float zMin = 2 / 16f;
    final float zMax = 14 / 16f;
    for (SmartFluidTankBehaviour behaviour : tanks) {
        if (behaviour == null)
            continue;
        for (TankSegment tankSegment : behaviour.getTanks()) {
            FluidStack renderedFluid = tankSegment.getRenderedFluid();
            if (renderedFluid.isEmpty())
                continue;
            float units = tankSegment.getTotalUnits(partialTicks);
            if (units < 1)
                continue;
            float partial = Mth.clamp(units / totalUnits, 0, 1);
            xMax += partial * 12 / 16f;
            FluidRenderer.renderFluidBox(renderedFluid, xMin, yMin, zMin, xMax, yMax, zMax, buffer, ms, light, false);
            xMin = xMax;
        }
    }
    return yMax;
}
Also used : SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) FluidStack(net.minecraftforge.fluids.FluidStack) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)

Example 4 with TankSegment

use of com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment in project Create by Creators-of-Create.

the class BasinTileEntity method getTotalFluidUnits.

public float getTotalFluidUnits(float partialTicks) {
    int renderedFluids = 0;
    float totalUnits = 0;
    for (SmartFluidTankBehaviour behaviour : getTanks()) {
        if (behaviour == null)
            continue;
        for (TankSegment tankSegment : behaviour.getTanks()) {
            if (tankSegment.getRenderedFluid().isEmpty())
                continue;
            float units = tankSegment.getTotalUnits(partialTicks);
            if (units < 1)
                continue;
            totalUnits += units;
            renderedFluids++;
        }
    }
    if (renderedFluids == 0)
        return 0;
    if (totalUnits < 1)
        return 0;
    return totalUnits;
}
Also used : SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)

Example 5 with TankSegment

use of com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment 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)

Aggregations

SmartFluidTankBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour)8 TankSegment (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)8 FluidStack (net.minecraftforge.fluids.FluidStack)4 ItemStack (net.minecraft.world.item.ItemStack)3 FluidParticleData (com.simibubi.create.content.contraptions.fluids.particle.FluidParticleData)2 SmartInventory (com.simibubi.create.foundation.item.SmartInventory)2 AABB (net.minecraft.world.phys.AABB)2 PartialModel (com.jozufozu.flywheel.core.PartialModel)1 AllRecipeTypes (com.simibubi.create.AllRecipeTypes)1 BasinTileEntity (com.simibubi.create.content.contraptions.processing.BasinTileEntity)1 ProcessingRecipeParams (com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams)1 HeatLevel (com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel)1 TransportedItemStack (com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack)1 FluidIngredient (com.simibubi.create.foundation.fluid.FluidIngredient)1 FilteringBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour)1 Iterate (com.simibubi.create.foundation.utility.Iterate)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 LinkedList (java.util.LinkedList)1