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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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