Commands/publish
Minecraft Wiki article. Categories: Java_Edition, Upcoming, Java_Edition_upcoming_tag, Java_Edition_upcoming, Commands
📌 Mirrored from Minecraft Wiki
This article is reproduced from Commands/publish on the Minecraft Wiki. Mirrored from revision 3692386. It is licensed CC BY-NC-SA 3.0 by the Minecraft Wiki contributors — not under the Codex’s CC BY-SA 4.0, and it may not be used commercially. Edits belong upstream, not here.
This feature is exclusive to Java Edition.
/publish{
"title": "<code>/publish</code>",
"rows": [
{
"field": "4",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "No dedicated server<br>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Opens singleplayer world to the local network.
Syntax
publish [<allowCommands>] [<gamemode>] [<port>][until: JE 26.3]publish [<allowCommands>] [<port>][upcoming: JE 26.3]
Arguments
<allowCommands>: bool
- Whether commands are allowed when the world is hosted on the local network. Defaults to false.
- Must be a [Boolean]Boolean (either
trueorfalse).
<gamemode>: gamemode[until: JE 26.3]
- 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:
survivalfor Survival modecreativefor Creative modeadventurefor Adventure modespectatorfor 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 [Int]32-bit integer number (from -2147483648 (-231) to 2147483647 (231-1) ). And it must be between 0 and 65535 (inclusive).
Result
| Command | Trigger | Java Edition |
|---|---|---|
| Any | The command is incomplete, or any argument is 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. | |||||
| 26.2 | snap8 | The syntax of /publish has been changed again, and now accepts optional online argument. | |||||
| pre1 | The above change has been reverted. | ||||||
| Upcoming Java Edition | |||||||
| 26.3 | snap6 | The gamemode argument has been removed. | |||||
Navigation
Sources
- Commands/publish — Minecraft Wiki, CC BY-NC-SA 3.0, revision 3692386.