Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.tarasov.nifee.abstractions;
- import org.lwjgl.opengl.GL11;
- import net.minecraft.client.Minecraft;
- public class AlphaText {
- private Minecraft mc = Minecraft.getMinecraft();
- private boolean fadeing;
- private int speed;
- private int fadeamout;
- /*
- * CREATED 22.07.2017 - Author Serj.
- */
- public AlphaText(int fadeamout, int speed) {
- this.fadeamout = fadeamout;
- this.speed = speed;
- }
- public void draw(String text, float x, float y, int color) {
- tick();
- if(fadeamout < 20) return;
- GL11.glPushMatrix();
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- mc.fontRenderer.drawString(text, x, y, color + (fadeamout << 24));
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glPopMatrix();
- }
- public void drawShadow(String text, float x, float y, int color) {
- tick();
- if(fadeamout < 20) return;
- GL11.glPushMatrix();
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- mc.fontRenderer.drawStringWithShadow(text, x, y, color + (fadeamout << 24));
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glPopMatrix();
- }
- public void drawCenter(String text, float x, float y, int color) {
- tick();
- if(fadeamout < 20) return;
- GL11.glPushMatrix();
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- mc.fontRenderer.drawCenteredString(text, x, y, color + (fadeamout << 24));
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glPopMatrix();
- }
- private void tick() {
- if(!fadeing) {
- if(fadeamout <= 255) {
- fadeamout += speed;
- }else {
- fadeing = true;
- }
- }else {
- if(fadeamout >= 28) {
- fadeamout -= speed;
- }else {
- fadeing = false;
- }
- }
- }
- public void reset() {
- this.fadeamout = 0;
- this.fadeing = false;
- }
- public int getSpeed() {
- return speed;
- }
- public void setSpeed(int speed) {
- this.speed = speed;
- }
- public int getFadeAmout() {
- return fadeamout;
- }
- public void setFadeAmout(int fade) {
- this.fadeamout = fade;
- }
- }
Add Comment
Please, Sign In to add comment