MineSpecsLoading world…
All articles
BeginnerAug 23, 2026 8 min read

Minecraft Commands Every Player Should Know

keepInventory, time set, tp, locate and give with exact Java 1.21 syntax, plus how to switch cheats on in a world that started without them.


The single most valuable command in the game is /gamerule keepInventory true, and most players only discover it the night after they drop a full netherite kit into lava. Here is the short list that actually changes how you play, with exact Java 1.21 syntax and the two things everyone gets wrong about switching cheats on.

Cheats have to be on first

Without cheats the chat box answers almost everything with a red "Unknown or incomplete command" error, because the commands below are not registered for you at all. A few harmless ones survive: /help, /me, /msg and — in a singleplayer world — /seed. Everything else needs permission. In singleplayer that comes from the Allow Cheats toggle on the world creation screen. On a server it comes from operator status, granted with /op yourname from the console.

If your world already exists and cheats are off, you are not stuck:

  1. 1.Load the world and press Escape.
  2. 2.Click Open to LAN.
  3. 3.Set Allow Cheats to ON.
  4. 4.Click Start LAN World.

You now have full command access for the rest of that session. Nothing is damaged and nobody needs to be on your network.

The catch — the part people miss — is that the cheat permission itself is not saved. Quit to the title screen and it is gone. Gamerules, however, are saved. They live in the world's level.dat and are written out with the world, so one LAN session is enough to turn keepInventory on permanently. Set your rules, quit, reload, and they are still active with cheats back off.

TipOpen to LAN is session-only. The gamerules you set during that session are permanent. Use it once, change everything you want, and you may never need it again.

Commands do not disable advancements in Java

This is a Bedrock rule that Java players inherit as a rumour. On Bedrock, enabling cheats locks achievements for that world forever. Java has no equivalent penalty: advancements keep unlocking no matter how many commands you have run, statistics keep counting, and there is no hidden flag marking the world as tainted. More Java and Bedrock differences.

The gamerules worth setting on day one

The syntax is /gamerule rulename value. Rule names are case-sensitive — keepInventory works, keepinventory does not. Typing /gamerule keepInventory with no value prints the current setting instead of changing it.

One version caveat before the list. These are the 1.21 names, and they are what 1.21 through 1.21.10 expects. In 1.21.11 Mojang moved every game rule into a registry and renamed them to lowercase with underscores: keepInventory became keep_inventory, doDaylightCycle became advance_time, doWeatherCycle became advance_weather, doInsomnia became spawn_phantoms, mobGriefing became mob_griefing. If a name below is rejected, you are on a newer build — press Tab after /gamerule and the game lists the names it actually accepts.

  • /gamerule keepInventory true — you keep both your items and your experience levels on death. Default is false.
  • /gamerule doDaylightCycle false — freezes the sun where it currently sits. Set the time you want first, then freeze it.
  • /gamerule doWeatherCycle false — locks the weather as it is. Clear the sky first, or you have just made it rain forever.
  • /gamerule doFireTick false — fire still burns and hurts, it just stops spreading to neighbouring wood. This one did not survive the rename: 1.21.11 removed doFireTick entirely and replaced it with fire_spread_radius_around_player, where a value of 0 stops fire spreading.
  • /gamerule doInsomnia false — no more phantoms, ever.
  • /gamerule doImmediateRespawn true — skips the death screen entirely.
  • /gamerule playersSleepingPercentage 0 — one player in a bed skips the night for everybody. Default is 100. Set it above 100 and sleeping cannot skip the night at all.
  • /gamerule mobGriefing false — creepers stop cratering your walls, endermen stop stealing blocks, ghast fireballs stop punching holes.

That last one costs more than people expect. mobGriefing also governs villagers harvesting crops and picking up items, so with it off a farmer never picks wheat, never shares bread, and your breeder quietly stops working. If you rely on villagers, leave it alone and creeper-proof with lighting instead.

/gamerule randomTickSpeed 3 is the default. Raising it grows crops and spreads grass far faster, which helps when testing a farm, but it multiplies the work every loaded chunk does each tick — much above 100 and your frame rate suffers.

Controlling the clock

  • /time set day — tick 1000, early morning
  • /time set noon — tick 6000
  • /time set night — tick 13000
  • /time set midnight — tick 18000

A full Minecraft day is 24000 ticks, which is 20 real-world minutes, so 1000 ticks is roughly 50 seconds. Raw numbers work too: /time set 23000 puts you just before sunrise, and /time add 1000 nudges the clock forwards without jumping. /time query daytime reports where you are in the current day.

The common mistake is using /time set day to get rid of phantoms. It does not work. Phantoms are not tied to world time — they spawn from a per-player counter tracking time since you last rested, and it only resets when you sleep in a bed or die. Skipping to morning leaves it ticking, so they return the next night regardless. Sleep, or use /gamerule doInsomnia false.

Freezing the day at noon does not stop mobs spawning either. Hostile spawning is driven by block light level, so caves, unlit interiors and any dark corner keep producing mobs under a permanently bright sky.

Weather

/weather clear, /weather rain and /weather thunder do exactly what they say. Left bare they roll a random duration, so add one if you want it to stick.

Here is where old tutorials mislead you: the duration used to be in seconds, but since 1.19.4 it is in game ticks. Twenty ticks make a second and 24000 make a full Minecraft day, so /weather clear 24000 is one in-game day of blue sky — twenty real minutes. You can attach a unit instead of counting: s for seconds, d for in-game days. /weather clear 14d is fourteen Minecraft days, a little under five real hours. A bare number copied from a pre-1.19.4 guide will give you a fraction of what it promises.

