I need to be able to draw lines between two coordinates in Minecraft. I think I understand how to use the GL11 functions to get the actual drawing done. What I need to know is how to register my drawing function to be called every time the world needs to be rendered. (I believe this is the approach I need to take).
This is the simplest example I can make that demonstrates what I need. All that's missing is how get Forge to call my draw function.
package com.example.drawStuff;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
@Mod(modid = DrawStuffMod.MODID, name = DrawStuffMod.NAME, version = DrawStuffMod.VERSION)
public class DrawStuffMod {
public static final String NAME = "DrawStuffMod";
public static final String MODID = "drawstuffmod";
public static final String VERSION = "1.0";
@Mod.Instance(DrawStuffMod.MODID)
public static DrawStuffMod instance;
@EventHandler
public void init(FMLInitializationEvent event) {
// Do initialization stuff
}
// How do I get Forge to call this function? (Or a wrapper function if needed)
private void drawLineWithGL(BlockPos blockA, BlockPos blockB) {
GL11.glColor4f(1F, 0F, 1F, 0F); // change color and set alpha
GL11.glBegin(GL11.GL_LINE_STRIP);
GL11.glVertex3d(blockA.getX(), blockA.getY(), blockA.getZ());
GL11.glVertex3d(blockB.getX(), blockB.getY(), blockB.getZ());
GL11.glEnd();
}
}
Bonus points if you can show how to adjust the thickness of the line too.