Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MinecraftForge modding Send a command from the client to the server

Tags:

java

minecraft

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

like image 805
JensV Avatar asked Oct 16 '25 19:10

JensV


2 Answers

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

like image 108
AppleDash Avatar answered Oct 19 '25 10:10

AppleDash


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

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

like image 22
CrushedPixel Avatar answered Oct 19 '25 08:10

CrushedPixel