water/thirst bar

22 views
Skip to first unread message

Gus

unread,
Nov 26, 2012, 5:36:41 AM11/26/12
to dune...@googlegroups.com
Did some playing around in mcp with modloader and found a way of making a water/thirst bar, without modifying core files and thought I would share it here. Have attached the sprites used for the thirst bar.

GUIThirst.java
This class draws the thirst bar to the screen.

package net.minecraft.src;
 
import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;

public class GUIThirst extends Gui{

public GUIThirst(){
}
    public void Draw(Minecraft mc, int width, int height, int thirst)
    {
        int var4 = mc.renderEngine.getTexture("/gui/thirst.png");
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        mc.renderEngine.bindTexture(var4);
        int var5 = (width - 16) / 2 - 92;
        int var6 = (height - 16) / 2 + 64;

        float tmp = thirst - 1;
        for (int i = 0; i < 10; i++)
        {
            if ((int)(tmp / 2) >= i)
            {
                if (tmp / 2 - (int)(tmp / 2) != 0.5 && (int)(tmp / 2) == i)
                {
                    this.drawTexturedModalRect(var5 + (10 - i)* 9, var6, 9, 0, 9, 13);
                } else
                    this.drawTexturedModalRect(var5 + (10 - i) * 9, var6, 0, 0, 9, 13);
            } else
            this.drawTexturedModalRect(var5 + (10 - i) * 9, var6, 18, 0, 9, 13);
        }
       

        this.drawCenteredString(mc.fontRenderer, "DuneCraft Thirst ver 0.0.1",
                mc.fontRenderer.getStringWidth("DuneCraft Thirst ver 0.0.1") / 2, 0, 0xffffff);
    }

}

mod_Dune.java
This is were the mod is loaded, were you would work out how much water/thirst you have and were the gui is draw.
 
package net.minecraft.src;

import java.util.Map;
import java.util.Random;

import net.minecraft.client.Minecraft;
           
public class mod_Dune extends BaseMod
{           
    GUIThirst thirstGui = new GUIThirst();
   
    float thirst = 20;
   
    public void load()   
    {
        ModLoader.setInGUIHook(this, true, false);
        ModLoader.setInGameHook(this, true, false);
    }
   
    public boolean onTickInGui(float f, Minecraft minecraft)
    {
        return true;
    }
   
    public boolean onTickInGame(float f, Minecraft minecraft)
    {  
        if (!minecraft.thePlayer.capabilities.isCreativeMode && minecraft.isGuiEnabled() && !minecraft.isGamePaused)
        {
            ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
            int width = sr.getScaledWidth();
            int height = sr.getScaledHeight();
           
            thirstGui.Draw(minecraft, width, height, (int)thirst);
        }
        return true;
    }
   
    public String getVersion()
    {           
        return "1.4.2";
    }
   
}



thirst.png

Ordus Skrita

unread,
Nov 27, 2012, 10:36:19 PM11/27/12
to dune...@googlegroups.com
Just a few questions and suggestions, firstly, I personally would prefer water drops instead of bottles, (just personal preference).  Now, when wearing a stillsuit, the water should go down at about 1/3 of the rate that the hunger bar does, but when you are hit and in a stillsuit there is a 50% chance that the rate at which you lose water will triple (to simulate getting a leak)  Without the stillsuit, you thirst bar should run out in a bout 5 minutes.

Nate

unread,
Jan 8, 2013, 1:02:55 AM1/8/13
to dune...@googlegroups.com
Also a suggestion, perhaps the water should go above the hunger bar. Instead of the armour bar.

Augustus Pash

unread,
Jan 8, 2013, 7:53:39 AM1/8/13
to dune...@googlegroups.com
Thanks for the input.


On 8 January 2013 17:02, Nate <eachsold...@hotmail.co.nz> wrote:
Also a suggestion, perhaps the water should go above the hunger bar. Instead of the armour bar.

--
 
 
 

Reply all
Reply to author
Forward
0 new messages