• 1

    posted a message on "interpret":true isn't working when using /tellraw

    The way I understand it, if interpret is set to true and the specified nbt data is a raw JSON string, the game will parse that string and display the value. If it fails to parse the string, nothing is displayed.


    So the reason your command doesn't display anything is that the text you stored is not raw JSON. You can fix this by adding a pair of single quotes around it (you can also use double quotes, but then you would have to "escape" all the double quotes within the text).

    /data modify storage minecraft:new item set value '[{"text":"new-1"}]'
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on can armor stands pick up items??

    It should work for the offhand as well. I used your commands when testing, and both slots worked after I applied the changes.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on can armor stands pick up items??

    HandItems[0].Items is not a tag. You should be testing for either HandItems[0].id or HandItems[0].Count. Run this command near the armor stand (while it's holding an item) to see what I mean:

    /data get entity @e[type=minecraft:armor_stand,limit=1,sort=nearest] HandItems[0]

    Also, your first commands should only be checking if slot 0 is available.


    As for dropping the items, it's the same as picking them up but in reverse.

    /execute at @e[tag=robo4] run summon item ~ ~ ~ {Item:{id:"minecraft:paper",Count:1},Tags:["copy"]}
    
    /execute as @e[tag=robo4] at @s run data modify entity @e[tag=copy,limit=1,sort=nearest] Item set from entity @s HandItems[0]
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on can armor stands pick up items??

    I would use /data to copy the item into the armor stand's hand and then remove the ground item. Armor stands have an NBT tag called HandItems which contains the data of all held items. This is how you can copy an item to its hand:

    /execute as @e[tag=armor_stand] at @s unless data entity @s HandItems[0].Items run data modify entity @s HandItems[0] set from entity @e[type=item,limit=1,sort=nearest] Item
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Making a villager show love hearts

    If all you want to do is display the particles, then you can just use /particle on a scoreboard timer.

    /execute at @e[tag=yourVillager,scores={particleTimer=1..}] run particle minecraft:heart ~ ~ ~ 0.5 0.5 0.5 1 1

    /scoreboard players remove @a[scores={particleTimer=1..}] particleTimer 1
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Can one use chunk coordinates (rather than block coordinates) in command blocks?

    Well, not directly since you first need to calculate the chunk coordinates of the blocks. I did some testing and came up with a system that automagically fills a specific y level of a chunk using an armor stand. The way it works is I store the coordinates of the armor stand (in world coordinates) into scoreboard objectives, calculate the chunk coordinates of the armor stand (X mod 16, Z mod 16) and then teleport the armor stand that many blocks backward to get to 0,0 (in chunk coordinates). I used this wiki article to make this, I definitely recommend checking it out for more info.


    Objectives I used:

    /scoreboard objectives add x dummy
    /scoreboard objectives add z dummy
    /scoreboard objectives add chunkX dummy
    /scoreboard objectives add chunkZ dummy
    /scoreboard objectives add chunkSize dummy

    Global variable I used for calculation later on:

    /scoreboard players set global chunkSize 16

    Command block layout is impulse > chain > chain > ... . Note that the impulse command block must be in the chunk you want to fill.

    Commands I used:

    /summon minecraft:armor_stand ~ ~1 ~ {Tags:["test"]}
    
    # storing armor stand's coordinates into x,y,z objectives
    
    /execute as @e[tag=test] store result score @s x run data get entity @s Pos[0]
    /execute as @e[tag=test] store result score @s z run data get entity @s Pos[2]
    
    # storing a copy of the x,y,z values into chunkX and chunkZ so that I can calculate the chunk coordinates without chaning the original values (need them later on).
    
    /execute as @e[tag=test] run scoreboard players operation @s chunkX = @s x
    /execute as @e[tag=test] run scoreboard players operation @s chunkZ = @s z
    
    # calculating the chunk coordinates of the armor stand using its world coordinates. The chunkSize objective is set to 16 for a fake player called global. The resulting values also represent the distance of the armor stand from 0,0 in the current chunk. That is, we need to move chunkX and chunkZ blocks backwards to reach 0,0.
    
    /execute as @e[tag=test] run scoreboard players operation @s chunkX %= global chunkSize
    /execute as @e[tag=test] run scoreboard players operation @s chunkZ %= global chunkSize
    
    # subtracting the original x,z values (armor stand's world coordinates) from the chunk coordinates. As the result, we get the world coordinates of the chunk's 0,0 block (for some reason it has a half-block offset. That is fixed later on).
    
    /execute as @e[tag=test] run scoreboard players operation @s x -= @s chunkX
    /execute as @e[tag=test] run scoreboard players operation @s z -= @s chunkZ
    
    # teleporting the armor stand to the calculated world coordinates
    
    /execute as @e[tag=test] store result entity @s Pos[0] double 1 run scoreboard players get @s x
    /execute as @e[tag=test] store result entity @s Pos[2] double 1 run scoreboard players get @s z
    
    # applying a half-block offset because for some reason, it teleports to the edge of the block instead of the center.
    
    /execute as @e[tag=test] at @s run tp @s ~0.5 ~ ~0.5
    
    # and finally, run the fill command
    
    /execute at @e[tag=test] run fill ~ ~10 ~ ~15 ~10 ~15 glass
    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Detection players by Command Block

    The execute command is not necessary here. You can apply the effect directly like this:

    /effect give @a[x=0,y=0,z=0,dx=10,dy=10,dz=10] minecraft:speed 1 1 false

    But if you want to use it, this is how you do that:

    /execute as @a[x=0,y=0,z=0,dx=10,dy=10,dz=10] run effect give @s minecraft:speed 1 1 false
    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Alarm with names??

    Here's my idea. When someone enters the room, summon an item (ex. paper) and modify the item's name to match the player's name. Then, collect the item using a hopper and store it into a chest. This would also allow you to check how many times someone entered the room.


    You can get the player's name using a sign and /data:

    /data modify block <sign_x> <sign_y> <sign_z> Text1 set value '{"selector":"@p"}'

    And you can copy it to the item like this:

    /execute as @e[type=minecraft:item,distance=..2] run data modify entity @s Item.tag.display.Name set from block <sign_x> <sign_y> <sign_z> Text1
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Command line to automatically open gates

    The simplest way is to place a repeating (always active) command block near the gate and connect it to the gate using a comparator and some redstone. The command for detecting a player is:


    (1.13+)

    /execute if entity @e[type=player,distance=..5]

    (1.12)

    /testfor @e[type=player,r=5]
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Change everyone's skin at server

    I'm not sure if this is going to work, but try using the execute command:


    (1.13+)

    /execute as @a run skin set @s bedrock_block

    (1.12)

    /execute @a ~ ~ ~ skin set @s bedrock_block

    The plugin you are using has to support selectors though. And you might need to change "skin" to "plugin_name:skin" if you get an error saying the command is undefined.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on execute run doesn't work with plugin commands

    Every plugin has its own namespace in which commands can be registered. This was implemented so that there can be multiple commands with the same name. For example, default Minecraft commands are registered in the minecraft namespace and you can access them like this: "minecraft:setblock". The same goes for plugins so try to access the command using "plugin_name:command" in your /execute command.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on can anyone expain me why this does not work?
    Quote from Hexalobular»

    Hi,

    I think it has to do with the nested citation marks, I found a post on Reddit that says you need to use backslashes to "escape" the nesting.

    Like this

    \\".......\".....\".....\\"

    also, shouldn't the "command:"setblock" have a capital "C"?


    Changing those gave me:



    /data merge block 15061 70 15000 {Command:\"/setblock ~ ~ ~ minecraft:chain_command_block{auto:1,Command:\\"/fill 15059 69 14997 15059 69 15003 air\\"}\"}


    but that gave me another error: "Expected value at position 42: ... Command:<--[HERE]"


    and I don't really know what to do about that.


    The error message says that there should be a value after "Command:". And there is, but the game can't detect it properly because you "escaped" the pair of quotation marks around it. You don't need to do that as they are not within another pair of quotation marks :)


    This should work:

    /data merge block 15061 70 15000 {Command:"/setblock ~ ~ ~ minecraft:chain_command_block{auto:1,Command:\"/fill 15059 69 14997 15059 69 15003 air\"}"}
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Jetpack with execute command

    You should use the @s selector when you want to refer to the player that is executing the command. The way you have it set up now, it picks a random player from the team to check their score. By the way, you also need to specify "limit=1" in the third selector for it to even work, but again, you should use @s instead. Here's an example of how to use it:

    /execute as @e[team=ja,nbt={Inventory:[{Slot:-106b,Count:1b,id:"minecraft:blaze_rod"}]}] if score @s jet = @s requiredJetValue run effect give @s minecraft:levitation 1 6 true

    Notice how I also modified the part where you were checking if the score is equal to 1. That is because you can't compare an objective to a number directly. Instead, you have to create another objective, set it to 1 and then compare the two objectives. In this case, that second objective is "requiredJetValue".


    The command now executes as some player, checks if the score of that player only is equal to the value of requiredJetValue (which is 1) and applies the effect if it is.

    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on How to tp a player if they are near x y z?

    For 1.16.x just replace r=1 with distance=..1

    /tp @a[x=<x>,y=<y>,z=<z>,distance=..1] <x> <y> <z>
    Posted in: Commands, Command Blocks and Functions
  • 0

    posted a message on Detect used item with custom name

    Happy to hear you got it working. I didn't want to bore you with the explanation for the /execute command since it's not necessary. Since you want to know more, I will try to explain how it works.


    So what the /execute command allows you to do is execute a command as someone or at some defined position. This is the command I used to test the system:

    /execute as @a[tag=holdingScroll_1,scores={eatBread=1..}] run say used scroll

    This command iterates through all online players, and for each one, it checks if they match the selector. If a player matches the selector, the command defined after the run keyword is executed as that player. In this case, all players tagged holdingScroll_1 with a score of 1 on the eatBread objective will say "used scroll" in chat.


    You can also specify where you want the command to be executed using the at or positioned keywords.

    /execute at @p run setblock ~ ~ ~ glass  // this means place a glass block at the position of the nearest player
    
    /execute positioned <x> <y> <z> run setblock ~ ~ ~ glass  // this means place a glass block at <x> <y> <z>
    
    /execute as @p at @s run setblock ~ ~ ~ glass  // this means execute the command at the position of the entity that is executing it (nearest player in this case)

    Sometimes you need to execute as something and at the position of that executor. A good example of this is when you want to test if the player is standing on a specific block and increase one of their objectives.

    /execute as @p at @s if block ~ ~-1 ~ diamond_block run scoreboard players add @s standingOnBlock 1

    You can read more about the /execute command on the wiki. The wiki page covers its usage in detail.

    https://minecraft.gamepedia.com/Commands/execute

    Posted in: Commands, Command Blocks and Functions
  • To post a comment, please .