use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class StabilizedBearingMovementBehaviour method renderInContraption.
@Override
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) {
if (Backend.isOn())
return;
Direction facing = context.state.getValue(BlockStateProperties.FACING);
PartialModel top = AllBlockPartials.BEARING_TOP;
SuperByteBuffer superBuffer = CachedBufferer.partial(top, context.state);
float renderPartialTicks = AnimationTickHolder.getPartialTicks();
// rotate to match blockstate
Quaternion orientation = BearingInstance.getBlockStateOrientation(facing);
// rotate against parent
float angle = getCounterRotationAngle(context, facing, renderPartialTicks) * facing.getAxisDirection().getStep();
Quaternion rotation = facing.step().rotationDegrees(angle);
rotation.mul(orientation);
orientation = rotation;
superBuffer.transform(matrices.getModel());
superBuffer.rotateCentered(orientation);
// render
superBuffer.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
}
use of com.jozufozu.flywheel.core.PartialModel in project Create by Creators-of-Create.
the class BearingRenderer method renderSafe.
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (Backend.canUseInstancing(te.getLevel()))
return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
IBearingTileEntity bearingTe = (IBearingTileEntity) te;
final Direction facing = te.getBlockState().getValue(BlockStateProperties.FACING);
PartialModel top = bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
SuperByteBuffer superBuffer = CachedBufferer.partial(top, te.getBlockState());
float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light);
if (facing.getAxis().isHorizontal())
superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
superBuffer.rotateCentered(Direction.EAST, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing)));
superBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
Aggregations