Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.lwjgl.opengl.GL11;
- import org.lwjgl.input.Keyboard;
- import net.minecraft.client.Minecraft;
- public class mod_hurtflash extends BaseMod {
- public int hurtColor = 0xff0000;
- public int healColor = 0x0000ff;
- public static mod_hurtflash inst;
- public float maxAlpha = 0.4f;
- public Minecraft mc = ModLoader.getMinecraftInstance();
- public int fadeColor;
- public float fadeColorStep, fadeColorStop, fadeColorAlpha;
- public boolean fadeColorRunning = false;
- public String fadeImagePath;
- public float fadeImageStep, fadeImageStop, fadeImageAlpha;
- public boolean fadeImageRunning = false;
- public long clock;
- public long timedImageTicks;
- public boolean timedImageRunning;
- public float timedImageAlpha;
- public String timedImage;
- public long timedColorTicks;
- public boolean timedColorRunning;
- public float timedColorAlpha;
- public int timedColor;
- public mod_hurtflash() {
- inst = this;
- ModLoader.SetInGameHook(this, true, false);
- }
- public void OnTickInGame(Minecraft game) {
- if (game.q != null)
- return;
- if (Keyboard.isKeyDown(Keyboard.KEY_Y)) {
- GL11.glDisable(GL11.GL_DEPTH_TEST);
- } else {
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- }
- // these are just examples on how to use the methods
- // you can just as well call these from outside of mod_hurtflash.class
- // like in the poison arrow you could do fadeColor purple etc
- if (game.g != null && game.g.X > 0) {
- float a = Math.min(Math.max((float)game.g.X / game.g.Y, 0f), maxAlpha);
- flashColor(a, hurtColor);
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
- fadeColor(healColor, 0f, 0.05f, 0.5f);
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
- displayImage("%blur%/misc/vignette.png", 0.4f, 100);
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
- fadeImage("%blur%/misc/pumpkinblur.png", 1f, -0.05f, 0f);
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
- displayColor(healColor, 0.7f, 100);
- }
- if (fadeColorRunning) {
- flashColor(fadeColorAlpha, fadeColor);
- fadeColorAlpha += fadeColorStep;
- if ((fadeColorStep > 0 && fadeColorAlpha > fadeColorStop) || (fadeColorStep < 0 && fadeColorAlpha < fadeColorStop))
- fadeColorRunning = false;
- }
- if (fadeImageRunning) {
- flashImage(fadeImagePath, fadeImageAlpha);
- fadeImageAlpha += fadeImageStep;
- if ((fadeImageStep > 0 && fadeImageAlpha > fadeImageStop) || (fadeImageStep < 0 && fadeImageAlpha < fadeImageStop))
- fadeImageRunning = false;
- }
- if (mc.e != null && (timedImageRunning || timedColorRunning)) {
- long l = mc.e.r();
- if (timedImageRunning) {
- flashImage(timedImage, timedImageAlpha);
- if (l != clock) {
- timedImageTicks--;
- if (timedImageTicks <= 0) {
- timedImageRunning = false;
- }
- }
- }
- if (timedColorRunning) {
- flashColor(timedColorAlpha, timedColor);
- if (l != clock) {
- timedColorTicks--;
- if (timedColorTicks <= 0) {
- timedColorRunning = false;
- }
- }
- }
- clock = l;
- }
- }
- public void displayColor(int color, float alpha, long ticks) {
- timedColor = color;
- timedColorAlpha = alpha;
- timedColorTicks = ticks;
- timedColorRunning = true;
- }
- public void displayImage(String path, float alpha, long ticks) {
- timedImageRunning = true;
- timedImage = path;
- timedImageAlpha = alpha;
- timedImageTicks = ticks;
- }
- public void fadeColor(int color_, float alpha_, float step_, float stop_) {
- fadeColor = color_;
- fadeColorAlpha = alpha_;
- fadeColorStep = step_;
- fadeColorStop = stop_;
- fadeColorRunning = true;
- }
- public void fadeImage(String path, float alpha, float step, float stop) {
- fadeImagePath = path;
- fadeImageAlpha = alpha;
- fadeImageStep = step;
- fadeImageStop = stop;
- fadeImageRunning = true;
- }
- public void flashColor(float a, int color) {
- float r = (float)(color >> 16 & 0xff) / 255F;
- float g = (float)(color >> 8 & 0xff) / 255F;
- float b = (float)(color & 0xff) / 255F;
- flashColor(a, r, g, b);
- }
- public void flashColor(float a, float r, float g, float b) {
- int i = 0, k = 0;
- mt kh1 = new mt(mc.c, mc.d);
- int l = kh1.a();
- int i1 = kh1.b();
- kv kv1 = kv.a;
- GL11.glEnable(3042);
- GL11.glDisable(3553);
- GL11.glBlendFunc(770, 771);
- GL11.glColor4f(r, g, b, a);
- kv1.b();
- kv1.a(i, i1, 0.0D);
- kv1.a(l, i1, 0.0D);
- kv1.a(l, k, 0.0D);
- kv1.a(i, k, 0.0D);
- kv1.a();
- GL11.glEnable(3553);
- GL11.glDisable(3042);
- }
- public void flashImage(String path, float alpha) {
- mt kh1 = new mt(mc.c, mc.d);
- int width = kh1.a();
- int height = kh1.b();
- GL11.glEnable(3042);
- GL11.glDisable(2929);
- GL11.glDepthMask(false);
- GL11.glBlendFunc(770, 771);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha);
- GL11.glDisable(3008);
- GL11.glBindTexture(3553, mc.o.a(path));
- kv tessellator = kv.a;
- tessellator.b();
- tessellator.a(0.0D, height, -90.0D, 0.0D, 1.0D);
- tessellator.a(width, height, -90.0D, 1.0D, 1.0D);
- tessellator.a(width, 0.0D, -90.0D, 1.0D, 0.0D);
- tessellator.a(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
- tessellator.a();
- GL11.glDepthMask(true);
- GL11.glEnable(2929);
- GL11.glEnable(3008);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha);
- }
- public String Version() {
- return "wahtever";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment