Jump to content

Recommended Posts

Posted

Hey, im trying to add a new feature to a mod of mine, it basically allow the user to make the "object" bigger or smaller on his screen, i will add an scrolling bar to modify this value but first i need to make it work, this is my code:

 



 

package com.henixmc.www.coders.infinity.mods.clockmod;

import java.awt.Color;
import java.text.SimpleDateFormat;

import org.lwjgl.opengl.GL11;

import com.henixmc.www.coders.infinity.mods.keystrokes.KeystrokesMod;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraftforge.client.event.RenderGameOverlayEvent;

public class CLOCKRenderer
{
    private final Minecraft mc;
    int index = 0;
    long x = 0L;

    public static Color rainbowEffect(float f, float fade)
    {
        int speed = 10000 / KeystrokesMod.chromaspeed;
        int color = Color.HSBtoRGB((float)(System.currentTimeMillis() % speed) / speed, 0.7F, 0.8F);
        Color c = new Color((int)color);
        return new Color(c.getRed() / 255.0F * fade, c.getGreen() / 255.0F * fade, c.getBlue() / 255.0F * fade, c.getAlpha() / 255.0F);
    }

    public CLOCKRenderer()
    {
        this.mc = Minecraft.getMinecraft();
    }

    @SubscribeEvent
    public void onRenderGameOverlay(RenderGameOverlayEvent event)
    {
        if ((event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE) || (event.isCancelable())) {
            return;
        }
        if ((!KeystrokesMod.enabledClock)) {
            return;
        }
        if ((this.mc.gameSettings.showDebugInfo)) {
            return;
        }
        int clockcolor = Integer.MAX_VALUE;
        if (KeystrokesMod.ColorsClock == 0) {
            clockcolor = 2130706432;
        } else if (KeystrokesMod.ColorsClock == 1) {
            clockcolor = 2130706602;
        } else if (KeystrokesMod.ColorsClock == 2) {
            clockcolor = 2130749952;
        } else if (KeystrokesMod.ColorsClock == 3) {
            clockcolor = 2130750122;
        } else if (KeystrokesMod.ColorsClock == 4) {
            clockcolor = 2141847552;
        } else if (KeystrokesMod.ColorsClock == 5) {
            clockcolor = 2141847722;
        } else if (KeystrokesMod.ColorsClock == 6) {
            clockcolor = 2147461632;
        } else if (KeystrokesMod.ColorsClock == 7) {
            clockcolor = 2141891242;
        } else if (KeystrokesMod.ColorsClock == 8) {
            clockcolor = 2136298837;
        } else if (KeystrokesMod.ColorsClock == 9) {
            clockcolor = 2136299007;
        } else if (KeystrokesMod.ColorsClock == 10) {
            clockcolor = 2136342357;
        } else if (KeystrokesMod.ColorsClock == 11) {
            clockcolor = 2136342527;
        } else if (KeystrokesMod.ColorsClock == 12) {
            clockcolor = 2147439957;
        } else if (KeystrokesMod.ColorsClock == 13) {
            clockcolor = 2147440127;
        } else if (KeystrokesMod.ColorsClock == 14) {
            clockcolor = 2147483477;
        } else if (KeystrokesMod.ColorsClock == 15) {
            clockcolor = Integer.MAX_VALUE;
        } else if (KeystrokesMod.ColorsClock == 16) {
            clockcolor = rainbowEffect(this.index + (float)this.x * 4000.0F, 1.0F).getRGB();
        }
        else if (KeystrokesMod.ColorsClock == 17) {
            Color textdemocolor = new Color(KeystrokesMod.r2, KeystrokesMod.g2, KeystrokesMod.b2, KeystrokesMod.alpha2);
            clockcolor = textdemocolor.getRGB();
        }


        String timeStamp1 = new SimpleDateFormat("hh:mm:ss").format(new java.util.Date());
        String timeStamp = timeStamp1;
        if(KeystrokesMod.BackgroundBox) {


            Color mycolour = new Color(KeystrokesMod.r, KeystrokesMod.g, KeystrokesMod.b, KeystrokesMod.alpha);

            Gui.drawRect(KeystrokesMod.coordsClockX, KeystrokesMod.coordsClockY, KeystrokesMod.coordsClockX + 58, KeystrokesMod.coordsClockY + 13, mycolour.getRGB());

            this.mc.fontRenderer.drawString(timeStamp, KeystrokesMod.coordsClockX + 9, KeystrokesMod.coordsClockY + 3, clockcolor);
        }

        if(!KeystrokesMod.BackgroundBox) {
            this.mc.fontRenderer.drawStringWithShadow(timeStamp, KeystrokesMod.coordsClockX + 9, KeystrokesMod.coordsClockY + 3, clockcolor);

        }


    }
}
 

 

[/CODE]

 

I was thinking about using this for the scale but it gets kinda buggy and change the scale of everything in the screen if i use it, so, how should i properly use this? or, is there another method?

 

[CODE]

            GL11.glScalef(1.1F, 1.1F, 0.0F);

 

[/CODE]

 

 

 

Screenshot with and without the buggy thing bellow:

 

2017-09-10_19.16.07.png

2017-09-10_19.16.12.png

2017-09-10_19.17.01.png

2017-09-10_19.17.08.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.