Search in sources :

Example 41 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.

the class CuckooClockRenderer method renderSafe.

@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    if (!(te instanceof CuckooClockTileEntity))
        return;
    CuckooClockTileEntity clock = (CuckooClockTileEntity) te;
    BlockState blockState = te.getBlockState();
    Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING);
    VertexConsumer vb = buffer.getBuffer(RenderType.solid());
    // Render Hands
    SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
    SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
    float hourAngle = clock.hourHand.get(partialTicks);
    float minuteAngle = clock.minuteHand.get(partialTicks);
    rotateHand(hourHand, hourAngle, direction).light(light).renderInto(ms, vb);
    rotateHand(minuteHand, minuteAngle, direction).light(light).renderInto(ms, vb);
    // Doors
    SuperByteBuffer leftDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState);
    SuperByteBuffer rightDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState);
    float angle = 0;
    float offset = 0;
    if (clock.animationType != null) {
        float value = clock.animationProgress.get(partialTicks);
        int step = clock.animationType == Animation.SURPRISE ? 3 : 15;
        for (int phase = 30; phase <= 60; phase += step) {
            float local = value - phase;
            if (local < -step / 3)
                continue;
            else if (local < 0)
                angle = Mth.lerp(((value - (phase - 5)) / 5), 0, 135);
            else if (local < step / 3)
                angle = 135;
            else if (local < 2 * step / 3)
                angle = Mth.lerp(((value - (phase + 5)) / 5), 135, 0);
        }
    }
    rotateDoor(leftDoor, angle, true, direction).light(light).renderInto(ms, vb);
    rotateDoor(rightDoor, angle, false, direction).light(light).renderInto(ms, vb);
    // Figure
    if (clock.animationType != Animation.NONE) {
        offset = -(angle / 135) * 1 / 2f + 10 / 16f;
        PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
        SuperByteBuffer figure = CachedBufferer.partial(partialModel, blockState);
        figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise())));
        figure.translate(offset, 0, 0);
        figure.light(light).renderInto(ms, vb);
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 42 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.

the class DrillRenderer method renderInContraption.

public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) {
    BlockState state = context.state;
    SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.DRILL_HEAD, state);
    Direction facing = state.getValue(DrillBlock.FACING);
    float speed = (float) (context.contraption.stalled || !VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()) ? context.getAnimationSpeed() : 0);
    float time = AnimationTickHolder.getRenderTime() / 20;
    float angle = (float) (((time * speed) % 360));
    superBuffer.transform(matrices.getModel()).centre().rotateY(AngleHelper.horizontalAngle(facing)).rotateX(AngleHelper.verticalAngle(facing)).rotateZ(angle).unCentre().light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Direction(net.minecraft.core.Direction)

Example 43 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.

the class HarvesterRenderer method renderSafe.

@Override
protected void renderSafe(HarvesterTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    BlockState blockState = te.getBlockState();
    SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.HARVESTER_BLADE, blockState);
    transform(te.getLevel(), blockState.getValue(HarvesterBlock.FACING), superBuffer, te.getAnimatedSpeed());
    superBuffer.light(light).renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer)

Example 44 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.

the class HarvesterRenderer method renderInContraption.

public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffers) {
    BlockState blockState = context.state;
    Direction facing = blockState.getValue(HORIZONTAL_FACING);
    SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.HARVESTER_BLADE, blockState);
    float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()) ? context.getAnimationSpeed() : 0);
    if (context.contraption.stalled)
        speed = 0;
    superBuffer.transform(matrices.getModel());
    transform(context.world, facing, superBuffer, speed);
    superBuffer.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), buffers.getBuffer(RenderType.cutoutMipped()));
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Direction(net.minecraft.core.Direction)

Example 45 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.

the class BeltTunnelRenderer method renderSafe.

@Override
protected void renderSafe(BeltTunnelTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    SuperByteBuffer flapBuffer = CachedBufferer.partial(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
    VertexConsumer vb = buffer.getBuffer(RenderType.solid());
    Vec3 pivot = VecHelper.voxelSpace(0, 10, 1f);
    TransformStack msr = TransformStack.cast(ms);
    for (Direction direction : Iterate.directions) {
        if (!te.flaps.containsKey(direction))
            continue;
        float horizontalAngle = AngleHelper.horizontalAngle(direction.getOpposite());
        float f = te.flaps.get(direction).get(partialTicks);
        ms.pushPose();
        msr.centre().rotateY(horizontalAngle).unCentre();
        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 * (direction.getAxis() == Axis.X ? 1 : -1);
            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();
    }
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Vec3(net.minecraft.world.phys.Vec3) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) TransformStack(com.jozufozu.flywheel.util.transform.TransformStack) Direction(net.minecraft.core.Direction)

Aggregations

SuperByteBuffer (com.simibubi.create.foundation.render.SuperByteBuffer)53 BlockState (net.minecraft.world.level.block.state.BlockState)30 Direction (net.minecraft.core.Direction)20 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)18 BlockPos (net.minecraft.core.BlockPos)12 PartialModel (com.jozufozu.flywheel.core.PartialModel)11 Axis (net.minecraft.core.Direction.Axis)7 Vec3 (net.minecraft.world.phys.Vec3)7 TransformStack (com.jozufozu.flywheel.util.transform.TransformStack)5 PoseStack (com.mojang.blaze3d.vertex.PoseStack)5 BlockState (net.minecraft.block.BlockState)5 AxisDirection (net.minecraft.core.Direction.AxisDirection)4 BufferBuilder (com.mojang.blaze3d.vertex.BufferBuilder)3 IRotate (com.simibubi.create.content.contraptions.base.IRotate)3 RenderType (net.minecraft.client.renderer.RenderType)3 Direction (net.minecraft.util.Direction)3 ShadeSeparatedBufferBuilder (com.jozufozu.flywheel.core.model.ShadeSeparatedBufferBuilder)2 ShadeSeparatingVertexConsumer (com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer)2 Random (java.util.Random)2 BlockRenderDispatcher (net.minecraft.client.renderer.block.BlockRenderDispatcher)2