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);
}
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()));
}
}
}
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));
});
}
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);
}
}
}
Aggregations