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