Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. package dyedclient.gui;
  2.  
  3. import java.awt.Color;
  4.  
  5. import org.lwjgl.opengl.GL11;
  6. import org.lwjgl.opengl.GLContext;
  7.  
  8. import net.minecraft.client.Minecraft;
  9. import net.minecraft.client.gui.Gui;
  10. import net.minecraft.client.gui.ScaledResolution;
  11. import net.minecraft.client.renderer.GlStateManager;
  12. import net.minecraft.client.renderer.texture.TextureManager;
  13. import net.minecraft.client.shader.Framebuffer;
  14. import net.minecraft.util.ResourceLocation;
  15. import tv.twitch.broadcast.FrameBuffer;
  16.  
  17. public class SplashProgress {
  18.  
  19. private static final int MAX = 7;
  20. private static int PROGRESS = 0;
  21. private static String CURRENT = "";
  22. private static ResourceLocation splash;
  23. private static UnicodeFontRenderer ufr;
  24.  
  25. public static void update() {
  26. if(Minecraft.getMinecraft() == null || Minecraft.getMinecraft().getLanguageManager() == null) {
  27. return;
  28. }
  29. drawSplash(Minecraft.getMinecraft().getTextureManager());
  30. }
  31.  
  32. public static void setProgress(int givenProgress, String givenText) {
  33. PROGRESS = givenProgress;
  34. CURRENT = givenText;
  35. update();
  36. }
  37.  
  38. public static void drawSplash(TextureManager tm) {
  39. ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
  40. int scaleFactor = scaledResolution.getScaleFactor();
  41.  
  42. Framebuffer framebuffer = new Framebuffer(scaledResolution.getScaledWidth() * scaleFactor, scaledResolution.getScaledHeight() * scaleFactor, true);
  43. framebuffer.bindFramebuffer(false);
  44.  
  45. GlStateManager.matrixMode(GL11.GL_PROJECTION);
  46. GlStateManager.loadIdentity();
  47. GlStateManager.ortho(0.0D, (double) scaledResolution.getScaledWidth(), (double) scaledResolution.getScaledHeight(), 0.0D, 1000.0D, 3000.0D);
  48. GlStateManager.matrixMode(GL11.GL_MODELVIEW);
  49. GlStateManager.translate(0.0F, 0.0F, -2000.0F);
  50. GlStateManager.disableLighting();
  51. GlStateManager.disableFog();
  52. GlStateManager.disableDepth();
  53. GlStateManager.enableTexture2D();
  54.  
  55. if(splash == null) {
  56. splash = new ResourceLocation("dyedclient/splash.png");
  57. }
  58. tm.bindTexture(splash);
  59.  
  60. GlStateManager.resetColor();
  61. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  62.  
  63. Gui.drawScaledCustomSizeModalRect(0, 0, 0, 0, 1920, 1080, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), 1920, 1080);
  64. drawProgress();
  65. framebuffer.unbindFramebuffer();
  66. framebuffer.framebufferRender(scaledResolution.getScaledWidth() * scaleFactor, scaledResolution.getScaledHeight() * scaleFactor);
  67.  
  68. GlStateManager.enableAlpha();
  69. GlStateManager.alphaFunc(516, 0.1F);
  70.  
  71. Minecraft.getMinecraft().updateDisplay();
  72. }
  73.  
  74. private static void drawProgress() {
  75. if(Minecraft.getMinecraft().gameSettings == null || Minecraft.getMinecraft().getTextureManager() == null) {
  76. return;
  77. }
  78.  
  79. if(ufr == null) {
  80. ufr = UnicodeFontRenderer.getFontOnPC("Arial", 20);
  81. }
  82.  
  83. ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
  84. double nProgress = (double) PROGRESS;
  85. double calc = (nProgress / MAX) * sr.getScaledWidth();
  86.  
  87. Gui.drawRect(0, sr.getScaledHeight() - 35, sr.getScaledWidth(), sr.getScaledHeight(), new Color(0, 0, 0, 50).getRGB());
  88.  
  89. GlStateManager.resetColor();
  90. resetTextureState();
  91.  
  92. ufr.drawString(CURRENT, 20, sr.getScaledHeight() - 25, 0xFFFFFFFF);
  93.  
  94. String step = PROGRESS + "/" + MAX;
  95. ufr.drawString(step, sr.getScaledWidth() - 20 - ufr.getStringWidth(step), sr.getScaledHeight() - 25, 0xe1e1e1FF);
  96.  
  97. GlStateManager.resetColor();
  98. resetTextureState();
  99.  
  100. Gui.drawRect(0, sr.getScaledHeight() - 2, (int) calc, sr.getScaledHeight(), new Color(149, 201, 144).getRGB());
  101.  
  102. Gui.drawRect(0, sr.getScaledHeight() - 2, sr.getScaledWidth(), sr.getScaledHeight(), new Color(0, 0, 0, 10).getRGB());
  103. }
  104.  
  105. private static void resetTextureState() {
  106. GlStateManager.textureState[GlStateManager.activeTextureUnit].textureName = -1;
  107. }
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement