Jump to content

Recommended Posts

Posted

Hi,

 

I currently have a set of commands executed on server side. I made a GUI to allow users an easy access to the features and perform the same actions as commands but the problem is my Gui is on client. So I need a way to execute code on server side when an action is performed on the GUI and to be able to find the player who did it.

 

Is there a way to emulate the use of commands such that i can send these to the server when a player click on the buttons ?

 

I tried addChatMessage but this does not check if it's a command and simply display it in the chat.

I also found a way to send commands like if it was typed in the server terminal using MinecraftServer getters but i think it does not allow to recover which player issued the command.

 

Can somebody help ?

Thanks a lot.

 

Posted

You need to use packets. There are tutorials on how to utilize packets in Forge all over the internet.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Ok, i suppose it's a better way to do it. But i could not find how to insert the player reference in the packets ...

 

As i had already commands allowing to do the action, i found a way to force a client to send a command. Here the code line if someone have the same problem :

 

((EntityClientPlayerMP) entityPlayer).sendChatMessage("/[command]");

 

Unfortunately it's not very OOP but it works.

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.