Questions tagged [minecraft-commands]

Anything related to the usage of commands, command blocks and functions in the Minecraft game series. If you're building a redstone device without commands, use the "minecraft-redstone" tag instead. Always use this tag together with the "minecraft-java-edition" or "minecraft-bedrock-edition" tag.

Filter by
Sorted by
Tagged with
13
votes
4answers
23k views

How do you add NBT tags to commands in Minecraft Pocket/Bedrock Edition?

How do you add NBT tags to commands? I’ve tried commands that normally work in Java Edition like: give @s minecraft:planks 30 1 {display:{Lore:["Wooden planks"]}} give @s potion 1 0 {Potion:"...
19
votes
2answers
4k views

How can I fix “unbalanced brackets” in my data tag?

Often, when making a command block contraption, you need to set an entity's data tag. These tags can sometimes be very long, with many layers of nested curly and square brackets. For example, this is ...
6
votes
2answers
362 views

Why am I getting an 'unexpected token' error with this command?

I need help with a specific command that I am using in a new game that I am creating inside of Minecraft. The command is: /give @p sign 1 0 {BlockEntityTag:{Text1:"{"text":" [MF2]","color":"gold","...
5
votes
1answer
458 views

Command for spawning chest with a CanPlaceOn tag

I am making a Minecraft Mini Game adventure map, and one of the levels has a /setblock command, I am using the command in a way to spawn an item in a chest (Wooden Button) I need the wooden button to ...
10
votes
4answers
11k views

Is there a way to set an “Adventure Mode Boundary” in Minecraft?

Is there a way to set an "Adventure Mode Boundary" in Minecraft? I am trying to create this village where players can spawn in, and then set out to explore the world and build and do normal minecraft ...
6
votes
1answer
1k views

How to delay or slowly loop commands?

I found 11 questions like this on gamingSE already, but none of them have proper and up-to-date answers. So I'm creating this Q&A: How do you either activate a command x seconds/minutes/hours/… ...
5
votes
3answers
85k views

How to test for an hold item name in Minecraft?

I'm trying to make a command block that spawns an item in front of you if you are holding an item with a specific name. I've got these two working scripts; /testfor @p[r=10] {Inventory:[{tag:{display:...
16
votes
8answers
29k views

How do I select all but two types of entities in Minecraft with the type selector?

I've asked this question towards a developer for Minecraft and I thought I'd ask here too since they might not see the question. How do I select all but two types of entities in Minecraft? For ...
15
votes
3answers
78k views

How can I make a block only be placed on certain other blocks

I want people to only be able to place TNT on only Quartz Blocks and I've see this done before where you can only place blocks on certain other blocks but I'm not sure of the command used to do that. ...
4
votes
3answers
4k views

How can I apply an effect when a player left-clicks/right-clicks with an item in hand?

Is there a way so that I make make it when I left click/right click with a certain item it applies an effect? I know that you can apply attributes to wearing armor and things but I want it so when you ...
8
votes
6answers
41k views

How can I make a random number generator with command blocks in Minecraft?

I want to make a mini game in Minecraft were I need a random command generator for 9 commands. I need a random command to give the player a random item. I can't do the command block in the dispenser ...
25
votes
3answers
5k views

How do I fix 'Invalid JSON' errors?

I've been at this for almost two hours and no one seems to have the same problem as I and I doubt this will be solved but I'll try anyway. this is the code /tellraw @p ["Would you like to teleport?",...
3
votes
3answers
26k views

Can you use /testfor to detect the death of a player?

Can you use the /testfor command in minecraft 1.8 to find out if a player has died ? I need it for my map, where 2 players (Only) are pitted against eachother. I want it so that when one of them dies,...
0
votes
1answer
363 views

Snowball executing command in 1.15

I am trying to make a snowball that triggers a command when it hits a player in 1.15, but I don't know how to do that. When I do execute at @e[type=snowball] run gamemode spectator @a[distance=..2] it ...
11
votes
7answers
18k views

I've lost a command block, how can I find it?

I've placed a command block making it day all the time. I want to turn it off, but I've lost it. What's the quickest way to find it?
37
votes
1answer
5k views

What are the basics of commands in Minecraft Java Edition?

What are the basics of Minecraft commands? If I were to start from scratch, with no knowledge on the topic, what are some things that I need to know?
16
votes
1answer
12k views

How do I make a setblock or a fill clock?

Often, when asking about command block contraptions, people suggest using a "setblock" or "fill" clock? What are those and how do I make them?
12
votes
1answer
63k views

How to set a command block with a command inside using the setblock command

Does someone know how to set a command block with a command inside using the setblock command? I have created this code /setblock <x> <y> <z> command_block {TileEntityData:{Command:"...
7
votes
1answer
122k views

How do I give players already enchanted Tools/Armour/Weapons

I'm making a map where I want players to be able to choose there kits/classes. The problem I'm having with it though is giving players already enchanted Tools/Armour/Weapons. I'm not sure if you can ...
4
votes
1answer
1k views

How do I give myself an item that can only be placed on a block with a certain damage value?

I'm currently in the process of making a custom map and I want to add blocks that can only be placed on a certain colour clay. This is the command I tried using. /give @p cobblestone 1 0 {CanPlaceOn:...
1
vote
2answers
286 views

How to count entities with commands/check if there are only one or a certain number of entities or players left?

I want to run a command when there are only 10 entities left. I know you can use /execute unless entity to detect when all matching mobs have died, but it doesn't work if you want to run a command ...
1
vote
1answer
483 views

How do I combine the NBT tags from two separate commands? [duplicate]

I have two commands I'd like to combine into one, but I'm not sure how to go about combining them. Is this possible? Here are the commands. They work individually, I just can't seem to get them to ...
26
votes
5answers
233k views

Is it possible in Minecraft to switch over from survival to creative in single player?

This question is regarding the minecraft Beta 1.8 prerelease -- I have a beautiful house in single player survival which I'd like to record while flying. I want to be able to change the game mode of ...
2
votes
1answer
316 views

Why is my command throwing a 'data tag parsing failed' error?

I am trying to lock some boxes in a map of mine, and I used this command: /blockdata 10 4 9 {Lock:Elyiana's Mage Key} At first it worked, but then when I logged back on the next day it gave me this ...
13
votes
3answers
123k views

Syntax to add multiple commands to a single command block

I am looking to try and set multiple commands in a single command block, but so far everything I have tried just returns "Unknown Command". What is the format for writing multiple commands in a ...
8
votes
4answers
13k views

How can I detect if a player has a specific item with a specific datavalue in their inventory?

Let's say I want to track a group of players to see which one of them (if any) have a specific block type in their inventory that's of a specific datavalue; for instance Red Wool (minecraft:wool with ...
7
votes
5answers
52k views

Minecraft 1.13 display:{Name:“”} NBT tag

I am in 1.13 Pre-Release 7 trying to make a one command creation and I need an item with a specific name. The command I use is /give @p diamond_sword{display:{Name:"Sword of Power"}} and it gives my a ...
4
votes
5answers
101k views

How do I test for a player at specific coordinates?

If I do: /testfor @p[x=,y=,z=,r=] It says: The entity UUID is in an invalid format.
2
votes
4answers
13k views

Is it possible to spawn mobs in random places?

I was wondering if it is possible for you to make a command block spawn hostile mobs in random places in a specified area? I need the mobs spawned on different Y coordinates too because you need to ...
4
votes
2answers
2k views

How to use exclamation marks in Minecraft commands?

I know that you can use exclamation marks in Minecraft commands to check for an entity that does not have a specific tag. For example, you can use /kill @e[type=!Player] to kill all entities except ...
1
vote
1answer
533 views

How can I filter items with a certain enchantement?

I am trying to build a custom Adventure Island. At this moment I am trying to limit the allowed items on this island. I'm trying to do this by filtering on a certain enchantment which is not item-...
6
votes
4answers
16k views

Run command whenever someone joins a Minecraft server

Is there any way to run a command automatically when a player joins the server? I need to do this without the use of a Bukkit plugin. I think it's possible with MCP but I want to know how!
4
votes
5answers
3k views

Is it possible to mark or modify a player with a specific item in their inventory

I'm building a CTF map of sorts, using command blocks in vanilla 1.8. I've discovered two commands for detecting if an item is in a players inventory: /clear @a[team=Red] banner 4 0 /testfor @a[team=...
13
votes
2answers
1k views

Why remove redstone dust from my command block contraptions?

Whenever I show my command block contraptions to my friends, they always comment that I should remove the redstone dust from them. They say it causes lag and that redstone can be unpredictable, but I'...
3
votes
1answer
3k views

How to use ^^^ coordinate systems for motion nbt

Since we can use ^ ^ ^ for relative coordinates with 1.13 like /execute as Asaf31214 run summon lightning_bolt ^ ^ ^10 (Summons a lightning at 10 blocks from me to the direction I look. By the way, ...
3
votes
1answer
655 views

How to test for minimum amount of items in inventory and execute a command if true

I am using the AmazingKit plugin on my Minecraft server to make inventory kits for players. In a command block I have the following command: /tellraw @p ["",{"text":"Iron","clickEvent":{"action":"...
2
votes
2answers
5k views

Can't Use /Summon Command

Recently I've been messing around with making a few minigames, and have used a few plugins to help make it easier to create and run them. However, a newer one I'm making requires me to use the /summon ...
2
votes
3answers
6k views

How to set Command Block(s) to test for a particular time and output a message?

I simply want one command block to test for the time of day or night (e.g. time = 18000) and output a message in the chat to everyone if that time returns true. I was trying a simple set-up with two ...
1
vote
1answer
168 views

How can I determine that I am looking at the block I need?

I want to execute a command if I am looking at a specific block. A command should only be executed if it is targeted.
20
votes
5answers
10k views

How do I kill mobs using /kill without them dropping loot?

I have a spawn area I am hoping to make a safe haven, so I have a command block on a clock that kills each hostile mob type. This works to keep the place free of any hostile mobs, however every night ...
8
votes
6answers
65k views

How do I remove a summoned Ender Dragon with no AI?

So I used the command /summon EnderDragon ~ ~ ~ {NoAI:1} so that I would have an Ender Dragon that would just sit there. I then wanted to get rid of it, but doing /killall EnderDragon didn't work, ...
6
votes
1answer
5k views

How to make your player invincible / undetectable by zombies?

Ok, I want my character to either be ignored by zombies or unable to die (invincible). I've tried: Adding a health scoreboard but this is uneditable A repeating command block that gives the player ...
4
votes
1answer
4k views

Mob Arena - Mob vs. Mob

I want to make an arena where mobs will fight each other and a player can bet on one side or the other. For example: There are 2 skeletons in dyed armor; red and blue. Each color representing a team. ...
3
votes
1answer
5k views

Would someone give a thorough explanation of 1.14 Minecraft's /data modify?

Okay, so I've been searching all over the internet for an explanation of data modify ever since I heard Sethbling passively mention it in one of his videos. The only thing I could find on it was the ...
3
votes
3answers
2k views

'Unbalanced Curly Brackets' Error with this command block code, what am I doing wrong? [duplicate]

I am trying to make a chest that is called 'I' that has another chest inside called 'II' that has another chest inside called 'III' that has another chest inside called 'IV' that has another chest ...
2
votes
1answer
149 views

Player variable in JSON [duplicate]

I'm trying to make a minigame where you have different kits. You step on a pressure plate and get all your armor and effects added. That's all working fine. I'm trying to make it so it places a sign ...
1
vote
2answers
11k views

How can I test for a player wearing specific armor?

How can I test for a player that is wearing an iron helmet named "test1" and an iron chestplate named "test2" in Minecraft Version 1.12?
5
votes
1answer
1k views

Use /testfor to make a custom command

Basically, I'm trying to recreate the Faction plugins /f map in my single-player without mods as my PC doesn't run them very well. (I know it sounds strange.) I am trying to use the /testfor to test ...
9
votes
2answers
793 views

(Java Minecraft 1.14.2) How to recursively (or otherwise) determine if a closed 2D arbitrarily sized rectangle of blocks has been placed?

The title is a little complex, so let me explain it more fully. I am writing a datapack where I want to be able to run some commands if there is a rectangle of iron bars placed which is complete. I ...
1
vote
2answers
2k views

How do you make 2 command blocks go off at once?

So I'm making a small adventure horror map, and there's suppose to be a death scene where the player steps on a pressure plate and a vine comes and kills them, but I want the command block to not only ...

1
2 3 4 5
9