Jump to content

[1.7.2] Overlays issue, only two rendering in game


zacharyjaiden

Recommended Posts

for some stupid reason idk if its a minor mistake ive overlooked or forge limits but i can only render 2 overlays in game at any one time....

 

i have 2 overlays that render in a pair when a pickaxe is present in hand...

 

as i have finished mostly all the work around pickaxes in my mod i decided to move on to the axe when i came across this problem..

the overlay for axe just will not render when the other two associated with the pickaxe are present..... although if i comment out (/****/) one of the pick axes guis the axes then works so it makes me think that it is either one a typo that i keep overlooking that somebody may find or maybe limitations

 

EDIT: Before actually posting this i had a stroke of genius and fixed my problem so ill post the solution that i found for the sake of helping anyone else out with the same problem (Ive only been modding a week or two so this is probably just a stupid mistake thats extremely obvious)

 

BUT i still am curious as to why i can only have two classes that render overlays???? this question still stands in case i want to add completely different and separate overlays in the future what was i doing wrong (if anything) or is it just a limitation of forge???

 

THE FIX, instead of having two classes one for pickaxe one for axe i put in two if statements

if player is holding axe reference the value associated to respective class..

if player is holding pickaxe reference the value associated to respective class i can probably do Much more cleaning up of the code as there are probably unnecessary code value declarations variables etc that are in the statements that shouldnt be but for now its working which solved my issue

 

class one PICKAXE LEVEL OVERLAY (keep in mind this is the FIXED solution version of the file)

 

package com.MCR.MinecraftReloaded.LevelingLib;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.entity.EntityClientPlayerMP;

import net.minecraft.client.gui.GuiIngame;

import net.minecraft.client.gui.ScaledResolution;

import net.minecraft.item.ItemAxe;

import net.minecraft.item.ItemPickaxe;

import net.minecraftforge.client.event.RenderGameOverlayEvent;

 

import org.lwjgl.opengl.GL11;

 

import com.MCR.MinecraftReloaded.Items.ModItemLevelInfoDisplay;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class OverlayMiningLevel extends GuiIngame {

 

    OverlayMiningLevel Instance = this;

 

    public OverlayMiningLevel() {

        super(Minecraft.getMinecraft());

    }

 

 

 

 

    @SubscribeEvent

    public void onRenderGameOverlay(RenderGameOverlayEvent event) {

        if (event.type == RenderGameOverlayEvent.ElementType.TEXT) {

 

                Instance.renderOverlay();

 

        }

    }

 

 

 

    @SideOnly(Side.CLIENT)

    public void renderOverlay()

    {

        ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);

        int width = scaledresolution.getScaledWidth();

        int height = scaledresolution.getScaledHeight();

 

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glDisable(GL11.GL_LIGHTING);

        GL11.glEnable(GL11.GL_BLEND);

 

        EntityClientPlayerMP player = this.mc.thePlayer;

        //////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////

        if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemAxe){

        System.out.print("WoodCutting overlay main iftool statement is working") ;

        StorageWoodCuttingLevel woodcuttinglevel = StorageWoodCuttingLevel.get(player);

 

        int WoodCuttingLevel;

 

        if(woodcuttinglevel != null)

        WoodCuttingLevel = woodcuttinglevel.GetLevel();

        else

        WoodCuttingLevel = 0;

 

 

        int x = 0;

        int y = 0;

 

        if(UtilsWoodCuttingLevel.TextArea == 1){

            x = width - 40;

            y = 15;

        }else if (UtilsWoodCuttingLevel.TextArea == 2){

            x = 40;

            y = 15;

        }else if (UtilsWoodCuttingLevel.TextArea == 3){

            x = width - 40;

            y = height - 15;

        }else if (UtilsWoodCuttingLevel.TextArea == 4){

            x = 40;

            y = height - 15;

 

        }else{

            x = width - 40;

            y = 15;

        }

 

        String Pre = UtilsWoodCuttingLevel.LevelMark;

 

       

            this.drawCenteredString(this.mc.fontRenderer, Pre + WoodCuttingLevel, x, y, 0xffffff);

 

 

 

 

 

 

        GL11.glDisable(GL11.GL_BLEND);

    }

      /////////////////////////////////////////////////////////

        ///////////////////////////////////////////////////////

       

        if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ModItemLevelInfoDisplay | player.inventory.getCurrentItem().getItem() instanceof ItemPickaxe){

        System.out.print("Normal overlay working ") ;

       

        StorageMiningLevel level = StorageMiningLevel.get(player);

 

        int Level;

 

        if(level != null)

        Level = level.GetLevel();

        else

        Level = 0;

 

 

        int x = 0;

        int y = 0;

 

        if(UtilsMiningLevel.TextArea == 1){

            x = 40;

            y = 15;

        }else if (UtilsMiningLevel.TextArea == 2){

            x = 40;

            y = 15;

        }else if (UtilsMiningLevel.TextArea == 3){

            x = width - 40;

            y = height - 15;

        }else if (UtilsMiningLevel.TextArea == 4){

            x = 40;

            y = height - 15;

 

        }else{

            x = width - 40;

            y = 15;

        }

 

        String Pre = UtilsMiningLevel.LevelMark;

 

 

            this.drawCenteredString(this.mc.fontRenderer, Pre + Level, x, y, 0xffffff);

       

 

 

 

 

 

        GL11.glDisable(GL11.GL_BLEND);

    }

    }

    }

 

 

 

 

 

 

