I'd like to visualize a ray that I cast from a player. To archieve this, I need to be able to draw a line.
Currently, I am using this code for testing purposes, but I cannot see any line drawn around x=0 y=0 z=0:
@SubscribeEvent
public static void onClientTick(TickEvent.ClientTickEvent event) {
// Only call code once as the tick event is called twice every tick
if (event.phase == TickEvent.Phase.END) {
if(MEASUREMENT_MANAGER.isCurrentlyMeasuring()) {
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tesselator.getBuilder();
Color c = new Color(1, 0, 0, 0.4f);
bufferBuilder.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR);
bufferBuilder.vertex(0, 0, 0).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
bufferBuilder.vertex(0, 2, 2).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).endVertex();
tesselator.end();
}
}
}
There have been many implementations in lower versions, but I could not find any for 1.20.2. What I've found, however, is this implementation on GitHub: https://github.com/cabaletta/baritone/blob/e183dcba1707c991fea1ba55be052dc3ee5d71a6/src/main/java/baritone/utils/IRenderer.java#L149
This also did not work for me.
Any help would be appreciated.