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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Try the latest build: https://modrinth.com/mod/axiom/version/4.1.1
    • *** buffer overflow detected ***: terminated /usr/bin/forge-1.12.2d: line 162: 15787 Aborted                 (core dumped) ${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null Starting server...There are several suitable screens on:     14630.forge-1.12.2    (Detached)     15796.forge-1.12.2    (Detached) Use -S to specify a session How do i fix this issue?
    • Oh I forgot to update the title. I figured out the issue and I'm rather embarrassed to say that it was a file path issue. The game already knew I was accessing the achievements so I wasn't suppose to include advancements in the file path. Minecraft file paths have always confused me a little bit... ResourceLocation advancementId = new ResourceLocation( TheDeadRise.MODID,"adventure/spawntrigger");
    • Can someone help my with this? My forge server won't open and I'm not that good with this stuff. It gave me this error message:   C:\Users\apbeu\Desktop\Forge server>java -Xmx4G -Xms1G -jar server.jar nogui 2024-12-11 18:21:01,054 main WARN Advanced terminal features are not available in this environment [18:21:01] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.34, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [18:21:01] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 21.0.4 by Oracle Corporation Exception in thread "main" java.lang.IllegalAccessError: class cpw.mods.modlauncher.SecureJarHandler (in unnamed module @0x402e37bc) cannot access class sun.security.util.ManifestEntryVerifier (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x402e37bc         at cpw.mods.modlauncher.SecureJarHandler.lambda$static$1(SecureJarHandler.java:45)         at cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck(LamdbaExceptionUtils.java:95)         at cpw.mods.modlauncher.SecureJarHandler.<clinit>(SecureJarHandler.java:45)         at cpw.mods.modlauncher.Launcher.lambda$new$6(Launcher.java:55)         at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:52)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:47)         at cpw.mods.modlauncher.Environment.computePropertyIfAbsent(Environment.java:62)         at cpw.mods.modlauncher.Launcher.<init>(Launcher.java:55)         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63)         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60)         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) C:\Users\apbeu\Desktop\Forge server>pause
    • Here is the url for the crash report if anyone can help me, please. https://mclo.gs/KGn5LWy  
  • Topics

×
×
  • Create New...

Important Information

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