Quote from orangejuice137»
I'm trying to detect if a player is standing still or moving. This command below is attempting to add 1 to a scoreboard "timer" when I'm standing still.
/execute as @a[nbt={Motion:[0.0,0.0,0.0]}] run scoreboard players add @s timer 1
As you probably could've guessed, this doesn't work. Even when I'm moving, it will still add 1.
For some odd reason, however, it stops when I'm sprinting and jumping (weird exception).
Can you guys help me out?
One reason the command behaves that way (apart from player motion being messed up as was mentioned) is because when you test for data within a list (values surrounded by square brackets), each element within the list you specify is checked within every element on the target.
For example, if you checked for "List:[1]" and the target had a list of "List:[3,2,1]", it would match because your specified value of "1" is compared with the target's values of "3", "2", and "1", and it matched the last value. Therefore your test of "Motion:[0.0,0.0,0.0]" is the exact same as testing "Motion:[0.0]".
But for whatever reason, the player's X and Z motion will be 0 even when moving normally, so the check for Motion:[0.0] will always find at least 1 element. Sprint-jumping causes the values to actually update, and no motion values are 0 at that point, so the check fails.
As for the objectives, you'd create them like so (prepended with "minecraft.custom:minecraft."):
/scoreboard objectives add jump minecraft.custom:minecraft.jump
1
This item idea does work....You just have to edit the display part.
So what you might do is place down a dropper,
spawn a invisible, invulnerable and marker:1b armor stand with custom weapon(Unbreakable:1b,Damage:#) either on hand or head slot.
Open your json model, edit the display part, or add it if your model doesn't have that.
With something like this
Scale, translation, rotation...
There is also a way to do it by using Optifine, but it hasn't release yet...
1
Need a \(escape) for each " and \ if there is any in command.
Because you want the Command to have a string value of
"execute as @a[nbt={SelectedItem:{id:"minecraft:diamond_pickaxe",tag:{display:{Lore:["asd"]}}}}] run scoreboard players set @p magnes 1"
And since there might be a issue for the game to check the second ", he might think what if you want this
"execute as @a[nbt={SelectedItem:{id:"
or this
"execute as @a[nbt={SelectedItem:{id:"minecraft:diamond_pickaxe"
or these...
"execute as @a[nbt={SelectedItem:{id:"minecraft:diamond_pickaxe",tag:{display:{Lore:["
"execute as @a[nbt={SelectedItem:{id:"minecraft:diamond_pickaxe",tag:{display:{Lore:["asd"
So in order to tell him which " it should end, every " and \ between the first " and last " need an escape.
Next time use this command below to check the format if you are uncertain, it also save you lots of time...
1
distance=..50 or distance=0..50
..50 means in a radius of 50 block
One good thing for 1.13, so you wouldn't have do distance=50, distance_min=0.
1
execute if entity @e...
1
You can enable the gameoutput to see what actually is going wrong in you datapack.
Open your launcher > Settings > Open output when the game starts
Then you can open your world, everything that shows red in the output is what you need to fix ASAP.
This thing is pretty useful, it tells you whether and which mcfunction in your datapack is wrong, which texture or model json is unrecognizable in your resourcepack, and many others...
1
Too lazy to check other two command...
The second one is working fine in 1.13-pre2, so I guess that's a bug in pre4?
1
emmm...a little bit trick here if you want to run in a command block
/execute as @a at @s if entity @s[y=0,dy=30] run say i
1
Wrote a bunch, then the website was refresh...
Seems doable, but it is kind of limit (depend on how many spawn data you want to copy).
First, you need scoreboard minecraft.broken:minecraft.mob_spawner to detemine if the player actually broke the spawner.
Then, you need to create a block tag in your data pack which it contain a list of block that tell which block the ray should pass. (air,sign,wall_sign,lever,torch,#minecraft:water,#minecraft:buttons,etc.)
Now, here is the main part.
#either in a function or command block, where you need player to run repeatedly
execute as @s at @s positioned ~ ~1.62 ~ run function namespace:ray
#ray
execute if entity @s[distance=..6] if block ~ ~ ~ minecraft:mob_spawner run function namespace:getspawnertype
execute if entity @s[distance=..6] if block ~ ~ ~ #namespace:pass positioned ^ ^ ^0.1 run function namespace:ray
#getspawnertype
execute if block ~ ~ ~ minecraft:mob_spawner{SpawnData:{id:"minecraft:pig"}} run tag @s add spawner_pig
execute if block ~ ~ ~ minecraft:mob_spawner{SpawnData:{id:"minecraft:cow"}} run tag @s add spawner_cow
execute if block ~ ~ ~ minecraft:mob_spawner{SpawnData:{id:"minecraft:zombie"}} run tag @s add spawner_zombie
execute if block ~ ~ ~ minecraft:mob_spawner{SpawnData:{id:"minecraft:spider"}} run tag @s add spawner_spider
...
Once the player have a score of 1 in minecraft.broken:minecraft.mob_spawner, give them the correspond spawner, then remove the score and tag.
1
greenrepu=17 when the score is 17
greenrepu=..17 17 or below
greenrepu=17.. 17 or above
greenrepu=0..17 between 0 and 17(inclusive)
See Selecting targets by score