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