Jump to content

Helmet Overlays


ashtonr12

Recommended Posts

If you want to see how it's implemented, take a look there:

net.minecraft.client.gui.GuiIngame.java, line 85

 

It's hard coded and there's no rendering handles around for you to use. The only option I see is to make your own TickHandler, which should receive the RENDER TickType. Put your rendering methods in the tickEnd(...) method and monitor the client if he's wearing your helmet.

 

Edit: I forgot that it will overlay the current HUD elements. That might be bit of a problem indeed ... Ah well.

Link to comment
Share on other sites

Well there's no other option. You either render it with in your TickHandler class ( but your helmet overlay will be rendered over existing HUD elements, like experience bar, hearts and stuff ) or you modify the stock Minecraft GUI classes which handle this. If you're going to modify the method rendering the HUD, just add another condition and copy the method that renders the pumpkin overlay changing the name of the texture. I don't think the TickHandler will be of use in this case, because just like I've said it would cover all of your existing HUD elements.

Link to comment
Share on other sites

It's not really that complicated. The reason why I didn't explain a thing on how to implement a TickHandler is because I didn't know if you want to use them :) It's just a copy-paste job, I'm sure you'd handle that ;) I'm sorry to hear you're eventually dumping the idea though.

 

Cheers!

Link to comment
Share on other sites

ok so i am slightly confused, probably because i am so tired. Thanks for all your help so far.

Is is possible without editing the base minecraft files to add a custom overlay to my self created helmet?

if yes how? example code or suggestions?

if no thanks for your help so far :)

 

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

Alrighty then ... with this code you will get the following result ( in my case when wearing a golden helmet - just change it ):

 

spzcK3Hl.png

 

Bear in mind though, that it will cover all of the existing HUD elements ( just as in the image ). Also the helmet overlay is not drawn when a menu is opened, because that would cover the entire menu :) Here's the code for the renderer:

 

http://paste.minecraftforge.net/view/6cff4e04

 

Also, add the following line in your mod init method:

 

TickRegistry.registerTickHandler(new RenderHUD(), Side.CLIENT);

 

That should do the trick. Let me know if that's what were you looking for :)

Link to comment
Share on other sites

WOW!

you must be very advanced at this if you came up with that!

is it possible to change the overlay? to say a see through circle in the middle and  black area around the outside?

i also notice that the item bar is behind the overlay? and when you put on a pumkin head the item bar is infront of the overlay?

dont misunderstand me i am immensly gratefull :D i was just wondering if it is possible to change the black squidy areas?

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

It's just a matter of a custom texture file. Make your new overlay with transparency ( in GIMP for instance, but could be pretty much anything ), save it in PNG format and paste it into jars/bin/minecraft.jar/... Then in my paste change this part:

 

%blur%/misc/pumpkinblur.png

 

... into:

 

%blur%/<your path to the new texture inside the minecraft.jar>

 

i also notice that the item bar is behind the overlay? and when you put on a pumkin head the item bar is infront of the overlay?

 

That's what I was rambling all about all this time :D This method has one big disadvantage: you will have all of these HUD elements like: experience bar, handy inventory at the bottom of the screen, health and hunger levels covered by the overlay texture. There's no way around it unfortunately. Unless you modify the Minecraft. Or a miracle happens and the Forge team puts some render handlers in there to have some control over layering the overlays but I don't think it's gonna happen any time soon :)

 

Cheers

Link to comment
Share on other sites

But I've told you that already:

 

It's just a matter of a custom texture file. Make your new overlay with transparency ( in GIMP for instance, but could be pretty much anything ), save it in PNG format and paste it into jars/bin/minecraft.jar/... Then in my paste change this part:

 

%blur%/misc/pumpkinblur.png

 

... into:

 

%blur%/<your path to the new texture inside the minecraft.jar>

 

You need to put your texture file inside of the minecraft.jar file. Open it up with any archiver like WinZIP, 7-Zip and paste your texture in there.

Link to comment
Share on other sites

I am using a custom helmet

 

package ashtonsmod.common;

import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;

public class MinersHelmet extends ItemArmor implements IArmorTextureProvider{

        public MinersHelmet(int par1,EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) {
                super(par1, par2EnumArmorMaterial, par3, par4);
        }

	@Override
    	public String getTextureFile(){
    		return CommonProxy.items_png;
         }

        public String getArmorTextureFile(ItemStack par1){
                if ( par1.itemID==ashtonsmod.ObsidianHelmet.shiftedIndex){
                        return "/armor/AbsorbingArmor_1.png";
                }return "/armor/AbsorbingArmor_2.png";
        }
}

 

however it worked before i used the overlays? i have provided code anyway in case i have made some stupid error.

 

Overlay code

package ashtonsmod.common;

