Arqade Asked on July 13, 2021
I’m attempting to make a system in which gives a player Slow Falling "indefinitely" when in a certain area/height (specially, in a specified rectangular are and from Y171 to Y189), then replacing it with the same except of 10 seconds instead when within a certain height lower than that (Y133 to Y171).
To do this, I’ve created a command system that does the following;
effect
. (the reason why I wanted Slow Falling). Then, gives them that tag.effect
tag.effect
tag.Chain 3 is the problematic one. What it should do is the following;
Searches for those without the effect
tag between Y133 and Y171, and adds the tag in
.
execute as @a[tag=!effect,y=133,dy=38] at @s run tag @s add in
Gives those with tag in
Slow Falling for 10 seconds
execute as @a[tag=in] at @s run effect give @s minecraft:slow_falling 10 1
Removes tag in
execute as @a[tag=in] at @s run tag @s remove in
The commands work perfectly fine on their own in chat, sent one-by-one. Attempting to put them in a command chain causes them to do absolutely nothing. I’ve never seen this happen before, and I can’t seem to figure out why.
The problem is with your target selector @a[tag=!effect,y=133,dy=38]
. When you specify dy
without specifying dx
or dz
, they are automatically added and default to 0. This means that the game is testing for a one block wide and long area. So in reality, the game is actually testing for @a[tag=!effect,y=133,dx=0,dy=38,dz=0]
The only reason why your commands work in chat is because when you are typing them in chat, the position that the selector calculates from is set to your location, meaning it creates its detection box starting from your position, so your hitbox will always be touching it, so it always succeeds. When you put it in a command block, the detection box is created from the command block's position, and you won't always be in that area.
To fix this, you can use a predicate to detect entity position, this is not subject to the rule that you must have all three at once.
Correct answer by ExpertCoder14 on July 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP