Posted April 9, 201510 yr Sooo i was working on my virus mod and finally got my humanity level to work. Sort of. this happened... 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
April 9, 201510 yr 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.
April 9, 201510 yr Author Im sorry i dont know a hell of a lot about this stuff, so can you just give me a code example of what you mean?
April 9, 201510 yr 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.
April 9, 201510 yr 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)); } }
April 9, 201510 yr 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.
April 9, 201510 yr 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.