I'm trying to programmatically "un-tame" a cat using the `data set` command. According to an Arqade answer, you just have to remove the `OwnerUUID` property of the animal NBT data. I tried the following commands with no success:
/data modify entity 71cfdc75-9cfa-4989-be66-3f481ed9baa7 OwnerUUID set value ""
/data remove entity 71cfdc75-9cfa-4989-be66-3f481ed9baa7 OwnerUUID
In both cases, the command seems successful, with a message saying the entity was modified. But there was no observable change and the target animal remains associated with the same OwnerUUID.
My own two cents--you can also try setting the Motion attribute of an armor stand to make it move:
/data modify entity@e[tag=creeperStand] Motion set value [1d,0d,0d]
Unfortunately, with this solution you have to specify the Cartesian coordinates of the motion vector, and AFAIK you cannot make it move relative to the player's facing direction.
But in my case, it doesn't matter, since my setblock command sets a redstone block that triggers a fill clock to another system.
🎓
Indeed! At the risk of sounding pedantic , in CS we say such operation is idempotent: "[it] can be applied multiple times without changing the result beyond the initial application"
More seriously, I assume your goal was to trigger other command blocks execution with that redstone block. Could you tell me a little bit more about that or share a screenshot of such design? As I said previously, I'm new to all of this, and I would be curious to see how we can handle control structures or alternate branches of execution with Minecraft commands and command block chains.
[...] I noticed the redstone signal strength did not match my entity count either.
Thank you for having taken the time to test that.
On my side, I noticed I can have an output signal strength matching the entity count if I use "execute as" and if the execute statement actually runs a command:
--ok--
execute as @e[type=villager,distance=..20] run me ""
execute as @e[type=villager,distance=..20] run execute if entity @s
--not ok--
execute if @e[type=villager,distance=..20]
execute as @e[type=villager,distance=..20]
execute as @e[type=villager,distance=..20] run
I suspect the output value is the sum of the output values of the commands: if you run for 5 entities a command returning 1, the result is 1+1+1+1+1 and that is what reflects the output signal strength. It is somewhat confirmed by the contrived command below:
[/p]
[p]execute as @e[type=villager,distance=..20] run execute if entity @s[tag=T][/p]
[p]
Here, the nested `execute` command is run once for each villager in the range. And that nested command will return either 0 or 1 depending if the villager is tagged. In my tests, the result value of the outer `execute` command is the number of tagged villagers.
Is there a limit on the distance an entity can travel (in Y as well as X/Z direction)? Can I limit the lifespan of my fireball so it will auto-destruct after having traveled a given distance and/or time?
Running this from the chat console should bring you to your melon slice:
/execute at @e[type=item,nbt={Item:{id:"minecraft:melon_slice"}}] run tp @s ~ ~ ~
The `execute at` statement changes the current location (`~ ~ ~`) for the command to the location of a melon slice. Then, it runs the `tp` command that will bring you (`@s`) at that location.
Amusingly enough, I was bitten myself by the `as`/`at` clause of the execute command yesterday. And despite that, I didn't pinpoint a similar issue in your command. I definitively need a lot more practice with Minecraft commands!
Actually, in your case, I suspect the following commands would do the trick too:
execute as @a[x=-160,y=75,z=164,distance=..1] run setblock -153 75 165 redstone_block
execute if entity @a[x=-160,y=75,z=164,distance=..1] run setblock -153 75 165 redstone_block
According to my (very recent) knowledge in that matter, I would favor the `if entity` version: I think the `as`/`at` versions may be less efficient, since they may potentially run the `setblock` command several times, once for each matching entity. Or am I wrong?
I still wonder however if we can emulate more complex control flows by spawning blocks or "passing" redstone power to different command chains. Any thought or ideas about that?
For fun I tried a couple of things, and end up with this design:
It works, but it is not very time efficient since branches execution is triggered on the falling edge of the redstone signal activating the "test" command (the `execute if` or `execute unless` command block on the foreground)
/execute has "if" and "unless" subcommands which you can use to achieve this. For example, if you want one branch to activate if there is a villager named "Villager_1" and the other branch to activate if there is a villager named "Villager_2", you would do it like this:
branch #1:
/execute if entity @e[type=villager,name=Villager_1] run <command_to_run_for_branch_1>
branch #2:
/execute if entity @e[type=villager,name=Villager_2] run <command_to_run_for_branch_2>
this will execute the command at the end of the criteria is met. Think of this as separating the "cases"
from the switch statement into separate if statements with the same criteria.
Yes, I saw the `if` and `unless` statements of the `execute` command. What was boring me is to repeat again and again the same condition for every command in each branch. But from your other answers, I'm afraid this is how it has to be done with the Minecraft's command system per se. I still wonder however if we can emulate more complex control flows by spawning blocks or "passing" redstone power to different command chains. Any thought or ideas about that?
0
Indeed it changes the animal custom name, but it's still tamed by the same user. Or did I miss something?
https://minecraft.fandom.com/wiki/Taming
0
Thanks for the reply Megacrafter.
I've made some similar experiments since my initial post, with the same conclusions, unfortunately :/
0
I'm trying to programmatically "un-tame" a cat using the `data set` command. According to an Arqade answer, you just have to remove the `OwnerUUID` property of the animal NBT data. I tried the following commands with no success:
In both cases, the command seems successful, with a message saying the entity was modified. But there was no observable change and the target animal remains associated with the same OwnerUUID.
Any suggestion to untame an animal in MC15.2?
0
My own two cents--you can also try setting the Motion attribute of an armor stand to make it move:
Unfortunately, with this solution you have to specify the Cartesian coordinates of the motion vector, and AFAIK you cannot make it move relative to the player's facing direction.
0
All that sounds really interesting. Thank you for sharing this!
1
🎓
Indeed! At the risk of sounding pedantic , in CS we say such operation is idempotent: "[it] can be applied multiple times without changing the result beyond the initial application"
More seriously, I assume your goal was to trigger other command blocks execution with that redstone block. Could you tell me a little bit more about that or share a screenshot of such design? As I said previously, I'm new to all of this, and I would be curious to see how we can handle control structures or alternate branches of execution with Minecraft commands and command block chains.
0
Thank you for having taken the time to test that.
On my side, I noticed I can have an output signal strength matching the entity count if I use "execute as" and if the execute statement actually runs a command:
I suspect the output value is the sum of the output values of the commands: if you run for 5 entities a command returning 1, the result is 1+1+1+1+1 and that is what reflects the output signal strength. It is somewhat confirmed by the contrived command below:
Here, the nested `execute` command is run once for each villager in the range. And that nested command will return either 0 or 1 depending if the villager is tagged. In my tests, the result value of the outer `execute` command is the number of tagged villagers.
0
... and I suspect you can't detect both water and waterloged blocks in only one command. Or can you?
0
0
I've created a fireball with the following command:
It is currently over 45000 in the Y direction (vertical axis) and still progressing--and way beyond the one minute lifespan before despawn mentionned in the wiki.
Is there a limit on the distance an entity can travel (in Y as well as X/Z direction)? Can I limit the lifespan of my fireball so it will auto-destruct after having traveled a given distance and/or time?
0
Running this from the chat console should bring you to your melon slice:
The `execute at` statement changes the current location (`~ ~ ~`) for the command to the location of a melon slice. Then, it runs the `tp` command that will bring you (`@s`) at that location.
0
Would that work with waterlogged blocks?
1
Thank you for having posted the solution!
Amusingly enough, I was bitten myself by the `as`/`at` clause of the execute command yesterday. And despite that, I didn't pinpoint a similar issue in your command. I definitively need a lot more practice with Minecraft commands!
Actually, in your case, I suspect the following commands would do the trick too:
According to my (very recent) knowledge in that matter, I would favor the `if entity` version: I think the `as`/`at` versions may be less efficient, since they may potentially run the `setblock` command several times, once for each matching entity. Or am I wrong?
0
For fun I tried a couple of things, and end up with this design:
It works, but it is not very time efficient since branches execution is triggered on the falling edge of the redstone signal activating the "test" command (the `execute if` or `execute unless` command block on the foreground)
0
Yes, I saw the `if` and `unless` statements of the `execute` command. What was boring me is to repeat again and again the same condition for every command in each branch. But from your other answers, I'm afraid this is how it has to be done with the Minecraft's command system per se. I still wonder however if we can emulate more complex control flows by spawning blocks or "passing" redstone power to different command chains. Any thought or ideas about that?