Search in sources :

Example 16 with PartialModel

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()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Quaternion(com.mojang.math.Quaternion) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 17 with PartialModel

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()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Aggregations

PartialModel (com.jozufozu.flywheel.core.PartialModel)17 SuperByteBuffer (com.simibubi.create.foundation.render.SuperByteBuffer)11 Direction (net.minecraft.core.Direction)8 BlockState (net.minecraft.world.level.block.state.BlockState)8 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)5 PoseStack (com.mojang.blaze3d.vertex.PoseStack)4 TransformStack (com.jozufozu.flywheel.util.transform.TransformStack)2 AxisDirection (net.minecraft.core.Direction.AxisDirection)2 Block (net.minecraft.world.level.block.Block)2 Vec3 (net.minecraft.world.phys.Vec3)2 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)2 Matrix3f (com.mojang.math.Matrix3f)1 Quaternion (com.mojang.math.Quaternion)1 IRotate (com.simibubi.create.content.contraptions.base.IRotate)1 Mode (com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode)1 HeatLevel (com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel)1 BlueprintSection (com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSection)1 SpriteShiftEntry (com.simibubi.create.foundation.block.render.SpriteShiftEntry)1 SmartFluidTankBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour)1 TankSegment (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)1