use of com.mojang.blaze3d.vertex.IVertexBuilder in project Bookshelf by Darkhax-Minecraft.
the class RenderUtils method renderBlock.
/**
* Renders a block state into the world. This only exists for optifine compatibility mode.
*
* @param state The state to render.
* @param world The world context to render into.
* @param pos The position of the block.
* @param matrix The render matrix.
* @param buffer The render buffer.
*/
private static void renderBlock(BlockState state, World world, BlockPos pos, MatrixStack matrix, IRenderTypeBuffer buffer) {
final BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
final IBakedModel model = dispatcher.getBlockModel(state);
final boolean useAO = Minecraft.useAmbientOcclusion() && state.getLightValue(world, pos) == 0 && model.useAmbientOcclusion();
final RenderType type = RenderUtils.findRenderType(state);
if (type != null) {
ForgeHooksClient.setRenderLayer(type);
final IVertexBuilder builder = buffer.getBuffer(type);
renderModel(dispatcher.getModelRenderer(), useAO, world, model, state, pos, matrix, builder, false, OverlayTexture.NO_OVERLAY);
ForgeHooksClient.setRenderLayer(null);
}
}
use of com.mojang.blaze3d.vertex.IVertexBuilder in project AgriCraft by AgriCraft.
the class AgriGenomeRenderer method addVertex.
protected void addVertex(IRenderTypeBuffer buffer, Matrix4f matrix, float x, float y, float z, float r, float g, float b, float a, float w) {
IVertexBuilder builder = this.getVertexBuilder(buffer, this.getRenderType(w));
builder.pos(matrix, x, y, z).color(r, g, b, a).endVertex();
}
use of com.mojang.blaze3d.vertex.IVertexBuilder in project AgriCraft by AgriCraft.
the class BlockGreenHouseAirRenderer method highlightGreenHouseAirBlocks.
protected void highlightGreenHouseAirBlocks(World world, BlockPos origin, MatrixStack transforms) {
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
IVertexBuilder builder = buffer.getBuffer(this.getRenderType());
transforms.push();
Vector3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
transforms.translate(-projectedView.x, -projectedView.y, -projectedView.z);
Matrix4f matrix4f = transforms.getLast().getMatrix();
BlockPos.Mutable pos = origin.toMutable();
for (int x = -RANGE; x <= RANGE; x++) {
for (int y = -RANGE; y <= RANGE; y++) {
for (int z = -RANGE; z <= RANGE; z++) {
pos.setPos(origin.getX() + x, origin.getY() + y, origin.getZ() + z);
if (world.getBlockState(pos).getBlock() instanceof BlockGreenHouseAir) {
this.renderWireFrameCube(builder, matrix4f, pos);
}
}
}
}
transforms.pop();
buffer.finish(this.getRenderType());
}
use of com.mojang.blaze3d.vertex.IVertexBuilder in project BluePower by Qmunity.
the class BPEventHandler method blockHighlightEvent.
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public void blockHighlightEvent(DrawHighlightEvent event) {
PlayerEntity player = Minecraft.getInstance().player;
if (player == null) {
return;
}
World world = player.level;
if (world == null) {
return;
}
RayTraceResult mop = event.getTarget();
if (mop instanceof BlockRayTraceResult) {
BlockPos pos = ((BlockRayTraceResult) mop).getBlockPos();
BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockBPMultipart) {
BlockState partstate = MultipartUtils.getClosestState(player, pos);
IVertexBuilder builder = event.getBuffers().getBuffer(RenderType.lines());
if (partstate != null) {
VoxelShape shape = partstate.getShape(world, pos, ISelectionContext.of(player));
Vector3d projectedView = event.getInfo().getPosition();
double d0 = pos.getX() - projectedView.x();
double d1 = pos.getY() - projectedView.y();
double d2 = pos.getZ() - projectedView.z();
Matrix4f matrix4f = event.getMatrix().last().pose();
shape.forAllEdges((startX, startY, startZ, endX, endY, endZ) -> {
builder.vertex(matrix4f, (float) (startX + d0), (float) (startY + d1), (float) (startZ + d2)).color(0.0F, 0.0F, 0.0F, 0.4F).endVertex();
builder.vertex(matrix4f, (float) (endX + d0), (float) (endY + d1), (float) (endZ + d2)).color(0.0F, 0.0F, 0.0F, 0.4F).endVertex();
});
event.setCanceled(true);
}
}
}
}
use of com.mojang.blaze3d.vertex.IVertexBuilder in project Overloaded by CJ-MC-Mods.
the class RenderMultiToolAssist method renderBlockModel.
private static void renderBlockModel(RenderWorldLastEvent event, BlockPos toRenderAt, @Nonnull IBakedModel model, @Nonnull BlockState state) {
ActiveRenderInfo camera = Minecraft.getInstance().gameRenderer.getMainCamera();
final double x = camera.getPosition().x();
final double y = camera.getPosition().y();
final double z = camera.getPosition().z();
event.getMatrixStack().pushPose();
event.getMatrixStack().translate(toRenderAt.getX() - x, toRenderAt.getY() - y, toRenderAt.getZ() - z);
IVertexBuilder buffer = Minecraft.getInstance().renderBuffers().bufferSource().getBuffer(GhostRenderType.getInstance());
Minecraft.getInstance().getBlockRenderer().getModelRenderer().tesselateBlock(Minecraft.getInstance().level, model, state, toRenderAt, event.getMatrixStack(), buffer, false, Minecraft.getInstance().level.random, 0, 0);
event.getMatrixStack().popPose();
Minecraft.getInstance().renderBuffers().bufferSource().endBatch(GhostRenderType.getInstance());
}
Aggregations