# What is a good balance between client and server actions?

I'm working on a voxel-based game right now which will have a lot of events, like clicking a block or object.

Say I want to open an interface when I click a certain block. Should I handle this on the client, or send a packet to the server with the action and it's details such as what the ID of the block is, its position et cetera, and then send a packet back to the client with the action OpenInterface with the interface ID?

It's quite common for the server to handle bits like sending messages to open an interface. There may be extensive scripts or other logic you want to run when clicking a block or interacting with inventory, for example, which you don't want to have to stream to clients (maybe the script has a secret or something you don't even want them to see). You can also make the argument that you don't want clients being asked to run arbitrary code unless you have a very tightly sandboxed script engine.

The actual GUI code itself needs to be on the client, of course, but you can definitely make all interaction require the server.

It's also of course common to just have the client handle it. It's definitely easier in some cases, especially if you want to make the game feel smooth.

Which way is right is 100% dependent on your game and what features you need. If in doubt, just go with whichever seems easier to you.

GUI/interface related stuff should be taken care of client-side, the server doesn't need to know if you're opening a dialog screen.

Send the server information that changes the game state: if your menu screen has a "delete voxel button", send a packet telling the server user X is trying to delete voxel Y, not user X has pressed "delete voxel button".

In your example, clicking on a certain block could ask the server for information about the block (block type, position, etc...), then when that information is received, the client opens the interface, and if the player does something that changes the "game state" through the interface (for example, changing the block type, position, color, etc...) you send that action to the server, not the GUI-related action.