Jump to content

Recommended Posts

Posted

PlayerLoggedInEvent, though I believe this event is fired only on the server side; if so and you absolutely must have an event that is fired on the client side (i.e. your mod is a client-side only mod), you can use EntityJoinWorldEvent and check for EntityPlayer before sending the message.

So now, what do I do to check if the Entity is a player, and how do I send the message?

 

EDIT: I can't find a tutorial for this exact version and topic on Google, so don't ask me to Google it. Done that already.

Developer of Chlod's Mod! Project Link: http://minecraft.curseforge.com/projects/chlods-mod

Posted

Done outside IDE, cannot guarantee if it will work from copy/paste, but the gist of it should be clear.

 

As this is for a client-side only mod, you could instead likely cast it directly to Minecraft#getMinecraft()#thePlayer() or whatever the structure of that is again.

public void getPlayer(EntityJoinWorldEvent event){
        //Check if the entity is what we are looking for.
        if(event.entity instanceof EntityPlayer){
                //If its a player, cast the entity to EntityPlayer.
                EntityPlayer player = (EntityPlayer) event.entity;
                //Now you use "player" instead of "event.entity"
        }
}

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

EntityPlayer#addChatComponentMessage to write message from client-side to client-chat.

 

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

Posted

I did it! Thanks guys! :D

Here's the results:

@EventHandler
public void getPlayer(EntityJoinWorldEvent event){
	//Credits: Matryoshika, Ernio and coolAlias on the Minecraft Forge Forums
        if(event.entity instanceof EntityPlayer){
                EntityPlayer player = Minecraft.getMinecraft().thePlayer; 
                    player.addChatMessage(new ChatComponentText("text));
        }
}

Developer of Chlod's Mod! Project Link: http://minecraft.curseforge.com/projects/chlods-mod

Posted

This will fire anytime ANY player joins world.

You need:

if (event.entity == Minecraft#thePlayer)

And ONLY that.

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.