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);
}
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);
}
}
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()));
}
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);
}
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()));
}
Aggregations