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

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. ๐Ÿ“ˆ Skills: RPG-style skill system that enhances your gaming experience! ๐ŸŽฎ Leaderboards: Compete and shine! Top players are rewarded weekly! ๐Ÿ† Random Teleporter: Travel instantly across different worlds with a click! ๐ŸŒ Custom World Generation: Beautifully generated world. ๐ŸŒ Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. ๐Ÿฐ Kits: Unlock ranks and gain access to various kits. ๐Ÿ› ๏ธ Fishing Tournament: Compete in a friendly fishing tournament! ๐ŸŽฃ Chat Games: Enjoy games right within the chat! ๐ŸŽฒ Minions: Get some help from your loyal minions. ๐Ÿ‘ฅ Piรฑata Party: Enjoy a festive party with Piรฑatas! ๐ŸŽ‰ Quests: Over 1000 quests that you can complete! ๐Ÿ“œ Bounty Hunter: Set a bounty on a player's head. ๐Ÿ’ฐ Tags: Displayed on nametags, in the tab list, and in chat. ๐Ÿท๏ธ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! ๐ŸŸข Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. ๐Ÿ”ฒโœจ[ Player Warp: Set your own warp points for other players to teleport to. ๐ŸŒŸ Display Shop: Create your own shop and sell to other players! ๐Ÿ›’ Item Skins: Customize your items with unique skins. ๐ŸŽจ Pets: Your cute loyal companion to follow you wherever you go! ๐Ÿพ Cosmetics: Enhance the look of your character with beautiful cosmetics! ๐Ÿ’„ XP-Bottle: Store your exp safely in a bottle for later use! ๐Ÿถ Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! ๐Ÿ“ฆ Glowing: Stand out from other players with a colorful glow! โœจ Player Particles: Over 100 unique particle effects to show off. ๐ŸŽ‡ Portable Inventories: Over virtual inventories with ease. ๐Ÿงณ And a lot more! Become part of our growing community today! Discord:ย https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working ย  I am not familiar with Linux - check for similar/related issues ย 
  • Topics

×
×
  • Create New...

Important Information

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