azovfaschisten

Animated Alpha text minecraft

Sep 21st, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | Source Code | 0 0
  1. package me.tarasov.nifee.abstractions;
  2.  
  3. import org.lwjgl.opengl.GL11;
  4.  
  5. import net.minecraft.client.Minecraft;
  6.  
  7. public class AlphaText {
  8.  
  9.     private Minecraft mc = Minecraft.getMinecraft();
  10.    
  11.     private boolean fadeing;
  12.     private int speed;
  13.     private int fadeamout;
  14.    
  15.     /*
  16.      * CREATED 22.07.2017 - Author Serj.
  17.      */
  18.    
  19.     public AlphaText(int fadeamout, int speed) {
  20.         this.fadeamout = fadeamout;
  21.         this.speed = speed;
  22.     }
  23.  
  24.     public void draw(String text, float x, float y, int color) {
  25.         tick();
  26.         if(fadeamout < 20) return;
  27.         GL11.glPushMatrix();
  28.         GL11.glEnable(GL11.GL_BLEND);
  29.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  30.         mc.fontRenderer.drawString(text, x, y, color + (fadeamout << 24));
  31.         GL11.glDisable(GL11.GL_BLEND);
  32.         GL11.glPopMatrix();
  33.     }
  34.     public void drawShadow(String text, float x, float y, int color) {
  35.         tick();
  36.         if(fadeamout < 20) return;
  37.         GL11.glPushMatrix();
  38.         GL11.glEnable(GL11.GL_BLEND);
  39.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  40.         mc.fontRenderer.drawStringWithShadow(text, x, y, color + (fadeamout << 24));
  41.         GL11.glDisable(GL11.GL_BLEND);
  42.         GL11.glPopMatrix();
  43.     }
  44.     public void drawCenter(String text, float x, float y, int color) {
  45.         tick();
  46.         if(fadeamout < 20) return;
  47.         GL11.glPushMatrix();
  48.         GL11.glEnable(GL11.GL_BLEND);
  49.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  50.         mc.fontRenderer.drawCenteredString(text, x, y, color + (fadeamout << 24));
  51.         GL11.glDisable(GL11.GL_BLEND);
  52.         GL11.glPopMatrix();
  53.     }
  54.    
  55.     private void tick() {
  56.         if(!fadeing) {
  57.             if(fadeamout <= 255) {
  58.                 fadeamout += speed;
  59.             }else {
  60.                 fadeing = true;
  61.             }
  62.         }else {
  63.             if(fadeamout >= 28) {
  64.                 fadeamout -= speed;
  65.             }else {
  66.                 fadeing = false;
  67.             }
  68.         }
  69.     }
  70.    
  71.     public void reset() {
  72.         this.fadeamout = 0;
  73.         this.fadeing = false;
  74.     }
  75.     public int getSpeed() {
  76.         return speed;
  77.     }
  78.  
  79.     public void setSpeed(int speed) {
  80.         this.speed = speed;
  81.     }
  82.  
  83.     public int getFadeAmout() {
  84.         return fadeamout;
  85.     }
  86.  
  87.     public void setFadeAmout(int fade) {
  88.         this.fadeamout = fade;
  89.     }
  90.    
  91.  
  92. }
Tags: minecraft src
Add Comment
Please, Sign In to add comment