class two PICKAXE EXPERIENCE

 

 

package com.MCR.MinecraftReloaded.LevelingLib;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.Minecraft;

import net.minecraft.client.entity.EntityClientPlayerMP;

import net.minecraft.client.gui.GuiIngame;

import net.minecraft.client.gui.ScaledResolution;

import net.minecraft.item.ItemPickaxe;

import net.minecraftforge.client.event.RenderGameOverlayEvent;

 

import org.lwjgl.opengl.GL11;

 

import com.MCR.MinecraftReloaded.Items.ModItemLevelInfoDisplay;

 

public class OverlayMiningExperience extends GuiIngame {

 

    OverlayMiningExperience Instance = this;

 

    public OverlayMiningExperience() {

        super(Minecraft.getMinecraft());

    }

 

 

 

 

    @SubscribeEvent

    public void onRenderGameOverlay(RenderGameOverlayEvent event) {

        if (event.type == RenderGameOverlayEvent.ElementType.TEXT) {

 

                Instance.renderOverlay();

 

        }

    }

 

 

 

    @SideOnly(Side.CLIENT)

    public void renderOverlay()

    {

        ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);

        int width = scaledresolution.getScaledWidth();

        int height = scaledresolution.getScaledHeight();

 

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glDisable(GL11.GL_LIGHTING);

        GL11.glEnable(GL11.GL_BLEND);

 

        EntityClientPlayerMP player = this.mc.thePlayer;

        if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ModItemLevelInfoDisplay | player.inventory.getCurrentItem().getItem() instanceof ItemPickaxe){

               

        StorageMiningExperience Experience = StorageMiningExperience.get(player);

 

        int Exp;

 

        if(Experience != null)

        Exp = Experience.GetExperience();

        else

        Exp = 0;

 

 

        int x = 0;

        int y = 0;

 

        if(UtilsMiningExperience.TextArea == 1){

            x = 40;

            y = 30;

        }else if (UtilsMiningExperience.TextArea == 2){

            x = 40;

            y = 15;

        }else if (UtilsMiningExperience.TextArea == 3){

            x = width - 40;

            y = height - 15;

        }else if (UtilsMiningExperience.TextArea == 4){

            x = 40;

            y = height - 15;

 

        }else{

            x = width - 40;

            y = 15;

        }

 

        String Pre = UtilsMiningExperience.ExperienceMark;

 

       

            this.drawCenteredString(this.mc.fontRenderer, Pre + Exp, x, y, 0xffffff);

       

 

 

 

 

 

        GL11.glDisable(GL11.GL_BLEND);

    }

}

}

 

 

 

 

third and final AXE LEVELING (it is now combined in the first class pickaxe leveling)

 

 

package com.MCR.MinecraftReloaded.LevelingLib;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.entity.EntityClientPlayerMP;

import net.minecraft.client.gui.GuiIngame;

import net.minecraft.client.gui.ScaledResolution;

import net.minecraft.item.ItemAxe;

import net.minecraft.item.ItemPickaxe;

import net.minecraftforge.client.event.RenderGameOverlayEvent;

 

import org.lwjgl.opengl.GL11;

 

