Search in sources :

Example 6 with SmartFluidTankBehaviour

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

the class ComparatorUtil method levelOfSmartFluidTank.

public static int levelOfSmartFluidTank(BlockGetter world, BlockPos pos) {
    SmartFluidTankBehaviour fluidBehaviour = TileEntityBehaviour.get(world, pos, SmartFluidTankBehaviour.TYPE);
    if (fluidBehaviour == null)
        return 0;
    SmartFluidTank primaryHandler = fluidBehaviour.getPrimaryHandler();
    double fillFraction = (double) primaryHandler.getFluid().getAmount() / primaryHandler.getCapacity();
    return fractionToRedstoneLevel(fillFraction);
}
Also used : SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) SmartFluidTank(com.simibubi.create.foundation.fluid.SmartFluidTank)

Example 7 with SmartFluidTankBehaviour

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

the class MechanicalMixerTileEntity method renderParticles.

public void renderParticles() {
    Optional<BasinTileEntity> basin = getBasin();
    if (!basin.isPresent() || level == null)
        return;
    for (SmartInventory inv : basin.get().getInvs()) {
        for (int slot = 0; slot < inv.getSlots(); slot++) {
            ItemStack stackInSlot = inv.getItem(slot);
            if (stackInSlot.isEmpty())
                continue;
            ItemParticleOption data = new ItemParticleOption(ParticleTypes.ITEM, stackInSlot);
            spillParticle(data);
        }
    }
    for (SmartFluidTankBehaviour behaviour : basin.get().getTanks()) {
        if (behaviour == null)
            continue;
        for (TankSegment tankSegment : behaviour.getTanks()) {
            if (tankSegment.isEmpty(0))
                continue;
            spillParticle(FluidFX.getFluidParticle(tankSegment.getRenderedFluid()));
        }
    }
}
Also used : BasinTileEntity(com.simibubi.create.content.contraptions.processing.BasinTileEntity) SmartInventory(com.simibubi.create.foundation.item.SmartInventory) SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) ItemParticleOption(net.minecraft.core.particles.ItemParticleOption) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment) ItemStack(net.minecraft.world.item.ItemStack)

Example 8 with SmartFluidTankBehaviour

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

the class BasinTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    behaviours.add(new DirectBeltInputBehaviour(this));
    filtering = new FilteringBehaviour(this, new BasinValueBox()).moveText(new Vec3(2, -8, 0)).withCallback(newFilter -> contentsChanged = true).forRecipes();
    behaviours.add(filtering);
    inputTank = new SmartFluidTankBehaviour(SmartFluidTankBehaviour.INPUT, this, 2, 1000, true).whenFluidUpdates(() -> contentsChanged = true);
    outputTank = new SmartFluidTankBehaviour(SmartFluidTankBehaviour.OUTPUT, this, 2, 1000, true).whenFluidUpdates(() -> contentsChanged = true).forbidInsertion();
    behaviours.add(inputTank);
    behaviours.add(outputTank);
    fluidCapability = LazyOptional.of(() -> {
        LazyOptional<? extends IFluidHandler> inputCap = inputTank.getCapability();
        LazyOptional<? extends IFluidHandler> outputCap = outputTank.getCapability();
        return new CombinedTankWrapper(inputCap.orElse(null), outputCap.orElse(null));
    });
}
Also used : DirectBeltInputBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour) FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) LazyOptional(net.minecraftforge.common.util.LazyOptional) Vec3(net.minecraft.world.phys.Vec3) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) CombinedTankWrapper(com.simibubi.create.foundation.fluid.CombinedTankWrapper)

Example 9 with SmartFluidTankBehaviour

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

SmartFluidTankBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour)9 TankSegment (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)7 FluidStack (net.minecraftforge.fluids.FluidStack)3 FluidParticleData (com.simibubi.create.content.contraptions.fluids.particle.FluidParticleData)2 ItemStack (net.minecraft.world.item.ItemStack)2 AABB (net.minecraft.world.phys.AABB)2 Vec3 (net.minecraft.world.phys.Vec3)2 PartialModel (com.jozufozu.flywheel.core.PartialModel)1 BasinTileEntity (com.simibubi.create.content.contraptions.processing.BasinTileEntity)1 TransportedItemStack (com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack)1 CombinedTankWrapper (com.simibubi.create.foundation.fluid.CombinedTankWrapper)1 SmartFluidTank (com.simibubi.create.foundation.fluid.SmartFluidTank)1 SmartInventory (com.simibubi.create.foundation.item.SmartInventory)1 DirectBeltInputBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour)1 FilteringBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour)1 Random (java.util.Random)1 ItemParticleOption (net.minecraft.core.particles.ItemParticleOption)1 LazyOptional (net.minecraftforge.common.util.LazyOptional)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1