How can I block people from my Minecraft world?

Solution 1:

I don't believe it's possible to ban players on LAN, but you could instead set up a command block to constantly kill them:

Give yourself a command block and change it to Repeat and Always Active:

Command block killing the player

You can then set the command to /kill <PLAYER>, and it should repeatedly kill them, making them unable to do anything.

If your chat gets spammed with [@: Killed Player] from this, turn off the commandBlockOutput gamerule:

/gamerule commandBlockOutput false

Solution 2:

You could set up a whitelist on the server. It's a bit more work than just banning those who do harm, but it means that you have full control in who's allowed to join your server. Hopefully keeping those griefers at bay.

For this to work you need to have created your LAN world first, and then exit the game. After you've done that, you can check the wiki for the whitelist commands.

In short. To enable the whitelist just write /whitelist on in the chat, and then /whitelist add <username> to allow players to join.

Note that I haven't tried this for a LAN server, but it should be just the same as for a dedicated one.