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.

×
×
  • Create New...

Important Information

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