import com.MCR.MinecraftReloaded.Items.ModItemLevelInfoDisplay;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class OverlayWoodCutting extends GuiIngame {

 

    OverlayWoodCutting Instance = this;

 

    public OverlayWoodCutting() {

        super(Minecraft.getMinecraft());

    }

 

 

 

 

    @SubscribeEvent

    public void onRenderGameOverlay(RenderGameOverlayEvent event) {

        if (event.type == RenderGameOverlayEvent.ElementType.TEXT) {

 

                Instance.renderOverlay();

 

        }

    }

 

 

 

    @SideOnly(Side.CLIENT)

    public void renderOverlay()

    {

        ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);

        int width = scaledresolution.getScaledWidth();

        int height = scaledresolution.getScaledHeight();

 

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glDisable(GL11.GL_LIGHTING);

        GL11.glEnable(GL11.GL_BLEND);

 

        EntityClientPlayerMP player = this.mc.thePlayer;

 

        if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemAxe){

        System.out.print("WoodCutting overlay main iftool statement is working") ;

        StorageWoodCuttingLevel woodcuttinglevel = StorageWoodCuttingLevel.get(player);

 

        int WoodCuttingLevel;

 

        if(woodcuttinglevel != null)

        WoodCuttingLevel = woodcuttinglevel.GetLevel();

        else

        WoodCuttingLevel = 0;

 

 

        int x = 0;

        int y = 0;

 

        if(UtilsWoodCuttingLevel.TextArea == 1){

            x = width - 40;

            y = 15;

        }else if (UtilsWoodCuttingLevel.TextArea == 2){

            x = 40;

            y = 15;

        }else if (UtilsWoodCuttingLevel.TextArea == 3){

            x = width - 40;

            y = height - 15;

        }else if (UtilsWoodCuttingLevel.TextArea == 4){

            x = 40;

            y = height - 15;

 

        }else{

            x = width - 40;

            y = 15;

        }

 

        String Pre = UtilsWoodCuttingLevel.LevelMark;

 

       

            this.drawCenteredString(this.mc.fontRenderer, Pre + WoodCuttingLevel, x, y, 0xffffff);

 

 

 

 

 

 

        GL11.glDisable(GL11.GL_BLEND);

    }

    }

}

 

 

 

 

any ideas on the matter would be appreciated :)

 

Link to comment
Share on other sites

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

    • One of my players is suddenly unable to join a locally hosted MC Eternal server. We have been playing on this server for about 2-3 weeks now. I have tried erasing his player files and his reputation file, and now it just coughs up this and kicks him out: [User Authenticator #5/INFO] [minecraft/NetHandlerLoginServer]: UUID of player EthosTheGod is 7692d8db-02c3-424f-a4ab-0e4e259b106b [20:25:36] [User Authenticator #4/INFO] [minecraft/NetHandlerLoginServer]: UUID of player EthosTheGod is 7692d8db-02c3-424f-a4ab-0e4e259b106b [20:29:35] [Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 575849ms behind, skipping 11516 tick(s) [20:29:35] [Server thread/INFO] [minecraft/NetHandlerLoginServer]: com.mojang.authlib.GameProfile@4a6c63f1[id=7692d8db-02c3-424f-a4ab-0e4e259b106b,name=EthosTheGod,properties={textures=[com.mojang.authlib.properties.Property@241ea89e]},legacy=false] (/IP.ADDRESS) lost connection: Disconnected [20:29:35] [Server thread/INFO] [minecraft/NetHandlerLoginServer]: com.mojang.authlib.GameProfile@6ab6c661[id=7692d8db-02c3-424f-a4ab-0e4e259b106b,name=EthosTheGod,properties={textures=[com.mojang.authlib.properties.Property@7f19aae3]},legacy=false] (/IP.ADDRESS) lost connection: Disconnected It just says "connection timed out" on his end. Any ideas?
    • I'm trying to migrate my mod from 1.20 to 1.21. Some packages in the forge api were changed so my mod did have some classes not working. I've changed everything i needed but still is getting me the following error error: cannot access Registry DeferredRegister.create(ForgeRegistries.BLOCKS, FarmMod.MOD_ID); ^ class file for net.minecraft.core.Registry not found The piece of code that is wrong is   public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, FarmMod.MOD_ID); And here are my imports   import com.lucas.farmmod.FarmMod; import com.lucas.farmmod.block.custom.BaseIrrigatorBlock; import com.lucas.farmmod.item.ModItems; import com.lucas.farmmod.item.custom.BaseIrrigatorBlockItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; The class DeferredRegister is throwing the error in the print below     I've tried running rebuilding my project in every way possible, tried refreshing my dependencies but nothing works. What can i do?
    • It sounds like there might be a synchronization issue with your PartEntity. Ensure that the part entity’s position is updated in your entity's tick method to continuously match the main entity’s location.
    • For keyboard and mouse inputs, Minecraft Forge utilizes the event system to manage interactions, making it easier to handle across different mods. If you’re looking to bypass this and read inputs directly, you’d typically look into the KeyboardListener and MouseListener classes in the game's code. These classes process input events directly from the user's hardware. If you're experimenting with inputs a lot, you might find a compact keypad handy for quick commands. Check out numeric keyboard . It can speed up your coding workflow! Good luck!
  • Topics

×
×
  • Create New...

Important Information

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