Search in sources :

Example 31 with SuperByteBuffer

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

the class MechanicalPressRenderer 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();
    float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);
    SuperByteBuffer headRender = CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING));
    headRender.translate(0, -renderedHeadOffset, 0).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)

Example 32 with SuperByteBuffer

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

the class FlywheelRenderer method renderFlywheel.

private void renderFlywheel(KineticTileEntity te, PoseStack ms, int light, BlockState blockState, float angle, VertexConsumer vb) {
    BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
    Direction facing = referenceState.getValue(BlockStateProperties.HORIZONTAL_FACING);
    SuperByteBuffer wheel = CachedBufferer.partialFacing(AllBlockPartials.FLYWHEEL, referenceState, facing);
    kineticRotationTransform(wheel, te, blockState.getValue(HORIZONTAL_FACING).getAxis(), AngleHelper.rad(angle), light);
    wheel.renderInto(ms, vb);
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection)

Example 33 with SuperByteBuffer

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

the class BlazeBurnerRenderer method renderSafe.

@Override
protected void renderSafe(BlazeBurnerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    HeatLevel heatLevel = te.getHeatLevelFromBlock();
    if (heatLevel == HeatLevel.NONE)
        return;
    float renderTick = AnimationTickHolder.getRenderTime(te.getLevel()) + (te.hashCode() % 13) * 16f;
    float offset = (Mth.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f;
    PartialModel blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
    SuperByteBuffer blazeBuffer = CachedBufferer.partial(blazeModel, te.getBlockState());
    blazeBuffer.rotateCentered(Direction.UP, AngleHelper.rad(te.headAngle.getValue(partialTicks)));
    blazeBuffer.translate(0, offset, 0);
    blazeBuffer.light(LightTexture.FULL_BRIGHT).renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) HeatLevel(com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 34 with SuperByteBuffer

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

the class SpeedControllerRenderer method renderSafe.

@Override
protected void renderSafe(SpeedControllerTileEntity tileEntityIn, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay);
    VertexConsumer builder = buffer.getBuffer(RenderType.solid());
    if (!Backend.canUseInstancing(tileEntityIn.getLevel())) {
        KineticTileEntityRenderer.renderRotatingBuffer(tileEntityIn, getRotatedModel(tileEntityIn), ms, builder, light);
    }
    if (!tileEntityIn.hasBracket)
        return;
    BlockPos pos = tileEntityIn.getBlockPos();
    Level world = tileEntityIn.getLevel();
    BlockState blockState = tileEntityIn.getBlockState();
    boolean alongX = blockState.getValue(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X;
    SuperByteBuffer bracket = CachedBufferer.partial(AllBlockPartials.SPEED_CONTROLLER_BRACKET, blockState);
    bracket.translate(0, 1, 0);
    bracket.rotateCentered(Direction.UP, (float) (alongX ? Math.PI : Math.PI / 2));
    bracket.light(LevelRenderer.getLightColor(world, pos.above()));
    bracket.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) BlockPos(net.minecraft.core.BlockPos) Level(net.minecraft.world.level.Level)

Example 35 with SuperByteBuffer

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

the class AnalogLeverRenderer method renderSafe.

@Override
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    BlockState leverState = te.getBlockState();
    float state = te.clientState.get(partialTicks);
    VertexConsumer vb = buffer.getBuffer(RenderType.solid());
    // Handle
    SuperByteBuffer handle = CachedBufferer.partial(AllBlockPartials.ANALOG_LEVER_HANDLE, leverState);
    float angle = (float) ((state / 15) * 90 / 180 * Math.PI);
    transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f).rotate(Direction.EAST, angle).translate(-1 / 2f, -1 / 16f, -1 / 2f);
    handle.light(light).renderInto(ms, vb);
    // Indicator
    int color = Color.mixColors(0x2C0300, 0xCD0000, state / 15f);
    SuperByteBuffer indicator = transform(CachedBufferer.partial(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState);
    indicator.light(light).color(color).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)

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