Search in sources :

Example 1 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project createaddition by mrh0.

the class RollingMillRenderer 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 (Backend.canUseInstancing(te.getLevel()))
        return;
    BlockState blockState = te.getBlockState();
    BlockPos pos = te.getBlockPos();
    VertexConsumer vb = buffer.getBuffer(RenderType.solid());
    int packedLightmapCoords = LevelRenderer.getLightColor(te.getLevel(), pos);
    // SuperByteBuffer shaft = AllBlockPartials.SHAFT_HALF.renderOn(blockState);
    SuperByteBuffer shaft = CachedBufferer.partial(AllBlockPartials.SHAFT_HALF, blockState);
    Axis axis = getRotationAxisOf(te);
    shaft.rotateCentered(Direction.UP, axis == Axis.Z ? 0 : 90 * (float) Math.PI / 180f).translate(0, 4f / 16f, 0).rotateCentered(Direction.NORTH, getAngleForTe(te, pos, axis)).light(packedLightmapCoords).renderInto(ms, vb);
    shaft.rotateCentered(Direction.UP, axis == Axis.Z ? 180 * (float) Math.PI / 180f : 270 * (float) Math.PI / 180f).translate(0, 4f / 16f, 0).rotateCentered(Direction.NORTH, -getAngleForTe(te, pos, axis)).light(packedLightmapCoords).renderInto(ms, vb);
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) BlockPos(net.minecraft.core.BlockPos) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) Axis(net.minecraft.core.Direction.Axis)

Example 2 with SuperByteBuffer

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

the class SBBContraptionManager method renderContraptionLayerSBB.

private void renderContraptionLayerSBB(ContraptionRenderInfo renderInfo, RenderType layer, VertexConsumer consumer) {
    if (!renderInfo.isVisible())
        return;
    SuperByteBuffer contraptionBuffer = CreateClient.BUFFER_CACHE.get(CONTRAPTION, Pair.of(renderInfo.contraption, layer), () -> ContraptionRenderDispatcher.buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer));
    if (!contraptionBuffer.isEmpty()) {
        ContraptionMatrices matrices = renderInfo.getMatrices();
        contraptionBuffer.transform(matrices.getModel()).light(matrices.getWorld()).hybridLight().renderInto(matrices.getViewProjection(), consumer);
    }
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer)

Example 3 with SuperByteBuffer

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

the class SawRenderer method renderInContraption.

public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) {
    BlockState state = context.state;
    Direction facing = state.getValue(SawBlock.FACING);
    Vec3 facingVec = Vec3.atLowerCornerOf(context.state.getValue(SawBlock.FACING).getNormal());
    facingVec = context.rotation.apply(facingVec);
    Direction closestToFacing = Direction.getNearest(facingVec.x, facingVec.y, facingVec.z);
    boolean horizontal = closestToFacing.getAxis().isHorizontal();
    boolean backwards = VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite());
    boolean moving = context.getAnimationSpeed() != 0;
    boolean shouldAnimate = (context.contraption.stalled && horizontal) || (!context.contraption.stalled && !backwards && moving);
    SuperByteBuffer superBuffer;
    if (SawBlock.isHorizontal(state)) {
        if (shouldAnimate)
            superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state);
        else
            superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state);
    } else {
        if (shouldAnimate)
            superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state);
        else
            superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state);
    }
    superBuffer.transform(matrices.getModel()).centre().rotateY(AngleHelper.horizontalAngle(facing)).rotateX(AngleHelper.verticalAngle(facing));
    if (!SawBlock.isHorizontal(state)) {
        superBuffer.rotateZ(state.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 90 : 0);
    }
    superBuffer.unCentre().light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped()));
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Vec3(net.minecraft.world.phys.Vec3) Direction(net.minecraft.core.Direction)

Example 4 with SuperByteBuffer

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

the class ContraptionRenderDispatcher method buildStructureBuffer.

public static SuperByteBuffer buildStructureBuffer(VirtualRenderWorld renderWorld, Contraption c, RenderType layer) {
    Collection<StructureTemplate.StructureBlockInfo> values = c.getBlocks().values();
    BufferBuilder builder = ModelUtil.getBufferBuilderFromTemplate(renderWorld, layer, values);
    return new SuperByteBuffer(builder);
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) BufferBuilder(com.mojang.blaze3d.vertex.BufferBuilder)

Example 5 with SuperByteBuffer

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

the class StickerRenderer method renderSafe.

@Override
protected void renderSafe(StickerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    BlockState state = te.getBlockState();
    SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.STICKER_HEAD, state);
    float offset = te.piston.getValue(AnimationTickHolder.getPartialTicks(te.getLevel()));
    if (te.getLevel() != Minecraft.getInstance().level && !te.isVirtual())
        offset = state.getValue(StickerBlock.EXTENDED) ? 1 : 0;
    Direction facing = state.getValue(StickerBlock.FACING);
    head.nudge(te.hashCode()).centre().rotateY(AngleHelper.horizontalAngle(facing)).rotateX(AngleHelper.verticalAngle(facing) + 90).unCentre().translate(0, (offset * offset) * 4 / 16f, 0);
    head.light(light).renderInto(ms, 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)

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