Jump to content

[1.7.10] Chat Proximity


Murphboy7

Recommended Posts

I'm starting a very simple mod, however I'm new to the Forge API and have a (hopefully) simple question I need answered, and if suggestions on how to complete it were provided that would be greatly appreciated.

 

The mod I'm intending to make puts a proximity limit on text chat so that you must be within a certain range to hear someone.  It seems to me the simplest solution would be to create a command that does exactly that; checks the distances and then sends the message appropriately.  However I intend for this to be the normal iteration of a chat input (for clarification: in vanilla if you just hit enter and type 'hello' it will broadcast 'hello' to everyone in the server.  I would like it so that 'hello' would only broadcast to the players nearby).  Before I set up the Forge API, I had been digging through the minecraft source code via MCP to figure out exactly how chat was handled, and it may be my lack of knowledge, but it seemed to me that the only way for this chat proximity mod to work is to change some source code.  Am I incorrect and there is a much simpler solution to my mod?  Is anyone willing to give me a pointer on how to tackle this?

 

If my post was vague or you need anymore information, I'll keep checking back and provide more information if it's needed.

Link to comment
Share on other sites

I've just finished setting up the events of ServerChatEvent and ClientReceivedChatEvents successfully (had the events print to console to make sure they work), however now I just don't know where to import a list of all players and their current locations to run a distance check between them and the sender.

Link to comment
Share on other sites

I've just finished setting up the events of ServerChatEvent and ClientReceivedChatEvents successfully (had the events print to console to make sure they work), however now I just don't know where to import a list of all players and their current locations to run a distance check between them and the sender.

 

You can get the player by

event.player

, and the world

event.player.worldObj

. There're methods and fields related to player list in

worldObj

. And there're methods in

Entity

class to calculate distance. Players are also entities.

 

PS: There're lots of changes from MCP to Forge. Reading Forge source codes helps more.

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

Link to comment
Share on other sites

Bukkit is a relict of the past.

Forge is the only future.

Our only salvation.

Those who oppose shall be purged by the holy fire of Blazes' spirits.

All hail Minecraft Forge!

 

 

 

Jokes will be jokes, but seriousy, leave Bukkit behind as soon as you can. It has literally no future (no updates) and will soon die totally.

Also - Forge server mods are just as good as any other mods or plugins (e.g Bukkit), I would even say they are better.

 

 

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

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.