JensV
JensV

Reputation: 4544

MinecraftForge modding Send a command from the client to the server

So I wanted to create a GUI for a server to make stuff easier for ppl. I created a Gui with buttons for easy use so you don't have to enter commands all the time. The button works but I didn't find any function that executes a command as the player itself. I googled around but didn't find a solution for this problem.

(btw. this obviously didn't work: player.sendChatToPlayer("/{any command}"); (player is a EntityPlayer))

Regards Jens

Upvotes: 4

Views: 11400

Answers (2)

CrushedPixel
CrushedPixel

Reputation: 1172

In case you want to execute a client-side only command, you can use

ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/your command");

Upvotes: 4

AppleDash
AppleDash

Reputation: 1714

Do a Minecraft.getMinecraft().thePlayer.sendChatMessage("/Command here")

Upvotes: 4

Related Questions