Rain matters more than it looks: during a thunderstorm the sky light drops far enough that hostile mobs spawn on the surface in the middle of the afternoon, which is why an ordinary building session suddenly turns into a fight.

Switching game mode

/gamemode creative, /gamemode survival, /gamemode adventure, /gamemode spectator. Java wants the full word — the old numeric shortcuts were removed in 1.13, so /gamemode 1 simply errors.

Two keys save typing once cheats are on. F3+N toggles between spectator and whatever mode you were in — the fastest way to scout a cave system. F3+F4 opens a small game mode picker: hold F3, tap F4 to cycle, release.

Adventure mode is the one nobody uses and probably should: you cannot break or place blocks unless an item explicitly permits it, but you can still fight, open doors and use chests. Ideal for showing a friend round your base without a stray left-click taking out a wall.

Teleporting

/tp 100 70 -250 sends you to those coordinates. /tp Steve sends you to a player. /tp Steve Alex sends Steve to Alex. /tp is an alias of /teleport and both work identically.

A tilde means "relative to where I am": /tp ~ ~100 ~ lifts you 100 blocks straight up and leaves X and Z alone. A caret means "relative to where I am looking": /tp ^ ^ ^10 moves you 10 blocks in your facing direction.

The mistake here hurts: there is no safe-landing logic — teleport into solid stone and you suffocate, kit and all. When jumping to coordinates you scribbled down weeks ago, aim high (a Y of 200 clears nearly all terrain), or switch to spectator first and look at where you are about to land. If you are converting overworld coordinates for a portal, apply the 1:8 ratio before you teleport, not after — see nether coordinates.

Giving yourself items

/give @s minecraft:diamond 64. The @s target means yourself, and the minecraft: namespace is optional in chat but harmless to type. Counts larger than a stack spill into extra stacks, and anything that will not fit drops at your feet.

Extra item data is where old tutorials break. Since 1.20.5 that data uses square-bracket item components instead of the old curly-brace NBT, so an enchanted-sword command copied from a 2019 video errors immediately. The exact component spelling was tightened again partway through the 1.21 series, so rather than trusting any fixed example, type the item name followed by an opening square bracket and let autocomplete list the components your build accepts — that list comes from your running version, so it cannot be out of date. To decide what belongs on the sword first, the enchantment calculator beats guessing.

Finding things

Since 1.19, locate is three separate commands:

  • /locate structure minecraft:ancient_city
  • /locate biome minecraft:mushroom_fields
  • /locate poi for points of interest such as villager workstations and beds

Villages are a trap worth knowing. There is no single village structure — plains, desert, savanna, snowy and taiga villages are five separate entries — so /locate structure #minecraft:village with a hash in front finds the nearest of any type. The hash prefix means "anything in this group".

The output gives X and Z with Y shown as a tilde, because most structures span too many heights to name one. The coordinates in chat are clickable, but clicking does not fire the teleport — it drops a ready-made /tp @s command into your chat box with the coordinates filled in, and you press Enter to go. If you get a "could not find a structure of that type nearby" message, the search radius genuinely ran out; travel a few thousand blocks and try again.

Strongholds are the classic use, although Eyes of Ender are still cheaper if you have blaze powder to spare. Both methods compared.

Seed and difficulty

/seed prints your world seed into chat, and it is the odd one out here: in singleplayer it needs no cheats at all, so it works in a plain vanilla world with the toggle off. Paste it into the seed explorer to see what your world contains without walking a single block. On a multiplayer server it is operator-only by default, because the seed reveals where every structure and slime chunk sits.

/difficulty on its own reports the current setting; /difficulty hard changes it. The values are peaceful, easy, normal and hard. Peaceful is not merely "fewer mobs" — it despawns every hostile already loaded, regenerates your health continuously and stops the hunger bar from depleting at all, which makes it a decent panic button. Hard is the only difficulty where a zombie that kills a villager always leaves a curable zombie villager behind — it is a coin flip on normal and never happens on easy. Full breakdown of all four.

Targets, and the command that wipes your base

Selectors are the second half of most commands. @s is you, @p the nearest player, @a all players, @r a random player, @e every entity in the world.

That last one is the trap. /kill @e does not mean "kill the mobs". It means every entity: you, your item frames, your paintings, your armour stands, your minecarts, your boats and every animal you have ever bred. Filter it:

  • /kill @e[type=item] clears dropped items and nothing else
  • /kill @e[type=!player] spares players but still destroys your decoration
  • /kill @e[type=zombie,distance=..30] kills zombies within 30 blocks

Filters go inside square brackets, separated by commas, and an exclamation mark negates. Distance uses range notation, so ..30 means "up to 30 blocks" and 10.. means "10 blocks or more".

Let the game type them for you

Press T to open chat, or the slash key to open it with the slash already typed. Then use Tab constantly: it cycles through the valid completions at your cursor and is the fastest way to learn what any command accepts. The up arrow recalls commands you have already run.

Java also shows a live error in red beneath the chat box as you type, pointing at where the parser lost the thread. If it reads "Incorrect argument", the word just before your cursor is the problem. Nothing runs until you press Enter, so exploring with Tab costs nothing.

#commands#cheats#gamerules