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