Search in sources :

Example 46 with SuperByteBuffer

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

the class SchematicannonRenderer method renderSafe.

@Override
protected void renderSafe(SchematicannonTileEntity tileEntity, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    boolean blocksLaunching = !tileEntity.flyingBlocks.isEmpty();
    if (blocksLaunching)
        renderLaunchedBlocks(tileEntity, partialTicks, ms, buffer, light, overlay);
    if (Backend.canUseInstancing(tileEntity.getLevel()))
        return;
    BlockPos pos = tileEntity.getBlockPos();
    BlockState state = tileEntity.getBlockState();
    double[] cannonAngles = getCannonAngles(tileEntity, pos, partialTicks);
    double yaw = cannonAngles[0];
    double pitch = cannonAngles[1];
    double recoil = getRecoil(tileEntity, partialTicks);
    ms.pushPose();
    VertexConsumer vb = buffer.getBuffer(RenderType.solid());
    SuperByteBuffer connector = CachedBufferer.partial(AllBlockPartials.SCHEMATICANNON_CONNECTOR, state);
    connector.translate(.5f, 0, .5f);
    connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
    connector.translate(-.5f, 0, -.5f);
    connector.light(light).renderInto(ms, vb);
    SuperByteBuffer pipe = CachedBufferer.partial(AllBlockPartials.SCHEMATICANNON_PIPE, state);
    pipe.translate(.5f, 15 / 16f, .5f);
    pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
    pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI));
    pipe.translate(-.5f, -15 / 16f, -.5f);
    pipe.translate(0, -recoil / 100, 0);
    pipe.light(light).renderInto(ms, vb);
    ms.popPose();
}
Also used : ForBlockState(com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState) 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)

Example 47 with SuperByteBuffer

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

the class SchematicRenderer method drawLayer.

protected SuperByteBuffer drawLayer(RenderType layer) {
    BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER;
    ThreadLocalObjects objects = THREAD_LOCAL_OBJECTS.get();
    PoseStack poseStack = objects.poseStack;
    Random random = objects.random;
    BlockPos.MutableBlockPos mutableBlockPos = objects.mutableBlockPos;
    SchematicWorld renderWorld = schematic;
    BoundingBox bounds = renderWorld.getBounds();
    ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper;
    ShadeSeparatedBufferBuilder builder = new ShadeSeparatedBufferBuilder(512);
    BufferBuilder unshadedBuilder = objects.unshadedBuilder;
    builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
    unshadedBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
    shadeSeparatingWrapper.prepare(builder, unshadedBuilder);
    ForgeHooksClient.setRenderType(layer);
    ModelBlockRenderer.enableCaching();
    for (BlockPos localPos : BlockPos.betweenClosed(bounds.minX(), bounds.minY(), bounds.minZ(), bounds.maxX(), bounds.maxY(), bounds.maxZ())) {
        BlockPos pos = mutableBlockPos.setWithOffset(localPos, anchor);
        BlockState state = renderWorld.getBlockState(pos);
        poseStack.pushPose();
        poseStack.translate(localPos.getX(), localPos.getY(), localPos.getZ());
        if (state.getRenderShape() == RenderShape.MODEL && ItemBlockRenderTypes.canRenderInLayer(state, layer)) {
            BlockEntity tileEntity = renderWorld.getBlockEntity(localPos);
            dispatcher.renderBatched(state, pos, renderWorld, poseStack, shadeSeparatingWrapper, true, random, tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);
        }
        poseStack.popPose();
    }
    ModelBlockRenderer.clearCache();
    ForgeHooksClient.setRenderType(null);
    shadeSeparatingWrapper.clear();
    unshadedBuilder.end();
    builder.appendUnshadedVertices(unshadedBuilder);
    builder.end();
    return new SuperByteBuffer(builder);
}
Also used : PoseStack(com.mojang.blaze3d.vertex.PoseStack) SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) ShadeSeparatingVertexConsumer(com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer) BufferBuilder(com.mojang.blaze3d.vertex.BufferBuilder) ShadeSeparatedBufferBuilder(com.jozufozu.flywheel.core.model.ShadeSeparatedBufferBuilder) BlockState(net.minecraft.world.level.block.state.BlockState) Random(java.util.Random) SchematicWorld(com.simibubi.create.content.schematics.SchematicWorld) BlockRenderDispatcher(net.minecraft.client.renderer.block.BlockRenderDispatcher) BoundingBox(net.minecraft.world.level.levelgen.structure.BoundingBox) BlockPos(net.minecraft.core.BlockPos) ShadeSeparatedBufferBuilder(com.jozufozu.flywheel.core.model.ShadeSeparatedBufferBuilder) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 48 with SuperByteBuffer

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

the class StabilizedBearingMovementBehaviour method renderInContraption.

@Override
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices, MultiBufferSource buffer) {
    if (Backend.isOn())
        return;
    Direction facing = context.state.getValue(BlockStateProperties.FACING);
    PartialModel top = AllBlockPartials.BEARING_TOP;
    SuperByteBuffer superBuffer = CachedBufferer.partial(top, context.state);
    float renderPartialTicks = AnimationTickHolder.getPartialTicks();
    // rotate to match blockstate
    Quaternion orientation = BearingInstance.getBlockStateOrientation(facing);
    // rotate against parent
    float angle = getCounterRotationAngle(context, facing, renderPartialTicks) * facing.getAxisDirection().getStep();
    Quaternion rotation = facing.step().rotationDegrees(angle);
    rotation.mul(orientation);
    orientation = rotation;
    superBuffer.transform(matrices.getModel());
    superBuffer.rotateCentered(orientation);
    // render
    superBuffer.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)).renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Quaternion(com.mojang.math.Quaternion) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 49 with SuperByteBuffer

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

the class BearingRenderer method renderSafe.

@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (Backend.canUseInstancing(te.getLevel()))
        return;
    super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
    IBearingTileEntity bearingTe = (IBearingTileEntity) te;
    final Direction facing = te.getBlockState().getValue(BlockStateProperties.FACING);
    PartialModel top = bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
    SuperByteBuffer superBuffer = CachedBufferer.partial(top, te.getBlockState());
    float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
    kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light);
    if (facing.getAxis().isHorizontal())
        superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
    superBuffer.rotateCentered(Direction.EAST, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing)));
    superBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
Also used : SuperByteBuffer(com.simibubi.create.foundation.render.SuperByteBuffer) Direction(net.minecraft.core.Direction) PartialModel(com.jozufozu.flywheel.core.PartialModel)

Example 50 with SuperByteBuffer

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

the class CopperBacktankRenderer 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);
    BlockState blockState = te.getBlockState();
    SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_COGS, blockState);
    cogs.centre().rotateY(180 + AngleHelper.horizontalAngle(blockState.getValue(CopperBacktankBlock.HORIZONTAL_FACING))).unCentre().translate(0, 6.5f / 16, 11f / 16).rotate(Direction.EAST, AngleHelper.rad(te.getSpeed() / 4f * AnimationTickHolder.getRenderTime(te.getLevel()) % 360)).translate(0, -6.5f / 16, -11f / 16);
    cogs.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)

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