Jump to content

hooks for renderName


DarkGuardsman

Recommended Posts

In the renderPlayer.class i tend to rewrite the RenderName method to make my mod ComeCloser work. Since forge changes that class i tend to have to rewrite my mod every update to be safe. It would be nice if there were some hooks to mess around with the rendering of player names. For example changing the size of the name tag, The name being displayed, the colors of the name, or for my mod the range at which it renders for other players. i would be grateful if they were added to forge. Especially since i plan to edit the player's name to show his Team in another mod i'm working on. I think a few other mods would take advantage of this if the hooks existed.

 

 

Link to comment
Share on other sites

ty after i posted and finish work on one of my mods i finally got to google how. I'm a little stuck on how to start going about creating a hook. I'm going to do a little research later on it but you think you can start me in the right direction. Maybe with an example or guide of how forge does hooks.

Link to comment
Share on other sites

The ForgeHooks.java file is the primary link for them all, mostly copy how it works.

ty, your doing a good job at not hand holding. I'll just try something and post back here if i need code help.

Mostly due to being busy.  ;)

 

Besides, the ForgeHooks.java file is fascinating.  It is the central communication point for so many of the Forge hooks, good at giving ideas.

Link to comment
Share on other sites

 

Mostly due to being busy.  ;)

i know being busy too well :)

Besides, the ForgeHooks.java file is fascinating.  It is the central communication point for so many of the Forge hooks, good at giving ideas.

I would find them fascinating if i understood java better. Still working out in my head how it goes together.

Link to comment
Share on other sites

Ok i got somethings, don't know what it is but its something  :) . I took how forge did custom item rendering and tried to make my code a custom player name render. It will do a check too see if the mod wants to use the normal name render. If it doesn't it calls to the mod's playerName render. At least that how it should work. Here my code if anyone want to comment on it. I'm still trying to understand how to make hooks, and how to use them.

 

At the bottom of the ForgeHooksClient.class

 public static boolean ShouldRenderNameOther()
    {
        for (IPlayerName handler : playerNameHandlers)
        {
            if (handler.shouldRenderNameOther())
            {
                return true;
            }
        }
        return false;
    }
    static LinkedList<IPlayerName> playerNameHandlers = new LinkedList<IPlayerName>();

    public static void renderPlayerName(IPlayerName customRenderer, EntityPlayer par1EntityPlayer, double par2, double par4, double par6)
    {
        if(customRenderer != null)
        {
            customRenderer.renderNewName(par1EntityPlayer,par2, par4, par6);
        }
         
    }   
    

at the bottom of the MinecraftForgeCleint.class

 private static IPlayerName customPlayerNameRender;
    public static void registerPlayerNameRenderer(IPlayerName renderer)
    {
       customPlayerNameRender = renderer;
    }
    public static IPlayerName getPlayerNameRender() {
    	
	return customPlayerNameRender;
}

My handler class

package net.minecraft.src.forge;
import net.minecraft.src.*;

public interface IPlayerName
{
    /** Called when RenderPlayer goes to render player name.
     * @return true if player's name should be rendered another way
     */
public boolean shouldRenderNameOther();

public void renderNewName(EntityPlayer par1EntityPlayer, double par2, double par4, double par6);
}

changed made to renderPlayer.class

if(ForgeHooksClient.ShouldRenderNameOther())
        	{
           //normal renderName Stuff
        	}
        	else
        	{
        		IPlayerName customRenderer = MinecraftForgeClient.getPlayerNameRender();
        		ForgeHooksClient.renderPlayerName(customRenderer, par1EntityPlayer,par2,par4, par6);
        	}

 

Link to comment
Share on other sites

i was posting the code for people to make suggestions before i finished and make a pull request. Also too see if i missed anything in make this work right.

A pull request submission allow people to make comments on it, comments on individual lines of code, lets people see how it fits into the whole, and lets people submit fixes to the pull request.  :)

Link to comment
Share on other sites

I think that this would work only with one mod using this, lets say that I'd like to use this too there are two things that would happen a) it would override my code b) it would override your code

Ya i noticed that but not sure how too change it much. I think no matter what i change this would always be the case since a player can only have one name tag.do you have any suggestions on how to get it working without conflict?

Link to comment
Share on other sites

In what conditions do you want to change this? Like if I'm in water set font size to 100 and when I get out set it back to normal or you set it once and it should stay like that.

original i was looking for a way to remove conflict with the fact my mod ComeCloser would conflict with anything that effected player render. The mod does the simplest thing and change the range at which name tags render for the player. So say you 10 blocks from me your name would show above your head in game for me. My mod changes this so at 10 blocks i can't see your name tag but at 8 i can. I was also looking to hook into this for other conditions say your in water the range is even less. Or if i use a smoke grenade it reduces to almost zero. Also for another mod i'm working on i want to add a team name before or under the player's name without conflicting with my other mod or another mod.

Link to comment
Share on other sites

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.