use of com.jozufozu.flywheel.core.PartialModel 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.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class DeployerTileEntity method getHandOffset.
@OnlyIn(Dist.CLIENT)
public float getHandOffset(float partialTicks) {
if (isVirtual())
return animatedOffset.getValue(partialTicks);
float progress = 0;
int timerSpeed = getTimerSpeed();
PartialModel handPose = getHandPose();
if (state == State.EXPANDING)
progress = 1 - (timer - partialTicks * timerSpeed) / 1000f;
if (state == State.RETRACTING)
progress = (timer - partialTicks * timerSpeed) / 1000f;
float handLength = handPose == AllBlockPartials.DEPLOYER_HAND_POINTING ? 0 : handPose == AllBlockPartials.DEPLOYER_HAND_HOLDING ? 4 / 16f : 3 / 16f;
float distance = Math.min(Mth.clamp(progress, 0, 1) * (reach + handLength), 21 / 16f);
return distance;
}
use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class BeltRenderer method renderSafe.
@Override
protected void renderSafe(BeltTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (!Backend.canUseInstancing(te.getLevel())) {
BlockState blockState = te.getBlockState();
if (!AllBlocks.BELT.has(blockState))
return;
BeltSlope beltSlope = blockState.getValue(BeltBlock.SLOPE);
BeltPart part = blockState.getValue(BeltBlock.PART);
Direction facing = blockState.getValue(BeltBlock.HORIZONTAL_FACING);
AxisDirection axisDirection = facing.getAxisDirection();
boolean downward = beltSlope == BeltSlope.DOWNWARD;
boolean upward = beltSlope == BeltSlope.UPWARD;
boolean diagonal = downward || upward;
boolean start = part == BeltPart.START;
boolean end = part == BeltPart.END;
boolean sideways = beltSlope == BeltSlope.SIDEWAYS;
boolean alongX = facing.getAxis() == Axis.X;
PoseStack localTransforms = new PoseStack();
TransformStack msr = TransformStack.cast(localTransforms);
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
float renderTick = AnimationTickHolder.getRenderTime(te.getLevel());
msr.centre().rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0)).rotateZ(sideways ? 90 : 0).rotateX(!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0).unCentre();
if (downward || beltSlope == BeltSlope.VERTICAL && axisDirection == AxisDirection.POSITIVE) {
boolean b = start;
start = end;
end = b;
}
DyeColor color = te.color.orElse(null);
for (boolean bottom : Iterate.trueAndFalse) {
PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom);
SuperByteBuffer beltBuffer = CachedBufferer.partial(beltPartial, blockState).light(light);
SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom);
// UV shift
float speed = te.getSpeed();
if (speed != 0 || te.color.isPresent()) {
float time = renderTick * axisDirection.getStep();
if (diagonal && (downward ^ alongX) || !sideways && !diagonal && alongX || sideways && axisDirection == AxisDirection.NEGATIVE)
speed = -speed;
float scrollMult = diagonal ? 3f / 8f : 0.5f;
float spriteSize = spriteShift.getTarget().getV1() - spriteShift.getTarget().getV0();
double scroll = speed * time / (31.5 * 16) + (bottom ? 0.5 : 0.0);
scroll = scroll - Math.floor(scroll);
scroll = scroll * spriteSize * scrollMult;
beltBuffer.shiftUVScrolling(spriteShift, (float) scroll);
}
beltBuffer.transform(localTransforms).renderInto(ms, vb);
// Diagonal belt do not have a separate bottom model
if (diagonal)
break;
}
if (te.hasPulley()) {
Direction dir = sideways ? Direction.UP : blockState.getValue(BeltBlock.HORIZONTAL_FACING).getClockWise();
Supplier<PoseStack> matrixStackSupplier = () -> {
PoseStack stack = new PoseStack();
TransformStack stacker = TransformStack.cast(stack);
stacker.centre();
if (dir.getAxis() == Axis.X)
stacker.rotateY(90);
if (dir.getAxis() == Axis.Y)
stacker.rotateX(90);
stacker.rotateX(90);
stacker.unCentre();
return stack;
};
SuperByteBuffer superBuffer = CachedBufferer.partialDirectional(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier);
KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
}
}
renderItems(te, partialTicks, ms, buffer, light, overlay);
}
use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class BlueprintRenderer method render.
@Override
public void render(BlueprintEntity entity, float yaw, float pt, PoseStack ms, MultiBufferSource buffer, int light) {
PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3 : entity.size == 2 ? AllBlockPartials.CRAFTING_BLUEPRINT_2x2 : AllBlockPartials.CRAFTING_BLUEPRINT_1x1;
SuperByteBuffer sbb = CachedBufferer.partial(partialModel, Blocks.AIR.defaultBlockState());
sbb.rotateY(-yaw).rotateX(90.0F + entity.getXRot()).translate(-.5, -1 / 32f, -.5);
if (entity.size == 2)
sbb.translate(.5, 0, -.5);
sbb.forEntityRender().light(light).renderInto(ms, buffer.getBuffer(Sheets.solidBlockSheet()));
super.render(entity, yaw, pt, ms, buffer, light);
ms.pushPose();
float fakeNormalXRotation = -15;
int bl = light >> 4 & 0xf;
int sl = light >> 20 & 0xf;
boolean vertical = entity.getXRot() != 0;
if (entity.getXRot() == -90)
fakeNormalXRotation = -45;
else if (entity.getXRot() == 90 || yaw % 180 != 0) {
bl /= 1.35;
sl /= 1.35;
}
int itemLight = Mth.floor(sl + .5) << 20 | (Mth.floor(bl + .5) & 0xf) << 4;
TransformStack.cast(ms).rotateY(vertical ? 0 : -yaw).rotateX(fakeNormalXRotation);
Matrix3f copy = ms.last().normal().copy();
ms.popPose();
ms.pushPose();
TransformStack.cast(ms).rotateY(-yaw).rotateX(entity.getXRot()).translate(0, 0, 1 / 32f + .001);
if (entity.size == 3)
ms.translate(-1, -1, 0);
PoseStack squashedMS = new PoseStack();
squashedMS.last().pose().multiply(ms.last().pose());
for (int x = 0; x < entity.size; x++) {
squashedMS.pushPose();
for (int y = 0; y < entity.size; y++) {
BlueprintSection section = entity.getSection(x * entity.size + y);
Couple<ItemStack> displayItems = section.getDisplayItems();
squashedMS.pushPose();
squashedMS.scale(.5f, .5f, 1 / 1024f);
displayItems.forEachWithContext((stack, primary) -> {
if (stack.isEmpty())
return;
squashedMS.pushPose();
if (!primary) {
squashedMS.translate(0.325f, -0.325f, 1);
squashedMS.scale(.625f, .625f, 1);
}
squashedMS.last().normal().load(copy);
Minecraft.getInstance().getItemRenderer().renderStatic(stack, TransformType.GUI, itemLight, OverlayTexture.NO_OVERLAY, squashedMS, buffer, 0);
squashedMS.popPose();
});
squashedMS.popPose();
squashedMS.translate(1, 0, 0);
}
squashedMS.popPose();
squashedMS.translate(0, 1, 0);
}
ms.popPose();
}
use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class FunnelRenderer method renderSafe.
@Override
protected void renderSafe(FunnelTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (!te.hasFlap() || Backend.canUseInstancing(te.getLevel()))
return;
BlockState blockState = te.getBlockState();
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP : AllBlockPartials.BELT_FUNNEL_FLAP);
SuperByteBuffer flapBuffer = CachedBufferer.partial(partialModel, blockState);
Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f);
TransformStack msr = TransformStack.cast(ms);
float horizontalAngle = AngleHelper.horizontalAngle(FunnelBlock.getFunnelFacing(blockState).getOpposite());
float f = te.flap.get(partialTicks);
ms.pushPose();
msr.centre().rotateY(horizontalAngle).unCentre();
ms.translate(0, 0, -te.getFlapOffset());
for (int segment = 0; segment <= 3; segment++) {
ms.pushPose();
float intensity = segment == 3 ? 1.5f : segment + 1;
float abs = Math.abs(f);
float flapAngle = Mth.sin((float) ((1 - abs) * Math.PI * intensity)) * 30 * -f;
if (f > 0)
flapAngle *= .5f;
msr.translate(pivot).rotateX(flapAngle).translateBack(pivot);
flapBuffer.light(light).renderInto(ms, vb);
ms.popPose();
ms.translate(-3 / 16f, 0, 0);
}
ms.popPose();
}
Aggregations