Jump to content

Recommended Posts

Posted

Hello,

my goal is to make property displayed next to players name so now in vanilla my name would be displayed like : "KakesRevenge".

And for example i want to display another name next to players name like that : "[AnythingGoesHere]KakesRevenge".

My question is how to do it ?

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

You can handle the NameFormat event and directly modify the event string. For example, for any of my friends who log in I usually add a funny title like "the Magnificent". Here is an example method:

 

    @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)

    public void onEvent(NameFormat event)

    {

    // DEBUG

    System.out.println("NameFormat event for username = "+event.username);

        if (event.username.equalsIgnoreCase("jnaejnae"))

        {

            event.displayname = event.username+" the Great and Powerful";

        }       

        else if (event.username.equalsIgnoreCase("MistMaestro"))

        {

            event.displayname = event.username+" the Wise";

        }   

        else if (event.username.equalsIgnoreCase("Taliaailat"))

        {

            event.displayname = event.username+" the Beautiful";

        }   

        else

        {

            event.displayname = event.username+" the Ugly";           

        }

    }

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Oh its that easy thank you thats exactky what i want :)

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

Looks like i have another problem ... so i have the property and if the property is this then do this like so :

 

@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
    public void NamingPlayers(NameFormat event) {
	String property = ProjektWow.player_class.getString();
	if(property == Reference.Warrior) {
		event.displayname = Reference.WarriorName + event.username;
	} else if (property == Reference.Thief) {
		event.displayname = Reference.ThiefName + event.username;
	} else if (property == Reference.Wizard) {
		event.displayname = Reference.WizardName + event.username;          
        }
}

 

the property works fine for another things but in this case it crashes

 

crash log :

 

  Reveal hidden contents

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

Wth is ProjektWow.player_class and why are you accessing it without player reference - it really looks like something either bad or "WIP" to-be-implemented.

 

Error is in some null there.

 

EDIT

To post below:

That is clearly "String property = ProjektWow.player_class.getString();"

There is nothing else that could cause null in that method, unless Reference.Warrior would also point at null object.

  Quote

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

Posted
java.lang.NullPointerException
   at cz.grossik.projektwow.handler.WoWEventHandler.NamingPlayers(WoWEventHandler.java:48) ~[WoWEventHandler.class:?]

There is something

null

on that line. We could help you if you show us that line.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

this is the warrior string in the reference class :

public static String Warrior = "Warrior";

 

EDIT

Basically im writing players player_class in config : (this isnt my code im working on this mod with someone else)

@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
        String name = event.player.getCommandSenderName();
        NBTTagCompound playerData = event.player.getEntityData();
    	
        if (!playerData.hasKey("firstLogin")) {
         ProjektWow.config.load();
         ProjektWow.player_class = ProjektWow.config.get(name, "Class", Reference.nul);
         ProjektWow.player_name = ProjektWow.config.get(name, "Player", name);
         playerData.setBoolean("firstLogin", true); 
    	 ProjektWow.config.save();
        }
}

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

here :

public static Property player_class;

 

cWhole event handler class :

 

  Reveal hidden contents

 

 

Reference class :

 

  Reveal hidden contents

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

that was for something else thats not needed thats doing nothing atm

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted
  On 6/8/2015 at 8:36 PM, KakesRevenge said:

that was for something else thats not needed thats doing nothing atm

Well, why not remove it then? It isn't like it's hard to re-add it...

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

ok i will remove it but thats not the main problem right ?

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

NameFormat event edited :

@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
    public void NamingPlayers(NameFormat event) {
	String property = ProjektWow.player_class.getString();
	if(property.equals(Reference.Warrior)) {
		event.displayname = Reference.WarriorName + event.username;
	} else if (property.equals(Reference.Thief)) {
		event.displayname = Reference.ThiefName + event.username;
	} else if (property.equals(Reference.Wizard)) {
		event.displayname = Reference.WizardName + event.username;          
	}
}

 

ProjektWowClass

 

  Reveal hidden contents

 

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

You have no clue what you are doing, do you?

 

public static Property player_name;
public static Property player_class;

And then happily:

@SubscribeEvent
   public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
...
         ProjektWow.player_class = ProjektWow.config.get(name, "Class", Reference.nul);
         ProjektWow.player_name = ProjektWow.config.get(name, "Player", name);
....
   }

Dude, if this - "Reference.nul" is NULL you can't suddely use it as not-null.

 

Also - your whole mod is (looks) totally bad designed - no per-player saving, nothing.

 

Read about:

IExtendedEntityPeoperties to save data.

Packeting to synchronize data.

  Quote

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

Posted

I knew theres is something bad about that ... and as i said im not working on this mod alone and im not author of the property as well. Tahnk you for that im gonna look on that

 

Edit : this is how the config folder looks like

 

  Reveal hidden contents

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

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.