I'm looking for a way to have my code generate a chat message that will act as though it was typed and sent by the player.
I already know how to print strings to the chat field, though that doesn't achieve what i'm going for.
I have a ServerChatEvent registered that i would like to trigger automatically from somewhere else by faking a user message to trigger it, though the methods I'm aware of to add chat text don't seem to trigger the event and are logged in the console as [CHAT] "message" when legitimate player chat logs as <player> "message"
Ideally the generated message will never actually be displayed, but instead be cancelled and replaced by the ServerChatEvent
I smell malicious intent, so I'm only going to be vague. Look for the code for death messages, they're "announced" to all players and don't show the [CHAT] prefix.
One thing though, if this is designed for mod-related feedback, using the chat window is a really lazy and annoying way to do it. I don't know what you're trying to do but consider using the "Achievement notification" method instead.
I smell malicious intent, so I'm only going to be vague. Look for the code for death messages, they're "announced" to all players and don't show the [CHAT] prefix.
One thing though, if this is designed for mod-related feedback, using the chat window is a really lazy and annoying way to do it. I don't know what you're trying to do but consider using the "Achievement notification" method instead.
No malicious intent just investigating weather this could be used as a work around for the million problems I'v had trying to work out how to use packets.
The Event I have set up allows me to set NBT values of custom items in hand and nearby custom tile entities (within 32 blocks + or - on x/zaxis and within 6 blocks + or - on yaxis) works as intended with manual input from player. I made this because players couldn't use GUI's i made in multiplayer because of problematic packet code, if i can "spam" a player chat message as if the player themselves had typed out the message and trigger the event I will be able to re-enable the GUI's and it will be a complete work around... no more Packets so no more problems
well considering it took at least 2 hours to add this to my code i don't know that lazy is the right word, but packets do not work with multiplayer so had to come up with something else.
Packets are designed *for* multiplayer. If you don't use the packet system then it's literally impossible to have an SMP-compatible Forge mod (unless your mod is client-side only e.g. a minimap but that's not what you're doing).
Not worrying about packets is fine when you're just starting out, but avoiding them intentionally restricts you to SSP/client-side mods only. If that is your intention, then fair enough - I can't give any more advice. If or when you want your mod to be multiplayer compatible though, consider trying again and opening a new thread if you need help with getting your custom packets to work.
yeah I understand they are meant to work for multiplayer. I have followed a couple tutorials and thought i had everything working until the first time i actually used them in multiplayer... worked just fine for me as the hosting pc on lan network... but any time a packet was sent for any other player they are kicked by server, there is an open thread and have been trying to figure out myself but with no luck...
This was more an experiment to see if I could get it done another way as have already spent more hours than id like to count on this packet code that only works in single player or for the hosting PC
Packets were a bit of a PITA when I first got used to them, so fair enough. But I really do need to stress how important they are - there's no getting around them I'm afraid.
I'm not sure I understand your goal, so I can't say whether you can get away without using packets in this particular case. But you eventually will need to.
Mind linking me to that thread? I can't find it. Maybe I can help. My first packet work was in 1.7.10 and I still have the source on GitHub for it, so it'll be easy for me to share by example.
Packets were a bit of a PITA when I first got used to them, so fair enough. But I really do need to stress how important they are - there's no getting around them I'm afraid.
I'm not sure I understand your goal, so I can't say whether you can get away without using packets in this particular case. But you eventually will need to.
Mind linking me to that thread? I can't find it. Maybe I can help. My first packet work was in 1.7.10 and I still have the source on GitHub for it, so it'll be easy for me to share by example.
Sorry for slow reply fell asleep haha.
Yeah you can say that again, certainly are a little hard to get your head around, I agree it would be preferable to have the intended packets working properly.
My goal for this thread (even if I get packets working it's still a point of interest) was to see if you could send a message as if it had been typed by a player triggered by the player in another way like clicking a button/ standing or clicking a block ect. and have it be treated exactly the same as a normal message typed and sent by that player.
Here is a link to the open thread about packet issues. It's titled about and shows examples of a particular item but the issue relates to all cases where a custom packet is triggered by a player other then the one who started off in single player (host in multiplayer).
Any Help you could provide would be greatly appreciated.
I'm looking for a way to have my code generate a chat message that will act as though it was typed and sent by the player.
I already know how to print strings to the chat field, though that doesn't achieve what i'm going for.
I have a ServerChatEvent registered that i would like to trigger automatically from somewhere else by faking a user message to trigger it, though the methods I'm aware of to add chat text don't seem to trigger the event and are logged in the console as [CHAT] "message" when legitimate player chat logs as <player> "message"
Ideally the generated message will never actually be displayed, but instead be cancelled and replaced by the ServerChatEvent
Thanks for any advise you guys can provide
I smell malicious intent, so I'm only going to be vague. Look for the code for death messages, they're "announced" to all players and don't show the [CHAT] prefix.
One thing though, if this is designed for mod-related feedback, using the chat window is a really lazy and annoying way to do it. I don't know what you're trying to do but consider using the "Achievement notification" method instead.
No malicious intent just investigating weather this could be used as a work around for the million problems I'v had trying to work out how to use packets.
The Event I have set up allows me to set NBT values of custom items in hand and nearby custom tile entities (within 32 blocks + or - on x/zaxis and within 6 blocks + or - on yaxis) works as intended with manual input from player. I made this because players couldn't use GUI's i made in multiplayer because of problematic packet code, if i can "spam" a player chat message as if the player themselves had typed out the message and trigger the event I will be able to re-enable the GUI's and it will be a complete work around... no more Packets so no more problems
So not malicious, just lazy coding? Fair enough lol.... Good luck not using packets though.
well considering it took at least 2 hours to add this to my code i don't know that lazy is the right word, but packets do not work with multiplayer so had to come up with something else.
Packets are designed *for* multiplayer. If you don't use the packet system then it's literally impossible to have an SMP-compatible Forge mod (unless your mod is client-side only e.g. a minimap but that's not what you're doing).
Not worrying about packets is fine when you're just starting out, but avoiding them intentionally restricts you to SSP/client-side mods only. If that is your intention, then fair enough - I can't give any more advice. If or when you want your mod to be multiplayer compatible though, consider trying again and opening a new thread if you need help with getting your custom packets to work.
yeah I understand they are meant to work for multiplayer. I have followed a couple tutorials and thought i had everything working until the first time i actually used them in multiplayer... worked just fine for me as the hosting pc on lan network... but any time a packet was sent for any other player they are kicked by server, there is an open thread and have been trying to figure out myself but with no luck...
This was more an experiment to see if I could get it done another way as have already spent more hours than id like to count on this packet code that only works in single player or for the hosting PC
Packets were a bit of a PITA when I first got used to them, so fair enough. But I really do need to stress how important they are - there's no getting around them I'm afraid.
I'm not sure I understand your goal, so I can't say whether you can get away without using packets in this particular case. But you eventually will need to.
Mind linking me to that thread? I can't find it. Maybe I can help. My first packet work was in 1.7.10 and I still have the source on GitHub for it, so it'll be easy for me to share by example.
Sorry for slow reply fell asleep haha.
Yeah you can say that again, certainly are a little hard to get your head around, I agree it would be preferable to have the intended packets working properly.
My goal for this thread (even if I get packets working it's still a point of interest) was to see if you could send a message as if it had been typed by a player triggered by the player in another way like clicking a button/ standing or clicking a block ect. and have it be treated exactly the same as a normal message typed and sent by that player.
Here is a link to the open thread about packet issues. It's titled about and shows examples of a particular item but the issue relates to all cases where a custom packet is triggered by a player other then the one who started off in single player (host in multiplayer).
Any Help you could provide would be greatly appreciated.
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2431049-player-kicked-by-clicking-button-in-item-gui
Ok, I replied.
As for text, this is from CombatTracker:
And this is the text from the language file:
As I said, death messages are "announced" to all players, and you can manually add the brackets around display name if you wish.
I think the important thing is to run that code on the server side, not client.