Search in sources :

Example 11 with SuperByteBuffer

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

the class CopperBacktankArmorLayer method render.

@Override
public void render(PoseStack ms, MultiBufferSource buffer, int light, LivingEntity entity, float yaw, float pitch, float pt, float p_225628_8_, float p_225628_9_, float p_225628_10_) {
    if (entity.getPose() == Pose.SLEEPING)
        return;
    if (!AllItems.COPPER_BACKTANK.get().isWornBy(entity))
        return;
    M entityModel = getParentModel();
    if (!(entityModel instanceof HumanoidModel))
        return;
    HumanoidModel<?> model = (HumanoidModel<?>) entityModel;
    RenderType renderType = Sheets.cutoutBlockSheet();
    BlockState renderedState = AllBlocks.COPPER_BACKTANK.getDefaultState().setValue(CopperBacktankBlock.HORIZONTAL_FACING, Direction.SOUTH);
    SuperByteBuffer backtank = CachedBufferer.block(renderedState);
    SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_COGS, renderedState);
    ms.pushPose();
    model.body.translateAndRotate(ms);
    ms.translate(-1 / 2f, 10 / 16f, 1f);
    ms.scale(1, -1, -1);
    backtank.forEntityRender().light(light).renderInto(ms, buffer.getBuffer(renderType));
    cogs.centre().rotateY(180).unCentre().translate(0, 6.5f / 16, 11f / 16).rotate(Direction.EAST, AngleHelper.rad(2 * AnimationTickHolder.getRenderTime(entity.level) % 360)).translate(0, -6.5f / 16, -11f / 16);
    cogs.forEntityRender().light(light).renderInto(ms, buffer.getBuffer(renderType));
    ms.popPose();
}
Also used : HumanoidModel(net.minecraft.client.model.HumanoidModel) BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) RenderType(net.minecraft.client.renderer.RenderType)

Example 12 with SuperByteBuffer

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

the class BellRenderer method renderSafe.

@Override
protected void renderSafe(TE te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    BlockState state = te.getBlockState();
    Direction facing = state.getValue(BellBlock.FACING);
    BellAttachType attachment = state.getValue(BellBlock.ATTACHMENT);
    SuperByteBuffer bell = CachedBufferer.partial(te.getBellModel(), state);
    if (te.isRinging)
        bell.rotateCentered(te.ringDirection.getCounterClockWise(), getSwingAngle(te.ringingTicks + partialTicks));
    float rY = AngleHelper.horizontalAngle(facing);
    if (attachment == BellAttachType.SINGLE_WALL || attachment == BellAttachType.DOUBLE_WALL)
        rY += 90;
    bell.rotateCentered(Direction.UP, AngleHelper.rad(rY));
    bell.light(light).renderInto(ms, buffer.getBuffer(RenderType.cutout()));
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) BellAttachType(net.minecraft.world.level.block.state.properties.BellAttachType) Direction(net.minecraft.core.Direction)

Example 13 with SuperByteBuffer

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

the class WorldSectionElement method renderLayer.

@Override
protected void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float fade, float pt) {
    SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE;
    int code = hashCode() ^ world.hashCode();
    Pair<Integer, Integer> key = Pair.of(code, RenderType.chunkBufferLayers().indexOf(type));
    if (redraw)
        bufferCache.invalidate(DOC_WORLD_SECTION, key);
    SuperByteBuffer contraptionBuffer = bufferCache.get(DOC_WORLD_SECTION, key, () -> buildStructureBuffer(world, type));
    if (contraptionBuffer.isEmpty())
        return;
    transformMS(contraptionBuffer.getTransforms(), pt);
    int light = lightCoordsFromFade(fade);
    contraptionBuffer.light(light).renderInto(ms, buffer.getBuffer(type));
}
Also used : SuperByteBufferCache(com.simibubi.create.foundation.render.SuperByteBufferCache) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer)

Example 14 with SuperByteBuffer

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

the class ColoredOverlayTileEntityRenderer method renderSafe.

@Override
protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light);
    render.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer)

Example 15 with SuperByteBuffer

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

the class BracketedKineticTileRenderer method renderSafe.

@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    if (!AllBlocks.LARGE_COGWHEEL.has(te.getBlockState())) {
        super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
        return;
    }
    // Large cogs sometimes have to offset their teeth by 11.25 degrees in order to
    // mesh properly
    Axis axis = getRotationAxisOf(te);
    BlockPos pos = te.getBlockPos();
    Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
    renderRotatingBuffer(te, CachedBufferer.partialFacingVertical(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, te.getBlockState(), facing), ms, buffer.getBuffer(RenderType.solid()), light);
    float offset = getShaftAngleOffset(axis, pos);
    float time = AnimationTickHolder.getRenderTime(te.getLevel());
    float angle = ((time * te.getSpeed() * 3f / 10 + offset) % 360) / 180 * (float) Math.PI;
    SuperByteBuffer shaft = CachedBufferer.partialFacingVertical(AllBlockPartials.COGWHEEL_SHAFT, te.getBlockState(), facing);
    kineticRotationTransform(shaft, te, axis, angle, light);
    shaft.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) Axis(net.minecraft.core.Direction.Axis)

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