#Support carnavious
1 messages · Page 1 of 1 (latest)
here, i copied the drawRect method to draw lines.
fun drawLine(x1: Double, z1: Double, x2: Double, z2: Double, width: Double, color: Int) {
val length = sqrt((x1 - x2).toDouble().pow(2) + (z1 - z2).toDouble().pow(2))
//perpendicular to line to use for width
val normx = (z1-z2)/length
val normz = -(x1-x2)/length
val dx = normx * width
val dz = normz * width
val f3 = (color shr 24 and 255).toFloat() / 255.0f
val f = (color shr 16 and 255).toFloat() / 255.0f
val f1 = (color shr 8 and 255).toFloat() / 255.0f
val f2 = (color and 255).toFloat() / 255.0f
GlStateManager.color(f, f1, f2, f3)
val tessellator = Tessellator.getInstance()
val worldRenderer = tessellator.worldRenderer
GlStateManager.enableBlend()
GlStateManager.disableTexture2D()
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
worldRenderer.begin(7, DefaultVertexFormats.POSITION)
worldRenderer.pos(x1 + dx, z1 + dz, 0.0).endVertex()
worldRenderer.pos(x1 - dx, z1 - dz, 0.0).endVertex()
worldRenderer.pos(x2 - dx, z2 - dz, 0.0).endVertex()
worldRenderer.pos(x2 + dx, z2 + dz, 0.0).endVertex()
tessellator.draw()
GlStateManager.enableTexture2D()
GlStateManager.disableBlend()
}```
then in miningfeatures.kt I added
val trailObject = TrailObject().apply {
// Set test coordinates
trail.add(Pair(100.0, 100.0))
trail.add(Pair(200.0, 200.0))
trail.add(Pair(400.0, 400.0))
trail.add(Pair(200.0, 600.0))
trail.add(Pair(700.0, 200.0))
UChat.chat("$successPrefix §aadded point")
trail.add(Pair(300.0, 600.0))
trail.add(Pair(500.0, 500.0))
}
...
class TrailObject {
val trail: MutableList<Pair<Double, Double>> = mutableListOf()
fun reset() {
trail.clear()
}
fun add() {
val locX = mc.thePlayer.posX - 200
val locZ = mc.thePlayer.posZ - 200
trail.add(Pair(locX, locZ))
}
fun exists(): Boolean {
return trail.isNotEmpty()
}
fun drawOnMap(width: Double, color: Int) {
if (true) {
UChat.chat("$successPrefix §aentered loop")
for (i in 1 until trail.size) {
val (oldlocX, oldlocZ) = trail[i-1]
val (curlocX, curlocZ) = trail[i]
RenderUtil.drawLine(oldlocX, oldlocZ, curlocX, curlocZ, width, color)
}
}
}
}
and tried to see if i could get lines drawn on the minimap the same way notable locations were drawn
UGraphics.disableLighting()
stack.runWithGlobalState {
RenderUtil.renderTexture(mapLocation, 0, 0, 624, 624, false)
if (Skytils.config.crystalHollowMapPlaces) {
Locations.entries.forEach {
it.loc.drawOnMap(it.size, it.color)
} }
// Call drawOnMap for the trail object
trailObject.drawOnMap(20.0, ColorFactory.RED.rgb)
}
at this point I was trying to use chat messages to debug, half knowing that it was probably going to loop because the map is called over and over, (i got the 'Skytils entered an infinite loop! (320)' message) and decided to ask for help debugging