Advertisement
TNT_Block

RenderUtils

Nov 15th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.77 KB | None | 0 0
  1. package de.cryptonicdev.cryptonic.utils;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Rectangle;
  5.  
  6. import org.lwjgl.opengl.GL11;
  7.  
  8. import net.minecraft.client.Minecraft;
  9. import net.minecraft.client.gui.ScaledResolution;
  10. import net.minecraft.client.renderer.RenderGlobal;
  11. import net.minecraft.client.renderer.Tessellator;
  12. import net.minecraft.client.renderer.WorldRenderer;
  13. import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
  14. import net.minecraft.entity.Entity;
  15. import net.minecraft.util.AxisAlignedBB;
  16. import net.minecraft.util.BlockPos;
  17. import net.minecraft.util.Vec3i;
  18.  
  19. public class RenderUtils {
  20.  
  21. protected Minecraft mc = Minecraft.getMinecraft();
  22.  
  23. public static void drawBorderedCircle(int x, int y, float radius, int outsideC, int insideC) {
  24. GL11.glEnable(3042);
  25. GL11.glDisable(3553);
  26. GL11.glBlendFunc(770, 771);
  27. GL11.glEnable(2848);
  28. GL11.glPushMatrix();
  29. float scale = 0.1F;
  30. GL11.glScalef(scale, scale, scale);
  31. x = (int) (x * (1.0F / scale));
  32. y = (int) (y * (1.0F / scale));
  33. radius *= 1.0F / scale;
  34. drawCircle(x, y, radius, insideC);
  35. drawUnfilledCircle(x, y, radius, 1.0F, outsideC);
  36. GL11.glScalef(1.0F / scale, 1.0F / scale, 1.0F / scale);
  37. GL11.glPopMatrix();
  38. GL11.glEnable(3553);
  39. GL11.glDisable(3042);
  40. GL11.glDisable(2848);
  41. }
  42.  
  43. public static void drawUnfilledCircle(int x, int y, float radius, float lineWidth, int color) {
  44. float alpha = (color >> 24 & 0xFF) / 255.0F;
  45. float red = (color >> 16 & 0xFF) / 255.0F;
  46. float green = (color >> 8 & 0xFF) / 255.0F;
  47. float blue = (color & 0xFF) / 255.0F;
  48. GL11.glColor4f(red, green, blue, alpha);
  49. GL11.glLineWidth(lineWidth);
  50. GL11.glEnable(2848);
  51. GL11.glBegin(2);
  52. for (int i = 0; i <= 360; i++) {
  53. GL11.glVertex2d(x + Math.sin(i * 3.141526D / 180.0D) * radius,
  54. y + Math.cos(i * 3.141526D / 180.0D) * radius);
  55. }
  56. GL11.glEnd();
  57. GL11.glDisable(2848);
  58. }
  59.  
  60. public static void drawCircle(int x, int y, float radius, int color) {
  61. float alpha = (color >> 24 & 0xFF) / 255.0F;
  62. float red = (color >> 16 & 0xFF) / 255.0F;
  63. float green = (color >> 8 & 0xFF) / 255.0F;
  64. float blue = (color & 0xFF) / 255.0F;
  65. GL11.glColor4f(red, green, blue, alpha);
  66. GL11.glBegin(9);
  67. for (int i = 0; i <= 360; i++) {
  68. GL11.glVertex2d(x + Math.sin(i * 3.141526D / 180.0D) * radius,
  69. y + Math.cos(i * 3.141526D / 180.0D) * radius);
  70. }
  71. GL11.glEnd();
  72. }
  73.  
  74. public static int rainbow(long delay) {
  75. double rainbowState = Math.ceil((System.currentTimeMillis() + delay) / 20.0D);
  76. rainbowState %= 360;
  77. return Color.getHSBColor((float) rainbowState / 360f, 0.8f, 0.7f).getRGB();
  78. }
  79.  
  80. public static int purple(long delay) {
  81. double rainbowState = 10D;
  82. rainbowState %= 180;
  83. return Color.magenta.getHSBColor((float) 0F, 1.0f, 0.7f).getRGB();
  84. }
  85.  
  86. /* Start of HashExec's Methods */
  87.  
  88. public static void entityESPBox(Entity entity, Color c) {
  89. GL11.glBlendFunc(770, 771);
  90. GL11.glEnable(GL11.GL_BLEND);
  91. GL11.glLineWidth(2.0F);
  92. GL11.glDisable(GL11.GL_TEXTURE_2D);
  93. GL11.glDisable(GL11.GL_DEPTH_TEST);
  94. GL11.glDepthMask(false);
  95. GL11.glColor4f(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f);
  96. Minecraft.getMinecraft().getRenderManager();
  97. RenderGlobal.func_181561_a(new AxisAlignedBB(
  98. entity.boundingBox.minX - 0.05 - entity.posX
  99. + (entity.posX - Minecraft.getMinecraft().getRenderManager().renderPosX),
  100. entity.boundingBox.minY - entity.posY
  101. + (entity.posY - Minecraft.getMinecraft().getRenderManager().renderPosY),
  102. entity.boundingBox.minZ - 0.05 - entity.posZ
  103. + (entity.posZ - Minecraft.getMinecraft().getRenderManager().renderPosZ),
  104. entity.boundingBox.maxX + 0.05 - entity.posX
  105. + (entity.posX - Minecraft.getMinecraft().getRenderManager().renderPosX),
  106. entity.boundingBox.maxY + 0.1 - entity.posY
  107. + (entity.posY - Minecraft.getMinecraft().getRenderManager().renderPosY),
  108. entity.boundingBox.maxZ + 0.05 - entity.posZ
  109. + (entity.posZ - Minecraft.getMinecraft().getRenderManager().renderPosZ)));
  110. GL11.glEnable(GL11.GL_TEXTURE_2D);
  111. GL11.glEnable(GL11.GL_DEPTH_TEST);
  112. GL11.glDepthMask(true);
  113. GL11.glDisable(GL11.GL_BLEND);
  114. }
  115.  
  116. public static void framelessBlockESP(BlockPos pos, Color c) {
  117. double d0 = pos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
  118. double d1 = pos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
  119. double d2 = pos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
  120. GL11.glBlendFunc(770, 771);
  121. GL11.glEnable(3042);
  122. GL11.glLineWidth(2.0F);
  123. GL11.glDisable(3553);
  124. GL11.glDisable(2929);
  125. GL11.glDepthMask(false);
  126. GL11.glColor4f(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f,
  127. c.getAlpha() / 255f);
  128. drawColorBox(new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 1.0D, d2 + 1.0D), c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
  129. GL11.glEnable(3553);
  130. GL11.glEnable(2929);
  131. GL11.glDepthMask(true);
  132. GL11.glDisable(3042);
  133. }
  134.  
  135. public static void drawColorBox(AxisAlignedBB axisalignedbb, float red, float green, float blue, float alpha) {
  136. Tessellator tessellator = Tessellator.getInstance();
  137. WorldRenderer vertexbuffer = tessellator.getWorldRenderer();
  138. vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
  139. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  140. .endVertex();
  141. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  142. .endVertex();
  143. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  144. .endVertex();
  145. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  146. .endVertex();
  147. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  148. .endVertex();
  149. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  150. .endVertex();
  151. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  152. .endVertex();
  153. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  154. .endVertex();
  155. tessellator.draw();
  156. vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
  157. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  158. .endVertex();
  159. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  160. .endVertex();
  161. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  162. .endVertex();
  163. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  164. .endVertex();
  165. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  166. .endVertex();
  167. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  168. .endVertex();
  169. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  170. .endVertex();
  171. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  172. .endVertex();
  173. tessellator.draw();
  174. vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
  175. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  176. .endVertex();
  177. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  178. .endVertex();
  179. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  180. .endVertex();
  181. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  182. .endVertex();
  183. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  184. .endVertex();
  185. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  186. .endVertex();
  187. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  188. .endVertex();
  189. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  190. .endVertex();
  191. tessellator.draw();
  192. vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
  193. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  194. .endVertex();
  195. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  196. .endVertex();
  197. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  198. .endVertex();
  199. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  200. .endVertex();
  201. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  202. .endVertex();
  203. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  204. .endVertex();
  205. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  206. .endVertex();
  207. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  208. .endVertex();
  209. tessellator.draw();
  210. vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
  211. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  212. .endVertex();
  213. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  214. .endVertex();
  215. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  216. .endVertex();
  217. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  218. .endVertex();
  219. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  220. .endVertex();
  221. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  222. .endVertex();
  223. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  224. .endVertex();
  225. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  226. .endVertex();
  227. tessellator.draw();
  228. vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
  229. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  230. .endVertex();
  231. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  232. .endVertex();
  233. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  234. .endVertex();
  235. vertexbuffer.pos(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  236. .endVertex();
  237. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ).color(red, green, blue, alpha)
  238. .endVertex();
  239. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ).color(red, green, blue, alpha)
  240. .endVertex();
  241. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  242. .endVertex();
  243. vertexbuffer.pos(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ).color(red, green, blue, alpha)
  244. .endVertex();
  245. tessellator.draw();
  246. }
  247.  
  248. public static void blockESPBox(BlockPos blockPos) {
  249. double x = blockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
  250. double y = blockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
  251. double z = blockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
  252. GL11.glBlendFunc(770, 771);
  253. GL11.glEnable(GL11.GL_BLEND);
  254. GL11.glLineWidth(2.0F);
  255. GL11.glColor4d(0, 1, 0, 0.15F);
  256. GL11.glDisable(GL11.GL_TEXTURE_2D);
  257. GL11.glDisable(GL11.GL_DEPTH_TEST);
  258. GL11.glDepthMask(false);
  259. GL11.glColor4d(0, 0, 1, 0.5F);
  260. RenderGlobal.func_181561_a(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0));
  261. GL11.glEnable(GL11.GL_TEXTURE_2D);
  262. GL11.glEnable(GL11.GL_DEPTH_TEST);
  263. GL11.glDepthMask(true);
  264. GL11.glDisable(GL11.GL_BLEND);
  265. }
  266.  
  267. public static void enableGL2D() {
  268. GL11.glDisable(2929);
  269. GL11.glEnable(3042);
  270. GL11.glDisable(3553);
  271. GL11.glBlendFunc(770, 771);
  272. GL11.glDepthMask(true);
  273. GL11.glEnable(2848);
  274. GL11.glHint(3154, 4354);
  275. GL11.glHint(3155, 4354);
  276. }
  277.  
  278. public static void disableGL2D() {
  279. GL11.glEnable(3553);
  280. GL11.glDisable(3042);
  281. GL11.glEnable(2929);
  282. GL11.glDisable(2848);
  283. GL11.glHint(3154, 4352);
  284. GL11.glHint(3155, 4352);
  285. }
  286.  
  287. public static void drawRect(Rectangle rectangle, int color) {
  288. RenderUtils.drawRect(rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y + rectangle.height,
  289. color);
  290. }
  291.  
  292. public static void drawRect(float x2, float y2, float x1, float y1, int color) {
  293. RenderUtils.enableGL2D();
  294. RenderUtils.glColor(color);
  295. RenderUtils.drawRect(x2, y2, x1, y1);
  296. RenderUtils.disableGL2D();
  297. }
  298.  
  299. public static void drawBorderedRect(float x2, float y2, float x1, float y1, float width, int internalColor,
  300. int borderColor) {
  301. RenderUtils.enableGL2D();
  302. RenderUtils.glColor(internalColor);
  303. RenderUtils.drawRect(x2 + width, y2 + width, x1 - width, y1 - width);
  304. RenderUtils.glColor(borderColor);
  305. RenderUtils.drawRect(x2 + width, y2, x1 - width, y2 + width);
  306. RenderUtils.drawRect(x2, y2, x2 + width, y1);
  307. RenderUtils.drawRect(x1 - width, y2, x1, y1);
  308. RenderUtils.drawRect(x2 + width, y1 - width, x1 - width, y1);
  309. RenderUtils.disableGL2D();
  310. }
  311.  
  312. public static void drawBorderedRect(float x2, float y2, float x1, float y1, int insideC, int borderC) {
  313. RenderUtils.enableGL2D();
  314. GL11.glScalef(0.5f, 0.5f, 0.5f);
  315. RenderUtils.drawVLine(x2 *= 2.0f, y2 *= 2.0f, y1 *= 2.0f, borderC);
  316. RenderUtils.drawVLine((x1 *= 2.0f) - 1.0f, y2, y1, borderC);
  317. RenderUtils.drawHLine(x2, x1 - 1.0f, y2, borderC);
  318. RenderUtils.drawHLine(x2, x1 - 2.0f, y1 - 1.0f, borderC);
  319. RenderUtils.drawRect(x2 + 1.0f, y2 + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC);
  320. GL11.glScalef(2.0f, 2.0f, 2.0f);
  321. RenderUtils.disableGL2D();
  322. }
  323.  
  324. public static void drawBorderedRectReliant(float x2, float y2, float x1, float y1, float lineWidth, int inside,
  325. int border) {
  326. RenderUtils.enableGL2D();
  327. RenderUtils.drawRect(x2, y2, x1, y1, inside);
  328. RenderUtils.glColor(border);
  329. GL11.glEnable(3042);
  330. GL11.glDisable(3553);
  331. GL11.glBlendFunc(770, 771);
  332. GL11.glLineWidth(lineWidth);
  333. GL11.glBegin(3);
  334. GL11.glVertex2f(x2, y2);
  335. GL11.glVertex2f(x2, y1);
  336. GL11.glVertex2f(x1, y1);
  337. GL11.glVertex2f(x1, y2);
  338. GL11.glVertex2f(x2, y2);
  339. GL11.glEnd();
  340. GL11.glEnable(3553);
  341. GL11.glDisable(3042);
  342. RenderUtils.disableGL2D();
  343. }
  344.  
  345. public static void drawGradientBorderedRectReliant(float x2, float y2, float x1, float y1, float lineWidth,
  346. int border, int bottom, int top) {
  347. RenderUtils.enableGL2D();
  348. RenderUtils.drawGradientRect(x2, y2, x1, y1, top, bottom);
  349. RenderUtils.glColor(border);
  350. GL11.glEnable(3042);
  351. GL11.glDisable(3553);
  352. GL11.glBlendFunc(770, 771);
  353. GL11.glLineWidth(lineWidth);
  354. GL11.glBegin(3);
  355. GL11.glVertex2f(x2, y2);
  356. GL11.glVertex2f(x2, y1);
  357. GL11.glVertex2f(x1, y1);
  358. GL11.glVertex2f(x1, y2);
  359. GL11.glVertex2f(x2, y2);
  360. GL11.glEnd();
  361. GL11.glEnable(3553);
  362. GL11.glDisable(3042);
  363. RenderUtils.disableGL2D();
  364. }
  365.  
  366. public static void drawRoundedRect(float x2, float y2, float x1, float y1, int borderC, int insideC) {
  367. RenderUtils.enableGL2D();
  368. GL11.glScalef(0.5f, 0.5f, 0.5f);
  369. RenderUtils.drawVLine(x2 *= 2.0f, (y2 *= 2.0f) + 1.0f, (y1 *= 2.0f) - 2.0f, borderC);
  370. RenderUtils.drawVLine((x1 *= 2.0f) - 1.0f, y2 + 1.0f, y1 - 2.0f, borderC);
  371. RenderUtils.drawHLine(x2 + 2.0f, x1 - 3.0f, y2, borderC);
  372. RenderUtils.drawHLine(x2 + 2.0f, x1 - 3.0f, y1 - 1.0f, borderC);
  373. RenderUtils.drawHLine(x2 + 1.0f, x2 + 1.0f, y2 + 1.0f, borderC);
  374. RenderUtils.drawHLine(x1 - 2.0f, x1 - 2.0f, y2 + 1.0f, borderC);
  375. RenderUtils.drawHLine(x1 - 2.0f, x1 - 2.0f, y1 - 2.0f, borderC);
  376. RenderUtils.drawHLine(x2 + 1.0f, x2 + 1.0f, y1 - 2.0f, borderC);
  377. RenderUtils.drawRect(x2 + 1.0f, y2 + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC);
  378. GL11.glScalef(2.0f, 2.0f, 2.0f);
  379. RenderUtils.disableGL2D();
  380. }
  381.  
  382. public static void drawBorderedRect(Rectangle rectangle, float width, int internalColor, int borderColor) {
  383. float x2 = rectangle.x;
  384. float y2 = rectangle.y;
  385. float x22 = rectangle.x + rectangle.width;
  386. float y22 = rectangle.y + rectangle.height;
  387. RenderUtils.enableGL2D();
  388. RenderUtils.glColor(internalColor);
  389. RenderUtils.drawRect(x2 + width, y2 + width, x22 - width, y22 - width);
  390. RenderUtils.glColor(borderColor);
  391. RenderUtils.drawRect(x2 + 1.0f, y2, x22 - 1.0f, y2 + width);
  392. RenderUtils.drawRect(x2, y2, x2 + width, y22);
  393. RenderUtils.drawRect(x22 - width, y2, x22, y22);
  394. RenderUtils.drawRect(x2 + 1.0f, y22 - width, x22 - 1.0f, y22);
  395. RenderUtils.disableGL2D();
  396. }
  397.  
  398. public static void drawGradientRect(float x2, float y2, float x1, float y1, int topColor, int bottomColor) {
  399. RenderUtils.enableGL2D();
  400. GL11.glShadeModel(7425);
  401. GL11.glBegin(7);
  402. RenderUtils.glColor(topColor);
  403. GL11.glVertex2f(x2, y1);
  404. GL11.glVertex2f(x1, y1);
  405. RenderUtils.glColor(bottomColor);
  406. GL11.glVertex2f(x1, y2);
  407. GL11.glVertex2f(x2, y2);
  408. GL11.glEnd();
  409. GL11.glShadeModel(7424);
  410. RenderUtils.disableGL2D();
  411. }
  412.  
  413. public static void drawGradientHRect(float x2, float y2, float x1, float y1, int topColor, int bottomColor) {
  414. RenderUtils.enableGL2D();
  415. GL11.glShadeModel(7425);
  416. GL11.glBegin(7);
  417. RenderUtils.glColor(topColor);
  418. GL11.glVertex2f(x2, y2);
  419. GL11.glVertex2f(x2, y1);
  420. RenderUtils.glColor(bottomColor);
  421. GL11.glVertex2f(x1, y1);
  422. GL11.glVertex2f(x1, y2);
  423. GL11.glEnd();
  424. GL11.glShadeModel(7424);
  425. RenderUtils.disableGL2D();
  426. }
  427.  
  428. public static void drawGradientRect(double x2, double y2, double x22, double y22, int col1, int col2) {
  429. GL11.glEnable(3042);
  430. GL11.glDisable(3553);
  431. GL11.glBlendFunc(770, 771);
  432. GL11.glEnable(2848);
  433. GL11.glShadeModel(7425);
  434. GL11.glPushMatrix();
  435. GL11.glBegin(7);
  436. RenderUtils.glColor(col1);
  437. GL11.glVertex2d(x22, y2);
  438. GL11.glVertex2d(x2, y2);
  439. RenderUtils.glColor(col2);
  440. GL11.glVertex2d(x2, y22);
  441. GL11.glVertex2d(x22, y22);
  442. GL11.glEnd();
  443. GL11.glPopMatrix();
  444. GL11.glEnable(3553);
  445. GL11.glDisable(3042);
  446. GL11.glDisable(2848);
  447. GL11.glShadeModel(7424);
  448. }
  449.  
  450. public static void drawGradientBorderedRect(double x2, double y2, double x22, double y22, float l1, int col1,
  451. int col2, int col3) {
  452. RenderUtils.enableGL2D();
  453. GL11.glPushMatrix();
  454. RenderUtils.glColor(col1);
  455. GL11.glLineWidth(1.0f);
  456. GL11.glBegin(1);
  457. GL11.glVertex2d(x2, y2);
  458. GL11.glVertex2d(x2, y22);
  459. GL11.glVertex2d(x22, y22);
  460. GL11.glVertex2d(x22, y2);
  461. GL11.glVertex2d(x2, y2);
  462. GL11.glVertex2d(x22, y2);
  463. GL11.glVertex2d(x2, y22);
  464. GL11.glVertex2d(x22, y22);
  465. GL11.glEnd();
  466. GL11.glPopMatrix();
  467. RenderUtils.drawGradientRect(x2, y2, x22, y22, col2, col3);
  468. RenderUtils.disableGL2D();
  469. }
  470.  
  471. public static void glColor(Color color) {
  472. GL11.glColor4f((float) color.getRed() / 255.0f, (float) color.getGreen() / 255.0f,
  473. (float) color.getBlue() / 255.0f, (float) color.getAlpha() / 255.0f);
  474. }
  475.  
  476. public static void glColor(int hex) {
  477. float alpha = (float) (hex >> 24 & 255) / 255.0f;
  478. float red = (float) (hex >> 16 & 255) / 255.0f;
  479. float green = (float) (hex >> 8 & 255) / 255.0f;
  480. float blue = (float) (hex & 255) / 255.0f;
  481. GL11.glColor4f(red, green, blue, alpha);
  482. }
  483.  
  484. public static void glColor(float alpha, int redRGB, int greenRGB, int blueRGB) {
  485. float red = 0.003921569f * (float) redRGB;
  486. float green = 0.003921569f * (float) greenRGB;
  487. float blue = 0.003921569f * (float) blueRGB;
  488. GL11.glColor4f(red, green, blue, alpha);
  489. }
  490.  
  491. public static void drawStrip(int x2, int y2, float width, double angle, float points, float radius, int color) {
  492. float a2;
  493. float xc2;
  494. float yc2;
  495. int i2;
  496. float f1 = (float) (color >> 24 & 255) / 255.0f;
  497. float f2 = (float) (color >> 16 & 255) / 255.0f;
  498. float f3 = (float) (color >> 8 & 255) / 255.0f;
  499. float f4 = (float) (color & 255) / 255.0f;
  500. GL11.glPushMatrix();
  501. GL11.glTranslated(x2, y2, 0.0);
  502. GL11.glColor4f(f2, f3, f4, f1);
  503. GL11.glLineWidth(width);
  504. if (angle > 0.0) {
  505. GL11.glBegin(3);
  506. i2 = 0;
  507. while ((double) i2 < angle) {
  508. a2 = (float) ((double) i2 * (angle * 3.141592653589793 / (double) points));
  509. xc2 = (float) (Math.cos(a2) * (double) radius);
  510. yc2 = (float) (Math.sin(a2) * (double) radius);
  511. GL11.glVertex2f(xc2, yc2);
  512. ++i2;
  513. }
  514. GL11.glEnd();
  515. }
  516. if (angle < 0.0) {
  517. GL11.glBegin(3);
  518. i2 = 0;
  519. while ((double) i2 > angle) {
  520. a2 = (float) ((double) i2 * (angle * 3.141592653589793 / (double) points));
  521. xc2 = (float) (Math.cos(a2) * (double) (-radius));
  522. yc2 = (float) (Math.sin(a2) * (double) (-radius));
  523. GL11.glVertex2f(xc2, yc2);
  524. --i2;
  525. }
  526. GL11.glEnd();
  527. }
  528. RenderUtils.disableGL2D();
  529. GL11.glDisable(3479);
  530. GL11.glPopMatrix();
  531. }
  532.  
  533. public static void drawHLine(float x2, float y2, float x1, int y1) {
  534. if (y2 < x2) {
  535. float var5 = x2;
  536. x2 = y2;
  537. y2 = var5;
  538. }
  539. RenderUtils.drawRect(x2, x1, y2 + 1.0f, x1 + 1.0f, y1);
  540. }
  541.  
  542. public static void drawVLine(float x2, float y2, float x1, int y1) {
  543. if (x1 < y2) {
  544. float var5 = y2;
  545. y2 = x1;
  546. x1 = var5;
  547. }
  548. RenderUtils.drawRect(x2, y2 + 1.0f, x2 + 1.0f, x1, y1);
  549. }
  550.  
  551. public static void drawHLine(float x2, float y2, float x1, int y1, int y22) {
  552. if (y2 < x2) {
  553. float var5 = x2;
  554. x2 = y2;
  555. y2 = var5;
  556. }
  557. RenderUtils.drawGradientRect(x2, x1, y2 + 1.0f, x1 + 1.0f, y1, y22);
  558. }
  559.  
  560. public static void drawRect(float x2, float y2, float x1, float y1, float r2, float g2, float b2, float a2) {
  561. RenderUtils.enableGL2D();
  562. GL11.glColor4f(r2, g2, b2, a2);
  563. RenderUtils.drawRect(x2, y2, x1, y1);
  564. RenderUtils.disableGL2D();
  565. }
  566.  
  567. public static void drawRect(float x2, float y2, float x1, float y1) {
  568. GL11.glBegin(7);
  569. GL11.glVertex2f(x2, y1);
  570. GL11.glVertex2f(x1, y1);
  571. GL11.glVertex2f(x1, y2);
  572. GL11.glVertex2f(x2, y2);
  573. GL11.glEnd();
  574. }
  575.  
  576. public static void drawCircle(float cx, float cy2, float r2, int num_segments, int c2) {
  577. cx *= 2.0f;
  578. cy2 *= 2.0f;
  579. float f2 = (float) (c2 >> 24 & 255) / 255.0f;
  580. float f22 = (float) (c2 >> 16 & 255) / 255.0f;
  581. float f3 = (float) (c2 >> 8 & 255) / 255.0f;
  582. float f4 = (float) (c2 & 255) / 255.0f;
  583. float theta = (float) (6.2831852 / (double) num_segments);
  584. float p2 = (float) Math.cos(theta);
  585. float s = (float) Math.sin(theta);
  586. float x2 = r2 *= 2.0f;
  587. float y2 = 0.0f;
  588. RenderUtils.enableGL2D();
  589. GL11.glScalef(0.5f, 0.5f, 0.5f);
  590. GL11.glColor4f(f22, f3, f4, f2);
  591. GL11.glBegin(2);
  592. int ii2 = 0;
  593. while (ii2 < num_segments) {
  594. GL11.glVertex2f(x2 + cx, y2 + cy2);
  595. float t = x2;
  596. x2 = p2 * x2 - s * y2;
  597. y2 = s * t + p2 * y2;
  598. ++ii2;
  599. }
  600. GL11.glEnd();
  601. GL11.glScalef(2.0f, 2.0f, 2.0f);
  602. RenderUtils.disableGL2D();
  603. }
  604.  
  605. public static void drawFullCircle(int cx, int cy2, double r2, int c2) {
  606. r2 *= 2.0;
  607. cx *= 2;
  608. cy2 *= 2;
  609. float f2 = (float) (c2 >> 24 & 255) / 255.0f;
  610. float f22 = (float) (c2 >> 16 & 255) / 255.0f;
  611. float f3 = (float) (c2 >> 8 & 255) / 255.0f;
  612. float f4 = (float) (c2 & 255) / 255.0f;
  613. RenderUtils.enableGL2D();
  614. GL11.glScalef(0.5f, 0.5f, 0.5f);
  615. GL11.glColor4f(f22, f3, f4, f2);
  616. GL11.glBegin(6);
  617. int i2 = 0;
  618. while (i2 <= 360) {
  619. double x2 = Math.sin((double) i2 * 3.141592653589793 / 180.0) * r2;
  620. double y2 = Math.cos((double) i2 * 3.141592653589793 / 180.0) * r2;
  621. GL11.glVertex2d((double) cx + x2, (double) cy2 + y2);
  622. ++i2;
  623. }
  624. GL11.glEnd();
  625. GL11.glScalef(2.0f, 2.0f, 2.0f);
  626. RenderUtils.disableGL2D();
  627. }
  628.  
  629. public static void drawSmallString(String s, int x2, int y2, int color) {
  630. GL11.glPushMatrix();
  631. GL11.glScalef(0.5f, 0.5f, 0.5f);
  632. Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(s, x2 * 2, y2 * 2, color);
  633. GL11.glPopMatrix();
  634. }
  635.  
  636. public static void drawLargeString(String text, int x2, int y2, int color) {
  637. GL11.glPushMatrix();
  638. GL11.glScalef(1.5f, 1.5f, 1.5f);
  639. GL11.glPopMatrix();
  640. }
  641.  
  642. private static ScaledResolution scaledResolution;
  643.  
  644. public static ScaledResolution getScaledResolution() {
  645. return scaledResolution;
  646. }
  647. /* End of HashExec's Methods */
  648. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement