Jump to content

Recommended Posts

Posted

My mod implements a halo style gui for minecraft. However the methods I used wont render the image ingame.

 

Im using the exact same method used by the pumpkin blur.

 

The code calls the method (Which ive tested by putting a system.out.println("test") in the method). T

 

he the program also seems to find the image file. (Ive tested it by using an incorrect image location and it responds with the missing image error)

 

So im not sure what time doing wrong.

 

(I know my code has a lot of unused import, im going to clean those up once this issue is fixed)

 

 

Attached Code:

 

HaloHUD class (FML start class)

 

package com.zebomod.halohud;

/*

import net.minecraft.client.Minecraft;

import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.event.FMLInitializationEvent;

 

import cpw.mods.fml.common.gameevent.TickEvent;

import cpw.mods.fml.common.gameevent.TickEvent.Phase;

*/

 

import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;

import net.minecraft.client.settings.KeyBinding;

import net.minecraft.item.ItemStack;

import net.minecraft.util.ChatComponentText;

import net.minecraft.world.EnumSkyBlock;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraft.world.WorldServer;

 

import org.lwjgl.input.Keyboard;

 

import cpw.mods.fml.client.FMLClientHandler;

import cpw.mods.fml.client.registry.ClientRegistry;

import cpw.mods.fml.common.FMLCommonHandler;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

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

import cpw.mods.fml.common.gameevent.TickEvent;

import cpw.mods.fml.common.gameevent.TickEvent.Phase;

import cpw.mods.fml.common.registry.GameData;

 

@Mod(modid = "HaloHUD", name = "Halo HUD", version = "1.0")

public class HaloHUD

{

    public Minecraft mc = Minecraft.getMinecraft();

    private Minecraft mcinstance;

 

    @EventHandler

    public void preinit(FMLPreInitializationEvent event)

    {

        FMLCommonHandler.instance().bus().register(this);

 

    }

   

    @SubscribeEvent

    public void onTick(TickEvent.ClientTickEvent tick)

    {

    if(this.mc.theWorld != null)

    {

    HaloRender test = new HaloRender();

    test.HaloRenderController();

    }

    }

 

}

 

 

 

 

HaloRender Class

 

package com.zebomod.halohud;

 

/*

import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.ScaledResolution;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.util.ResourceLocation;

import net.minecraft.util.Session;

*/

 

import java.util.Collection;

import java.util.Iterator;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.Gui;

import net.minecraft.potion.Potion;

import net.minecraft.potion.PotionEffect;

import net.minecraftforge.client.event.RenderGameOverlayEvent;

import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

 

import java.awt.Color;

import java.util.Collection;

import java.util.Iterator;

import java.util.List;

import java.util.Random;

 

import net.minecraft.block.material.Material;

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.*;

import net.minecraft.client.network.NetHandlerPlayClient;

import net.minecraft.client.renderer.OpenGlHelper;

import net.minecraft.client.renderer.RenderHelper;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.entity.RenderItem;

import net.minecraft.client.renderer.texture.TextureMap;

import net.minecraft.client.resources.I18n;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.entity.ai.attributes.IAttributeInstance;

import net.minecraft.entity.boss.BossStatus;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.Potion;

import net.minecraft.scoreboard.Score;

import net.minecraft.scoreboard.ScoreObjective;

import net.minecraft.scoreboard.ScorePlayerTeam;

import net.minecraft.scoreboard.Scoreboard;

import net.minecraft.util.Direction;

import net.minecraft.util.EnumChatFormatting;

import net.minecraft.util.FoodStats;

import net.minecraft.util.IIcon;

import net.minecraft.util.MathHelper;

import net.minecraft.util.ResourceLocation;

import net.minecraft.util.StringUtils;

import net.minecraft.world.EnumSkyBlock;

import net.minecraft.world.chunk.Chunk;

 

import org.lwjgl.opengl.GL11;

 

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

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

 

public class HaloRender extends Gui

{

 

 

private static final ResourceLocation one = new ResourceLocation("halohud", "textures/health/1.png");

    private static final ResourceLocation two = new ResourceLocation("halohud", "textures/health/2.png");

    private static final ResourceLocation three = new ResourceLocation("halohud", "textures//health/3.png");

    private static final ResourceLocation four = new ResourceLocation("halohud", "textures/health/4.png");

    private static final ResourceLocation five = new ResourceLocation("halohud", "textures/health/5.png");

    private static final ResourceLocation six = new ResourceLocation("halohud", "textures/health/6.png");

    private static final ResourceLocation seven = new ResourceLocation("halohud", "textures/health/7.png");

    private static final ResourceLocation eight = new ResourceLocation("halohud", "textures/health/8.png");

    private static final ResourceLocation nine = new ResourceLocation("halohud", "textures/health/9.png");

    private static final ResourceLocation ten = new ResourceLocation("halohud", "textures/health/10.png");

    private static final ResourceLocation eleven = new ResourceLocation("halohud", "textures/health/11.png");

    private static final ResourceLocation twelve = new ResourceLocation("halohud", "textures/health/12.png");

    private static final ResourceLocation thirteen = new ResourceLocation("halohud", "textures/health/13.png");

    private static final ResourceLocation fourteen = new ResourceLocation("halohud", "textures/health/14.png");

    private static final ResourceLocation fifthteen = new ResourceLocation("halohud", "textures/health/15.png");

    private static final ResourceLocation sixteen = new ResourceLocation("halohud", "textures/health/16.png");

    private static final ResourceLocation seventeen = new ResourceLocation("halohud", "textures/health/17.png");

    private static final ResourceLocation eighteen = new ResourceLocation("halohud", "textures/health/18.png");

    private static final ResourceLocation nineteen = new ResourceLocation("halohud", "textures/health/19.png");

    private static final ResourceLocation twenty = new ResourceLocation("halohud", "textures/health/20.png");

    private static final ResourceLocation full = new ResourceLocation("halohud", "textures/hunger/full.png");

    private static final ResourceLocation medium = new ResourceLocation("halohud", "textures/hunger/medium.png");   

    private static final ResourceLocation low = new ResourceLocation("halohud", "textures/hunger/low.png");

    private static final ResourceLocation hud = new ResourceLocation("halohud", "textures/haloblur.png");

   

   

private static Minecraft mc;

private float health;

private float hunger;

@SubscribeEvent(priority=EventPriority.NORMAL)

public void HaloRenderController()

{

mc = Minecraft.getMinecraft();

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

int var6 = var5.getScaledWidth();

int var7 = var5.getScaledHeight();

health = this.mc.thePlayer.getHealth();

hunger = this.mc.thePlayer.getFoodStats().getFoodLevel();

 

RenderHaloBlur(var6,  var7);

 

 

 

if((int)health == 1)

{

this.health(var6, var7, one);

}

 

if((int)health == 2)

{

this.health(var6, var7, two);

}

if((int)health == 3)

{

this.health(var6, var7, three);

}

if((int)health == 4)

{

this.health(var6, var7, four);

}

if((int)health == 5)

{

this.health(var6, var7, five);

}

if((int)health == 6)

{

this.health(var6, var7, six);

}

if((int)health == 7)

{

this.health(var6, var7, seven);

}

if((int)health == 8)

{

this.health(var6, var7, eight);

}

if((int)health == 9)

{

this.health(var6, var7, nine);

}

if((int)health == 10)

{

this.health(var6, var7, ten);

}

if((int)health == 11)

{

this.health(var6, var7, eleven);

}

if((int)health == 12)

{

this.health(var6, var7, twelve);

}

if((int)health == 13)

{

this.health(var6, var7, thirteen);

}

if((int)health == 14)

{

this.health(var6, var7, fourteen);

}

if((int)health == 15)

{

this.health(var6, var7, fifthteen);

}

if((int)health == 16)

{

this.health(var6, var7, sixteen);

}

if((int)health == 17)

{

this.health(var6, var7, seventeen);

}

if((int)health == 18)

{

this.health(var6, var7, eighteen);

}

if((int)health == 19)

{

this.health(var6, var7, nineteen);

}

if((int)health == 20)

{

this.health(var6, var7, twenty);

}

 

if((int)hunger > 18)

{

this.hunger(var6, var7, full);

}

if((int)hunger <= 6)

{

this.hunger(var6, var7, low);

}

if((int)hunger < 18 && hunger > 6)

{

this.hunger(var6, var7, medium);

}

 

 

}

    private void health(int par1, int par2, ResourceLocation loc)

    {

        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);

        this.mc.getTextureManager().bindTexture(loc);

        Tessellator var3 = Tessellator.instance;

        var3.startDrawingQuads();

        var3.addVertexWithUV(0.0D, (double)par2, -90.0D, 0.0D, 1.0D);

        var3.addVertexWithUV((double)par1, (double)par2, -90.0D, 1.0D, 1.0D);

        var3.addVertexWithUV((double)par1, 0.0D, -90.0D, 1.0D, 0.0D);

        var3.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);

        var3.draw();

        GL11.glDepthMask(true);

        GL11.glEnable(GL11.GL_DEPTH_TEST);

        GL11.glEnable(GL11.GL_ALPHA_TEST);

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

    }

 

    private void hunger(int par1, int par2, ResourceLocation col)

    {

        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);

        this.mc.getTextureManager().bindTexture(col);

        Tessellator var3 = Tessellator.instance;

        var3.startDrawingQuads();

        var3.addVertexWithUV(0.0D, (double)par2, -90.0D, 0.0D, 1.0D);

        var3.addVertexWithUV((double)par1, (double)par2, -90.0D, 1.0D, 1.0D);

        var3.addVertexWithUV((double)par1, 0.0D, -90.0D, 1.0D, 0.0D);

        var3.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);

        var3.draw();

        GL11.glDepthMask(true);

        GL11.glEnable(GL11.GL_DEPTH_TEST);

        GL11.glEnable(GL11.GL_ALPHA_TEST);

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

       

    }

   

    private void RenderHaloBlur(int par1, int par2)

    {

        GL11.glDisable(GL11.GL_DEPTH_TEST);

        GL11.glDepthMask(false);

        OpenGlHelper.glBlendFunc(770, 771, 1, 0);

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

        GL11.glDisable(GL11.GL_ALPHA_TEST);

        this.mc.renderEngine.bindTexture(hud);

        this.drawTexturedModalRect(0, 0, 256, 256, 256, 256);

        Tessellator var3 = Tessellator.instance;

        var3.startDrawingQuads();

        var3.addVertexWithUV(0.0D, (double)par2, -90.0D, 0.0D, 1.0D);

        var3.addVertexWithUV((double)par1, (double)par2, -90.0D, 1.0D, 1.0D);

        var3.addVertexWithUV((double)par1, 0.0D, -90.0D, 1.0D, 0.0D);

        var3.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);

        var3.draw();

        GL11.glDepthMask(true);

        GL11.glEnable(GL11.GL_DEPTH_TEST);

        GL11.glEnable(GL11.GL_ALPHA_TEST);

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

    }

   

 

}

 

 

 

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

    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
    • Hello fellow Minecrafters! I recently returned to Minecraft and realized I needed a wiki that displays basic information easily and had great user navigation. That’s why I decided to build: MinecraftSearch — a site by a Minecraft fan, for Minecraft fans. Key Features So Far Straight-to-the-Point Info: No extra fluff; just the essentials on items, mobs, recipes, loot and more. Clean & Intuitive Layout: Easy navigation so you spend less time scrolling and more time playing. Optimized Search: Search for anything—items, mobs, blocks—and get results instantly. What I’m Thinking of Adding More data/information: Catch chances for fishing rod, traveling villager trades, biomes info and a lot more. The website is still under development and need a lot more data added. Community Contributions: Potential for user-uploaded tips for items/mobs/blocks in the future. Feature Requests Welcome: Your ideas could shape how the wiki evolves! You can see my roadmap at the About page https://minecraftsearch.com/about I’d love for you to check out MinecraftSearch and see if it helps you find the info you need faster. Feedback is crucial—I want to develop this further based on what the community needs most, so please let me know what you think. Thanks, and happy crafting!
    • Instructions on how to install newer Java can be found in the FAQ
    • That's just plain wrong... newer versions are much better optimised and start a lot faster than 1.8.9, both Forge and Minecraft itself. Comparing Fabric 1.21 with Forge 1.8 is like comparing apples and oranges... one's brand new and the other's over a decade old.
  • Topics

×
×
  • Create New...

Important Information

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