import java.util.EnumSet;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class MiningHelmetOverlay implements ITickHandler
{
        @Override
        public void tickStart(EnumSet<TickType> type, Object... tickData)
        {
               
        }

        @Override
        public void tickEnd(EnumSet<TickType> type, Object... tickData)
        {
                if(Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().currentScreen != null)
                        return;
               
                ItemStack helmet = Minecraft.getMinecraft().thePlayer.inventory.armorItemInSlot(3);
                if(Minecraft.getMinecraft().gameSettings.thirdPersonView == 0 && helmet != null && helmet.itemID == ashtonsmod.MinersHelmet.shiftedIndex)
                {
                        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
                       
                        Tessellator t = Tessellator.instance;
                       
                        ScaledResolution scale = new ScaledResolution(Minecraft.getMinecraft().gameSettings, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
                        int width = scale.getScaledWidth();
                        int height = scale.getScaledHeight();
                       
                        GL11.glDisable(GL11.GL_DEPTH_TEST);
                        GL11.glDepthMask(false);
                        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                        GL11.glDisable(GL11.GL_ALPHA_TEST);
                        GL11.glBindTexture(GL11.GL_TEXTURE_2D, Minecraft.getMinecraft().renderEngine.getTexture("%blur%/armor/MiningHelmetblur.png"));
                       
                        t.startDrawingQuads();
                        t.addVertexWithUV(0.0D, (double)height, 90.0D, 0.0D, 1.0D);
                        t.addVertexWithUV((double)width, (double)height, 90.0D, 1.0D, 1.0D);
                        t.addVertexWithUV((double)width, 0.0D, 90.0D, 1.0D, 0.0D);
                        t.addVertexWithUV(0.0D, 0.0D, 90.0D, 0.0D, 0.0D);
                        t.draw();
                       
                        GL11.glPopAttrib();
                }
        }

        @Override
        public EnumSet<TickType> ticks()
        {
                return EnumSet.of(TickType.RENDER);
        }

        @Override
        public String getLabel()
        {
                return "render hud tick handler";
        }

}

 

Use examples, i have aspergers.

Examples make sense to me.

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

    • tried it, it worked! Thank you kind stranger. Still a weird bug with that version of forge, but everything works now so it's fine.
    • New to forge modding, I'm currently trying to make a client side only mod that basically just reproduces the numbers for entities in FOV and total entity count shown in the F3 toggle (E: # in fov/# total). Basically just trying to take these numbers and display them in the center of the screen (without having F3 open) so they can be seen constantly.Been primarily learning forge using ChatGPT but it seems to spew out incorrect code over and over again when I ask it how it would do something like this (probably confusing versions and such). Not sure if these numbers can be directly accessed or not or if its more complicated than that.   This is my current code I basically just need to implement the 2 methods at the bottom. Any info/help is appreciated. import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGuiOverlayEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraft.world.entity.Entity; import net.minecraft.client.multiplayer.ClientLevel; @Mod.EventBusSubscriber(modid = "myforgehudmod", value = Dist.CLIENT) public class MyCustomHUD { @SubscribeEvent public static void onRenderHUD(RenderGuiOverlayEvent.Post event) { Minecraft minecraft = Minecraft.getInstance(); GuiGraphics guiGraphics = event.getGuiGraphics(); int screenWidth = minecraft.getWindow().getGuiScaledWidth(); int screenHeight = minecraft.getWindow().getGuiScaledHeight(); int totalEntities = countTotalEntities(minecraft); int entitiesInFOV = countEntitiesInFOV(minecraft); String hudText = entitiesInFOV + " / " + totalEntities; int textWidth = minecraft.font.width(hudText); int x = (screenWidth / 2) - (textWidth / 2); int y = screenHeight / 2; y = y + 10; // x,y is directly below crosshair by 10 pixels with centered text guiGraphics.drawString(minecraft.font, hudText, x, y, 0xFFFFFF); } private static int countTotalEntities(Minecraft minecraft) { return 0; } private static int countEntitiesInFOV(Minecraft minecraft) { return 0; } }  
    • Please let me know if there is a good solution: Hey Y'all, sorry to bother you, but I believe I'm getting an error between jurassicworld reborn and jurassicraft when I'm attempting to open my world. The world used to work with both mods active, and so I'm posting here to see why it doesn't work anymore, and if there is a solution to fix it that doesn't include taking out either, as doing that will take out a big part/amount of blocks out of my world. If not, then please let me know. Also, please let me know if more info is needed, as this was all of the crash report that would fit. Thanks for the help, look forward to hearing from you! Crash report Link: https://pastebin.com/K1H0qsmW
    • The game crashed whilst initializing game Error: java.lang.IllegalAccessError: class net.minecraft.client.Options tried to access private field net.minecraft.client.Minecraft.f_91036_ (net.minecraft.client.Options and net.minecraft.client.Minecraft are in module [email protected] of loader 'TRANSFORMER' @4232b34a)    wasnt allowed to put up the whole crash report but i rly want help
  • Topics

×
×
  • Create New...

Important Information

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