Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Sooo i was working on my virus mod and finally got my humanity level to work. Sort of. this happened... Df9LJfh.png Pretty strange, right? Anyway, what i am wondering is how the hell im going to fix it, because I have tried so many things its unreal. Here is my overlay code:

package com.tmg.tmggunsmod;

import java.util.Random;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class EventTMGInfectionDisplay{	
public static class GUIRenderEventClass10
{
    @SubscribeEvent(priority = EventPriority.HIGHEST)
public void eventHandler(RenderGameOverlayEvent event){

	int posX = (event.resolution.getScaledWidth()) /2;
    int posY = (event.resolution.getScaledHeight()) /2;

    EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
	int i = (int)entity.posX;
	int j = (int)entity.posY;
	int k = (int)entity.posZ;
	MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
	World world = server.worldServers[0];

	EventTMGInfectedPlayer props = EventTMGInfectedPlayer.get((EntityPlayer) entity);
	if(props.getCurrentMana() < 50){



		Minecraft.getMinecraft().fontRenderer.drawString(props.getCurrentMana() * 2 + "% Humanity", posX+(-188), posY+(-109), 0xffffff);
            if(props.getCurrentMana() < 10)
            {
    			Minecraft.getMinecraft().fontRenderer.drawString("Low Humanity. Prepare for Infection.", posX+(-188), posY+(-98), 0xff0033);
            }

	}


}
}

//idk, one of my fixing attempts 
public void load(){
MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass10());
}

}

and here is the registry line:

MinecraftForge.EVENT_BUS.register(new GUIRenderEventClass10());

Anyway, if anyboy could edit my code and show me how to fix this, i would be MORE than happy!

 

PS: the extended entity properties are working fine, its the rendering glitch that "bugs" me :D

RenderGameOverlayEvent has phases (or types, i don't remember). If you don't define phase (with if statememnt) your code will be executed about 12 or 13 times: for FOOD, HEALTH, etc.

You need to draw in only one ("ALL" maybe).

 

As to your bug - it might be fontrenderer binding ASCII textures. Picking one phase (ALL) should fix it. If not - you need to rebind texture WIDGETS (or ICONS, whatever, you know what I mean).

1.7.10 is no longer supported by forge, you are on your own.

if (event.type == ElementType.ALL)

 

EDIT

 

Also (just noticed)

PICK PHASE:

RenderGameOverlayEvent.Pre

RenderGameOverlayEvent.Post

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Also, while this topic is up and going i may as well ask why this code doesnt work. It is within a functional, errorless livingUpdateEvent but it is never working properly.

if(event.entity instanceof EntityPlayer)
{

	EntityPlayer player = (EntityPlayer) event.entity;
	EventTMGInfectedPlayer props = EventTMGInfectedPlayer.get((EntityPlayer) event.entity);

	if(props.getCurrentMana() < 1)
	{

			if(!event.entity.worldObj.isRemote)
			{
			((EntityPlayer) event.entity).addPotionEffect(new PotionEffect(Potion.wither.id, 480, 1));
			}

	}

Not really possible, how/where are you registering it, show full code.

1.7.10 is no longer supported by forge, you are on your own.

I think I know:

If the problem is not in event (if you have problem, this MUST work):

@SubscribeEvent
public void onEntityTick(LivingUpdateEvent event)
{
	if (event.entityLiving instanceof EntityPlayer)
	{
		System.out.println("WORKS");

 

Then the problem is in potions. I've never really read the code responsible for updateing potion, but I know that setting time to 1 will get you nowhere.

 

Set Potion tick time to >= 2.

1.7.10 is no longer supported by forge, you are on your own.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.