Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Chat Commands - Need Code


XxxXEclipse7XxxX
 Share

Recommended Posts

I am in need of some code so that when a player logs into a world he gets a message saying in the chat bar.

 

If not then i would also like to have the code for when you right click the message pops up!?

 

 

Any suggestions on how i would go by this?

Check Out My Modding Tutorials For Minecraft Forge!

 

http://www.youtube.com/user/XxxXEclipse7XxxX

 

 

Check Out My Forums -

http://www.theaustralianmodder.com

Link to comment
Share on other sites

To send a chat message use

player.sendChatToPlayer

. It takes a

ChatMessageComponent

which is a powerful helper class to do a lot of stuff with chat messages. You can add color, make it bold, etc. etc. Use the static factory methods in the

ChatMessageComponent

class for that, they are pretty self-explanatory.

To get notified when a player logs in you have to make an

IPlayerTracker

and for right-clicking you have to decide whether you want it to happen when the player:

  • right clicks a block =>
    onBlockActivated

    in your block

  • right clicks with an item =>
    onItemRightClick

    in your item

  • right clicks whenever =>
    PlayerInteractEvent

Link to comment
Share on other sites

Is there anyway to create a command?

 

For example /help uses "commands.help.success" which is overriding ChatMessageComponent

 

 

is there anyway i can create a custom command?

Check Out My Modding Tutorials For Minecraft Forge!

 

http://www.youtube.com/user/XxxXEclipse7XxxX

 

 

Check Out My Forums -

http://www.theaustralianmodder.com

Link to comment
Share on other sites

I didn't copy and paste i studied it and saw it was outdated.

 

Your telling me that ChatMessageComponent is used to make it colorful when i want it actually sent to the player!

Check Out My Modding Tutorials For Minecraft Forge!

 

http://www.youtube.com/user/XxxXEclipse7XxxX

 

 

Check Out My Forums -

http://www.theaustralianmodder.com

Link to comment
Share on other sites

Your telling me that ChatMessageComponent is used to make it colorful when i want it actually sent to the player!

I did not say that.
ChatMessageComponent

is a class which wraps around the chat message being sent so you don't have to construct the string yourself (chat messages are sent as JSON since 1.6).

If you just want to send a text, use

ChatMessageComponent.createFromText

.

Link to comment
Share on other sites

Thanks, it worked. :)

 

 

Sorry if i sounded "angry" or "harsh" i was needing this badly!

 

 

Thanks for your help.

 

 

EDIT - if i have any crashes  i will report here.

Check Out My Modding Tutorials For Minecraft Forge!

 

http://www.youtube.com/user/XxxXEclipse7XxxX

 

 

Check Out My Forums -

http://www.theaustralianmodder.com

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.