Search in sources :

Example 16 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer 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();
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) 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) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 17 with SuperByteBuffer

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

the class ToolboxRenderer method renderSafe.

@Override
protected void renderSafe(ToolboxTileEntity tileEntityIn, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    BlockState blockState = tileEntityIn.getBlockState();
    Direction facing = blockState.getValue(ToolboxBlock.FACING).getOpposite();
    SuperByteBuffer lid = CachedBufferer.partial(AllBlockPartials.TOOLBOX_LIDS.get(tileEntityIn.getColor()), blockState);
    SuperByteBuffer drawer = CachedBufferer.partial(AllBlockPartials.TOOLBOX_DRAWER, blockState);
    float lidAngle = tileEntityIn.lid.getValue(partialTicks);
    float drawerOffset = tileEntityIn.drawers.getValue(partialTicks);
    VertexConsumer builder = buffer.getBuffer(RenderType.cutoutMipped());
    lid.centre().rotateY(-facing.toYRot()).unCentre().translate(0, 6 / 16f, 12 / 16f).rotateX(135 * lidAngle).translate(0, -6 / 16f, -12 / 16f).light(light).renderInto(ms, builder);
    for (int offset : Iterate.zeroAndOne) {
        drawer.centre().rotateY(-facing.toYRot()).unCentre().translate(0, offset * 1 / 8f, -drawerOffset * .175f * (2 - offset)).light(light).renderInto(ms, builder);
    }
}
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)

Example 18 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create_Aeronautics by Eriksonnaren.

the class AirshipRenderer method redraw.

protected void redraw(Minecraft minecraft) {
    this.usedBlockRenderLayers.clear();
    this.startedBufferBuilders.clear();
    World blockAccess = this.schematic;
    BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRenderer();
    List<BlockState> blockstates = new LinkedList();
    Map<RenderType, BufferBuilder> buffers = new HashMap();
    MatrixStack ms = new MatrixStack();
    BlockPos.betweenClosedStream(boundingBox).forEach((localPos) -> {
        ms.pushPose();
        MatrixTransformStack.of(ms).translate(localPos);
        BlockPos pos = localPos.offset(this.anchor);
        BlockState state = blockAccess.getBlockState(pos);
        Iterator var10 = RenderType.chunkBufferLayers().iterator();
        while (var10.hasNext()) {
            RenderType blockRenderLayer = (RenderType) var10.next();
            if (RenderTypeLookup.canRenderInLayer(state, blockRenderLayer)) {
                ForgeHooksClient.setRenderLayer(blockRenderLayer);
                if (!buffers.containsKey(blockRenderLayer)) {
                    buffers.put(blockRenderLayer, new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()));
                }
                BufferBuilder bufferBuilder = (BufferBuilder) buffers.get(blockRenderLayer);
                if (this.startedBufferBuilders.add(blockRenderLayer)) {
                    bufferBuilder.begin(7, DefaultVertexFormats.BLOCK);
                }
                TileEntity tileEntity = blockAccess.getBlockEntity(localPos);
                if (blockRendererDispatcher.renderModel(state, pos, blockAccess, ms, bufferBuilder, true, minecraft.level.random, (IModelData) (tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE))) {
                    this.usedBlockRenderLayers.add(blockRenderLayer);
                }
                blockstates.add(state);
            }
        }
        ForgeHooksClient.setRenderLayer((RenderType) null);
        ms.popPose();
    });
    Iterator var7 = RenderType.chunkBufferLayers().iterator();
    while (var7.hasNext()) {
        RenderType layer = (RenderType) var7.next();
        if (this.startedBufferBuilders.contains(layer)) {
            BufferBuilder buf = (BufferBuilder) buffers.get(layer);
            buf.end();
            this.bufferCache.put(layer, new SuperByteBuffer(buf));
        }
    }
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) World(net.minecraft.world.World) AirshipWorld(com.eriksonn.createaeronautics.dimension.AirshipWorld) RenderType(net.minecraft.client.renderer.RenderType) TileEntity(net.minecraft.tileentity.TileEntity) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 19 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create_Aeronautics by Eriksonnaren.

the class AirshipRenderer method render.

public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) {
    if (this.active) {
        buffer.getBuffer(RenderType.solid());
        Iterator var3 = RenderType.chunkBufferLayers().iterator();
        while (var3.hasNext()) {
            RenderType layer = (RenderType) var3.next();
            if (this.usedBlockRenderLayers.contains(layer)) {
                SuperByteBuffer superByteBuffer = (SuperByteBuffer) this.bufferCache.get(layer);
                superByteBuffer.renderInto(ms, buffer.getBuffer(layer));
            }
        }
    // TileEntityRenderHelper.renderTileEntities(this.schematic, this.schematic.getRenderedTileEntities(), ms, buffer);
    }
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) RenderType(net.minecraft.client.renderer.RenderType)

Example 20 with SuperByteBuffer

use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create_Aeronautics by Eriksonnaren.

the class StationaryPotatoCannonRenderer method renderComponents.

protected void renderComponents(StationaryPotatoCannonTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
    IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
    if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
        KineticTileEntityRenderer.renderRotatingKineticBlock(te, this.getRenderedBlockState(te), ms, vb, light);
    }
    BlockState blockState = te.getBlockState();
    BlockPos pos = te.getBlockPos();
    // Vector3d offset = this.getHandOffset(te, partialTicks, blockState);
    Vector3d offset = new Vector3d(0, 0, 0);
    SuperByteBuffer barrel = PartialBufferer.get(CABlockPartials.CANNON_BARREL, blockState);
    // SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
    // SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState);
    transform(barrel.translate(offset.x, offset.y, offset.z), blockState, true).renderInto(ms, vb);
// transform(te.getLevel(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms, vb);
// transform(te.getLevel(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms, vb);
}
Also used : BlockState(net.minecraft.block.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Vector3d(net.minecraft.util.math.vector.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

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