Jump to content

Rendering anything in world


stellar

Recommended Posts

I've been trying to draw boxes inside of the minecraft world for many frustrating hours in 1.12.2 and I'm really struggling. My first thought was to try making a world2screen function and drawing there but this has been difficult and buggy

I saw many people using the

RenderWorldLastEvent

event but I'm not sure how it works.

 

The bottom of this post has exactly what I want but I couldn't find 1.12.2 equivalents of these. (code below)

@EventBusSubscriber(Dist.CLIENT)
public class SpellRenderEventSubscriber
{	
	@SubscribeEvent
	public static void worldRender(RenderWorldLastEvent event)
	{
		Impl buffer = Minecraft.getInstance().renderBuffers().bufferSource();
		IVertexBuilder builder = buffer.getBuffer(SpellRender.QUADS); //SpellRender.QUADS is a personal RenderType, of VertexFormat POSITION_COLOR.
		
		MatrixStack stack = event.getMatrixStack();
		
		stack.pushPose();
		
		Vector3d cam = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
		stack.translate(-cam.x, -cam.y, -cam.z);
		
		Matrix4f mat = stack.last().pose();
		
		builder.vertex(mat, 0, 57, 0).color(0, 255, 255, 150).endVertex();
		builder.vertex(mat, 1, 57, 0).color(0, 255, 255, 150).endVertex();
		builder.vertex(mat, 1, 58, 0).color(0, 255, 255, 150).endVertex();
		builder.vertex(mat, 0, 58, 0).color(0, 255, 255, 150).endVertex();
		
		stack.popPose();
		
		buffer.endBatch(SpellRender.QUADS);
	}
}

If anyone could help me translate this code to 1.12.2 it would be greatly appreciated!!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.