Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.54 KB | None | 0 0
  1. package me.zeroeightsix.kami.util;
  2.  
  3. import net.minecraft.util.math.AxisAlignedBB;
  4. import net.minecraft.client.renderer.BufferBuilder;
  5. import net.minecraft.util.math.BlockPos;
  6. import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
  7. import net.minecraft.client.renderer.GlStateManager;
  8. import org.lwjgl.opengl.GL11;
  9. import net.minecraft.client.renderer.Tessellator;
  10.  
  11. public class KamiTessellator extends Tessellator
  12. {
  13. public static KamiTessellator INSTANCE;
  14.  
  15. public KamiTessellator() {
  16. super(2097152);
  17. }
  18.  
  19. public static void prepare(final int mode) {
  20. prepareGL();
  21. begin(mode);
  22. }
  23.  
  24. public static void prepareGL() {
  25. GL11.glBlendFunc(770, 771);
  26. GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
  27. GlStateManager.glLineWidth(1.5f);
  28. GlStateManager.disableTexture2D();
  29. GlStateManager.depthMask(false);
  30. GlStateManager.enableBlend();
  31. GlStateManager.disableDepth();
  32. GlStateManager.disableLighting();
  33. GlStateManager.disableCull();
  34. GlStateManager.enableAlpha();
  35. GlStateManager.color(1.0f, 1.0f, 1.0f);
  36. }
  37.  
  38. public static void begin(final int mode) {
  39. KamiTessellator.INSTANCE.getBuffer().begin(mode, DefaultVertexFormats.POSITION_COLOR);
  40. }
  41.  
  42. public static void release() {
  43. render();
  44. releaseGL();
  45. }
  46.  
  47. public static void render() {
  48. KamiTessellator.INSTANCE.draw();
  49. }
  50.  
  51. public static void releaseGL() {
  52. GlStateManager.enableCull();
  53. GlStateManager.depthMask(true);
  54. GlStateManager.enableTexture2D();
  55. GlStateManager.enableBlend();
  56. GlStateManager.enableDepth();
  57. }
  58.  
  59. public static void drawBox(final BlockPos blockPos, final int argb, final int sides) {
  60. final int a = argb >>> 24 & 0xFF;
  61. final int r = argb >>> 16 & 0xFF;
  62. final int g = argb >>> 8 & 0xFF;
  63. final int b = argb & 0xFF;
  64. drawBox(blockPos, r, g, b, a, sides);
  65. }
  66.  
  67. public static void drawBox(final float x, final float y, final float z, final int argb, final int sides) {
  68. final int a = argb >>> 24 & 0xFF;
  69. final int r = argb >>> 16 & 0xFF;
  70. final int g = argb >>> 8 & 0xFF;
  71. final int b = argb & 0xFF;
  72. drawBox(KamiTessellator.INSTANCE.getBuffer(), x, y, z, 1.0f, 1.0f, 1.0f, r, g, b, a, sides);
  73. }
  74.  
  75. public static void drawBox(final BlockPos blockPos, final int r, final int g, final int b, final int a, final int sides) {
  76. drawBox(KamiTessellator.INSTANCE.getBuffer(), (float)blockPos.x, (float)blockPos.y, (float)blockPos.z, 1.0f, 1.0f, 1.0f, r, g, b, a, sides);
  77. }
  78.  
  79. public static BufferBuilder getBufferBuilder() {
  80. return KamiTessellator.INSTANCE.getBuffer();
  81. }
  82.  
  83. public static void drawBox(final BufferBuilder buffer, final float x, final float y, final float z, final float w, final float h, final float d, final int r, final int g, final int b, final int a, final int sides) {
  84. if ((sides & 0x1) != 0x0) {
  85. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  86. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  87. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  88. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  89. }
  90. if ((sides & 0x2) != 0x0) {
  91. buffer.pos((double)(x + w), (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  92. buffer.pos((double)x, (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  93. buffer.pos((double)x, (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  94. buffer.pos((double)(x + w), (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  95. }
  96. if ((sides & 0x4) != 0x0) {
  97. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  98. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  99. buffer.pos((double)x, (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  100. buffer.pos((double)(x + w), (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  101. }
  102. if ((sides & 0x8) != 0x0) {
  103. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  104. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  105. buffer.pos((double)(x + w), (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  106. buffer.pos((double)x, (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  107. }
  108. if ((sides & 0x10) != 0x0) {
  109. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  110. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  111. buffer.pos((double)x, (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  112. buffer.pos((double)x, (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  113. }
  114. if ((sides & 0x20) != 0x0) {
  115. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  116. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  117. buffer.pos((double)(x + w), (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  118. buffer.pos((double)(x + w), (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  119. }
  120. }
  121.  
  122. public static void drawFace(final BlockPos blockPos, final int argb, final int sides) {
  123. final int a = argb >>> 24 & 0xFF;
  124. final int r = argb >>> 16 & 0xFF;
  125. final int g = argb >>> 8 & 0xFF;
  126. final int b = argb & 0xFF;
  127. drawFace(blockPos, r, g, b, a, sides);
  128. }
  129.  
  130. public static void drawFace(final BlockPos blockPos, final int r, final int g, final int b, final int a, final int sides) {
  131. drawFace(KamiTessellator.INSTANCE.getBuffer(), (float)blockPos.x, (float)blockPos.y, (float)blockPos.z, 1.0f, 1.0f, 1.0f, r, g, b, a, sides);
  132. }
  133.  
  134. public static void drawFace(final BufferBuilder buffer, final float x, final float y, final float z, final float w, final float h, final float d, final int r, final int g, final int b, final int a, final int sides) {
  135. if ((sides & 0x1) != 0x0) {
  136. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  137. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  138. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  139. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  140. }
  141. }
  142.  
  143. public static void drawFaceOutline(final BlockPos blockPos, final int r, final int g, final int b, final int a, final int sides) {
  144. drawFaceOutline(KamiTessellator.INSTANCE.getBuffer(), (float)blockPos.x, (float)blockPos.y, (float)blockPos.z, 1.0f, 1.0f, 1.0f, r, g, b, a, sides);
  145. }
  146.  
  147. public static void drawFaceOutline(final BufferBuilder buffer, final float x, final float y, final float z, final float w, final float h, final float d, final int r, final int g, final int b, final int a, final int sides) {
  148. if ((sides & 0x1) != 0x0) {
  149. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  150. buffer.pos((double)(x + w), (double)y, z + 0.02).color(r, g, b, a).endVertex();
  151. buffer.pos((double)x, (double)y, z + 0.02).color(r, g, b, a).endVertex();
  152. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  153. buffer.pos(x + 0.02, (double)y, (double)z).color(r, g, b, a).endVertex();
  154. buffer.pos(x + 0.02, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  155. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  156. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  157. buffer.pos((double)(x + w), (double)y, z + d - 0.02).color(r, g, b, a).endVertex();
  158. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  159. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  160. buffer.pos((double)x, (double)y, z + d - 0.02).color(r, g, b, a).endVertex();
  161. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  162. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  163. buffer.pos(x + w - 0.02, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  164. buffer.pos(x + w - 0.02, (double)y, (double)z).color(r, g, b, a).endVertex();
  165. }
  166. }
  167.  
  168. public static void drawBoxOutline(final BlockPos blockPos, final int argb, final int sides) {
  169. final int a = argb >>> 24 & 0xFF;
  170. final int r = argb >>> 16 & 0xFF;
  171. final int g = argb >>> 8 & 0xFF;
  172. final int b = argb & 0xFF;
  173. drawBoxOutline(blockPos, r, g, b, a, sides);
  174. }
  175.  
  176. public static void drawBoxOutline(final float x, final float y, final float z, final int argb, final int sides) {
  177. final int a = argb >>> 24 & 0xFF;
  178. final int r = argb >>> 16 & 0xFF;
  179. final int g = argb >>> 8 & 0xFF;
  180. final int b = argb & 0xFF;
  181. drawBoxOutline(KamiTessellator.INSTANCE.getBuffer(), x, y, z, 1.0f, 1.0f, 1.0f, r, g, b, a, sides);
  182. }
  183.  
  184. public static void drawBoxOutline(final BlockPos blockPos, final int r, final int g, final int b, final int a, final int sides) {
  185. drawBoxOutline(KamiTessellator.INSTANCE.getBuffer(), (float)blockPos.x, (float)blockPos.y, (float)blockPos.z, 1.0f, 1.0f, 1.0f, r, g, b, a, sides);
  186. }
  187.  
  188. public static void drawBoxOutline(final BufferBuilder buffer, final float x, final float y, final float z, final float w, final float h, final float d, final int r, final int g, final int b, final int a, final int sides) {
  189. if ((sides & 0x1) != 0x0) {
  190. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  191. buffer.pos((double)(x + w), (double)y, z + 0.02).color(r, g, b, a).endVertex();
  192. buffer.pos((double)x, (double)y, z + 0.02).color(r, g, b, a).endVertex();
  193. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  194. buffer.pos(x + 0.02, (double)y, (double)z).color(r, g, b, a).endVertex();
  195. buffer.pos(x + 0.02, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  196. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  197. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  198. buffer.pos((double)(x + w), (double)y, z + d - 0.02).color(r, g, b, a).endVertex();
  199. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  200. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  201. buffer.pos((double)x, (double)y, z + d - 0.02).color(r, g, b, a).endVertex();
  202. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  203. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  204. buffer.pos(x + w - 0.02, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  205. buffer.pos(x + w - 0.02, (double)y, (double)z).color(r, g, b, a).endVertex();
  206. }
  207. }
  208.  
  209. public static void drawLines(final BlockPos blockPos, final int argb, final int sides) {
  210. final int a = argb >>> 24 & 0xFF;
  211. final int r = argb >>> 16 & 0xFF;
  212. final int g = argb >>> 8 & 0xFF;
  213. final int b = argb & 0xFF;
  214. drawLines(blockPos, r, g, b, a, sides);
  215. }
  216.  
  217. public static void drawLines(final BlockPos blockPos, final int r, final int g, final int b, final int a, final int sides) {
  218. drawLines(KamiTessellator.INSTANCE.getBuffer(), (float)blockPos.x, (float)blockPos.y, (float)blockPos.z, 1.0f, 1.0f, 1.0f, r, g, b, a, sides);
  219. }
  220.  
  221. public static void drawLines(final BufferBuilder buffer, final float x, final float y, final float z, final float w, final float h, final float d, final int r, final int g, final int b, final int a, final int sides) {
  222. if ((sides & 0x11) != 0x0) {
  223. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  224. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  225. }
  226. if ((sides & 0x12) != 0x0) {
  227. buffer.pos((double)x, (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  228. buffer.pos((double)x, (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  229. }
  230. if ((sides & 0x21) != 0x0) {
  231. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  232. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  233. }
  234. if ((sides & 0x22) != 0x0) {
  235. buffer.pos((double)(x + w), (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  236. buffer.pos((double)(x + w), (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  237. }
  238. if ((sides & 0x5) != 0x0) {
  239. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  240. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  241. }
  242. if ((sides & 0x6) != 0x0) {
  243. buffer.pos((double)x, (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  244. buffer.pos((double)(x + w), (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  245. }
  246. if ((sides & 0x9) != 0x0) {
  247. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  248. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  249. }
  250. if ((sides & 0xA) != 0x0) {
  251. buffer.pos((double)x, (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  252. buffer.pos((double)(x + w), (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  253. }
  254. if ((sides & 0x14) != 0x0) {
  255. buffer.pos((double)x, (double)y, (double)z).color(r, g, b, a).endVertex();
  256. buffer.pos((double)x, (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  257. }
  258. if ((sides & 0x24) != 0x0) {
  259. buffer.pos((double)(x + w), (double)y, (double)z).color(r, g, b, a).endVertex();
  260. buffer.pos((double)(x + w), (double)(y + h), (double)z).color(r, g, b, a).endVertex();
  261. }
  262. if ((sides & 0x18) != 0x0) {
  263. buffer.pos((double)x, (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  264. buffer.pos((double)x, (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  265. }
  266. if ((sides & 0x28) != 0x0) {
  267. buffer.pos((double)(x + w), (double)y, (double)(z + d)).color(r, g, b, a).endVertex();
  268. buffer.pos((double)(x + w), (double)(y + h), (double)(z + d)).color(r, g, b, a).endVertex();
  269. }
  270. }
  271.  
  272. public static void drawBox2(final AxisAlignedBB bb, final int r, final int g, final int b, final int a, final int sides) {
  273. final Tessellator tessellator = Tessellator.getInstance();
  274. final BufferBuilder bufferBuilder = tessellator.getBuffer();
  275. bufferBuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
  276. if ((sides & 0x1) != 0x0) {
  277. bufferBuilder.pos(bb.maxX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  278. bufferBuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  279. bufferBuilder.pos(bb.minX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  280. bufferBuilder.pos(bb.minX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  281. }
  282. if ((sides & 0x2) != 0x0) {
  283. bufferBuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  284. bufferBuilder.pos(bb.minX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  285. bufferBuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  286. bufferBuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  287. }
  288. if ((sides & 0x4) != 0x0) {
  289. bufferBuilder.pos(bb.maxX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  290. bufferBuilder.pos(bb.minX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  291. bufferBuilder.pos(bb.minX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  292. bufferBuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  293. }
  294. if ((sides & 0x8) != 0x0) {
  295. bufferBuilder.pos(bb.minX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  296. bufferBuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  297. bufferBuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  298. bufferBuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  299. }
  300. if ((sides & 0x10) != 0x0) {
  301. bufferBuilder.pos(bb.minX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  302. bufferBuilder.pos(bb.minX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  303. bufferBuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  304. bufferBuilder.pos(bb.minX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  305. }
  306. if ((sides & 0x20) != 0x0) {
  307. bufferBuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(r, g, b, a).endVertex();
  308. bufferBuilder.pos(bb.maxX, bb.minY, bb.minZ).color(r, g, b, a).endVertex();
  309. bufferBuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(r, g, b, a).endVertex();
  310. bufferBuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(r, g, b, a).endVertex();
  311. }
  312. tessellator.draw();
  313. }
  314.  
  315. public static void drawFullBox2(final AxisAlignedBB bb, final BlockPos blockPos, final float width, final int argb) {
  316. final int a = argb >>> 24 & 0xFF;
  317. final int r = argb >>> 16 & 0xFF;
  318. final int g = argb >>> 8 & 0xFF;
  319. final int b = argb & 0xFF;
  320. drawFullBox2(bb, blockPos, width, r, g, b, a);
  321. }
  322.  
  323. public static void drawFullBox2(final AxisAlignedBB bb, final BlockPos blockPos, final float width, final int red, final int green, final int blue, final int alpha) {
  324. prepare(7);
  325. drawBox2(bb, red, green, blue, alpha, 63);
  326. release();
  327. drawBoundingBox(bb, width, red, green, blue, 255);
  328. }
  329.  
  330. public static void drawFullBox(final AxisAlignedBB bb, final BlockPos blockPos, final float width, final int argb, final int alpha2) {
  331. final int a = argb >>> 24 & 0xFF;
  332. final int r = argb >>> 16 & 0xFF;
  333. final int g = argb >>> 8 & 0xFF;
  334. final int b = argb & 0xFF;
  335. drawFullBox(bb, blockPos, width, r, g, b, a, alpha2);
  336. }
  337.  
  338. public static void drawFullBox(final AxisAlignedBB bb, final BlockPos blockPos, final float width, final int red, final int green, final int blue, final int alpha, final int alpha2) {
  339. prepare(7);
  340. drawBox(blockPos, red, green, blue, alpha, 63);
  341. release();
  342. drawBoundingBox(bb, width, red, green, blue, alpha2);
  343. }
  344.  
  345. public static void drawFullFace(final AxisAlignedBB bb, final BlockPos blockPos, final float width, final int argb, final int alpha2) {
  346. final int a = argb >>> 24 & 0xFF;
  347. final int r = argb >>> 16 & 0xFF;
  348. final int g = argb >>> 8 & 0xFF;
  349. final int b = argb & 0xFF;
  350. drawFullFace(bb, blockPos, width, r, g, b, a, alpha2);
  351. }
  352.  
  353. public static void drawFullFace(final AxisAlignedBB bb, final BlockPos blockPos, final float width, final int red, final int green, final int blue, final int alpha, final int alpha2) {
  354. prepare(7);
  355. drawFace(blockPos, red, green, blue, alpha, 63);
  356. release();
  357. drawBoundingBoxFace(bb, width, red, green, blue, alpha2);
  358. }
  359.  
  360. public static void drawBoundingBox(final AxisAlignedBB bb, final float width, final int argb) {
  361. final int a = argb >>> 24 & 0xFF;
  362. final int r = argb >>> 16 & 0xFF;
  363. final int g = argb >>> 8 & 0xFF;
  364. final int b = argb & 0xFF;
  365. drawBoundingBox(bb, width, r, g, b, a);
  366. }
  367.  
  368. public static void drawBoundingBox(final AxisAlignedBB bb, final float width, final int red, final int green, final int blue, final int alpha) {
  369. GlStateManager.pushMatrix();
  370. GlStateManager.enableBlend();
  371. GlStateManager.disableDepth();
  372. GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
  373. GlStateManager.disableTexture2D();
  374. GlStateManager.depthMask(false);
  375. GL11.glEnable(2848);
  376. GL11.glHint(3154, 4354);
  377. GL11.glLineWidth(width);
  378. final Tessellator tessellator = Tessellator.getInstance();
  379. final BufferBuilder bufferbuilder = tessellator.getBuffer();
  380. bufferbuilder.begin(3, DefaultVertexFormats.POSITION_COLOR);
  381. bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  382. bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  383. bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  384. bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  385. bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  386. bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  387. bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  388. bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  389. bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  390. bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  391. bufferbuilder.pos(bb.minX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  392. bufferbuilder.pos(bb.maxX, bb.maxY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  393. bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  394. bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  395. bufferbuilder.pos(bb.maxX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  396. bufferbuilder.pos(bb.minX, bb.maxY, bb.minZ).color(red, green, blue, alpha).endVertex();
  397. tessellator.draw();
  398. GL11.glDisable(2848);
  399. GlStateManager.depthMask(true);
  400. GlStateManager.enableDepth();
  401. GlStateManager.enableTexture2D();
  402. GlStateManager.disableBlend();
  403. GlStateManager.popMatrix();
  404. }
  405.  
  406. public static void drawBoundingBoxFace(final AxisAlignedBB bb, final float width, final int red, final int green, final int blue, final int alpha) {
  407. GlStateManager.pushMatrix();
  408. GlStateManager.enableBlend();
  409. GlStateManager.disableDepth();
  410. GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
  411. GlStateManager.disableTexture2D();
  412. GlStateManager.depthMask(false);
  413. GL11.glEnable(2848);
  414. GL11.glHint(3154, 4354);
  415. GL11.glLineWidth(width);
  416. final Tessellator tessellator = Tessellator.getInstance();
  417. final BufferBuilder bufferbuilder = tessellator.getBuffer();
  418. bufferbuilder.begin(3, DefaultVertexFormats.POSITION_COLOR);
  419. bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  420. bufferbuilder.pos(bb.minX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  421. bufferbuilder.pos(bb.maxX, bb.minY, bb.maxZ).color(red, green, blue, alpha).endVertex();
  422. bufferbuilder.pos(bb.maxX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  423. bufferbuilder.pos(bb.minX, bb.minY, bb.minZ).color(red, green, blue, alpha).endVertex();
  424. tessellator.draw();
  425. GL11.glDisable(2848);
  426. GlStateManager.depthMask(true);
  427. GlStateManager.enableDepth();
  428. GlStateManager.enableTexture2D();
  429. GlStateManager.disableBlend();
  430. GlStateManager.popMatrix();
  431. }
  432.  
  433. static {
  434. KamiTessellator.INSTANCE = new KamiTessellator();
  435. }
  436. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement