Advertisement
Nix13

Draw texture in Minecraft 1.12.2 V2

May 19th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.06 KB | None | 0 0
  1.     fun drawTexture(x: Int, y: Int, u: Int, v: Int, width: Int, height: Int) {
  2.         val f = 0.00390625F
  3.         val startX = x.toDouble()
  4.         val startY = y.toDouble()
  5.         val startU = (u/f).toDouble()
  6.         val startV = (v/f).toDouble()
  7.         val endX = (x + width).toDouble()
  8.         val endY = (y + height).toDouble()
  9.         val endU = ((u + width)/f).toDouble()
  10.         val endV = ((v + height)/f).toDouble()
  11.         val tess = Tessellator.getInstance()
  12.         val builder = tess.buffer
  13.         builder.begin(7, DefaultVertexFormats.POSITION_TEX)
  14.         builder.pos(startX, startY, 0.0).tex(startU, startV).endVertex()
  15.         builder.pos(startX, endY, 0.0).tex(startU, endV).endVertex()
  16.         builder.pos(endX, endY, 0.0).tex(endU, endV).endVertex()
  17.         builder.pos(endX, startY, 0.0).tex(endU, startV).endVertex()
  18.         tess.draw()
  19.     }
  20.  
  21. // DrawUtils.kt
  22. mc.textureManager.bindTexture(ResourceLocation("$modid:textures/gui/stats.png"))
  23. DrawUtils.drawTexture(100, 100, 0, 0, 58, 100)
  24. DrawUtils.drawTexture(100, 100, 63, 0, 58, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement