Jump to content

Recommended Posts

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

Posted

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.

Posted

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.

Posted

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

	}

Posted

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

×   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



×
×
  • Create New...

Important Information

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