This feature is exclusive to Java Edition.
Opens singleplayer world to the local network.
Syntax[]
publish [<allowCommands>] [<gamemode>] [<port>]
Arguments[]
<allowCommands>
: bool
- Whether commands will be allowed when the world is hosted on the local network. Defaults to false.
- Must be a boolean (either
true
orfalse
).
<gamemode>
: gamemode
- Sets the default game mode for new player. If not specified, the default game mode for new player is the game mode of this world.
- Must be one of the following:
survival
for Survival modecreative
for Creative modeadventure
for Adventure modespectator
for Spectator mode
<port>
: integer
- The port to host on. If not specified, the port is automatically allocated, typically from an ephemeral port range.
- Must be a 32-bit integer number. And it must be between 0 and 65535 (inclusive).
Result[]
Command | Trigger | Java Edition |
---|---|---|
any | the arguments are not specified correctly | Unparseable |
the world is already published to LAN | Failed | |
the specified port could not be bound (e.g. a reserved port, or already in use by another application). | ||
Otherwise | Successful |
Output[]
Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
---|---|---|---|---|---|
any | Java Edition | On fail | N/A | 0 | 0 |
On success | N/A | 1 | the port allocated for this LAN world. |
History[]
Java Edition | |||||
---|---|---|---|---|---|
1.3.1 | 12w24a | Added /publish . | |||
1.13 | 17w45a | /publish now accepts an optional port argument.
| |||
/publish can now be run from command blocks. | |||||
18w01a | /publish can no longer be run from command blocks. | ||||
1.19.3 | 22w45a | The syntax of /publish has been changed, and now accepts optional command and gamemode arguments. |