I've got this "magic" system in place where if I throw the right thing, it turns into lightning or fire. I'm trying to make an ice-element trap like this:

/execute at @e[type=potion] if entity @p[distance=3..5] positioned as @p run fill ~2 ~2 ~2 ~-2 ~-2 ~-2 ice

It's throwing a splash potion that shatters harmlessly on the ground. Intended effect: I throw it, it gets a few blocks from me, then turns into a 4x4x4 block of ice. It's doing nothing. What am I doing wrong? I'm using repeat command blocks to run that. Ver. 1.14.2

  • Could you provide a bit more information to your question? I'm not sure what your magic system looks like. Or just include a world download, so we can take a better look at it. – Quijibo May 29 at 4:18
  • Your command works for me, it does not work as you seem to intend, but it does work. Please give some more information on your setup and how you are testing. I suggest trying your command in single player creative mode, and fly high up where there are no obstacles. To see if it works. – user232393 Jun 4 at 10:55

Your command works for me, but it does not do what you intend it to do.

Make sure that it is in a repeating command block and that the command block is actually loaded, it may have to be powered by redstone depending on how you set it up. Please give some more details about your problem if this does not help.

Altering the command does make it work the way you explained, as long as you are in a single player world and the potion actually gets far enough.

/execute at @e[type=potion] if entity @p[distance=3..5] run fill ~2 ~2 ~2 ~-2 ~-2 ~-2 ice

It may not always work as intended if you have multiple players in your world at the same time, in that case I would suggest a two commands solution like this:

/execute as @e[type=minecraft:potion,nbt={PortalCooldown:0}] run data modify entity @s PortalCooldown set value <time>
/execute at @e[type=minecraft:potion,nbt={PortalCooldown:1}] run fill ~2 ~2 ~2 ~-2 ~-2 ~-2 minecraft:ice

I set time to 10, it works quite well for me, but you may want it to fly for longer, or shorter

This solution is time based, so it is not affected by how many players are online. I am not sure if it works with lag though. You will not be able to throw the potion into another dimension through a portal, because this command uses the portal cooldown to keep track of time.

Neither of these solutions do anything if the splash potion breaks before the effect takes place (if the potion is not far enough away from you in the first case, or if it breaks too early in the second case)

Note: This part (~2 ~2 ~2 ~-2 ~-2 ~-2) specifies a 5x5x5 volume and not 4x4x4

Note 2: The potions will set everything close to it to ice, so it may potentially break barriers, bedrock, or any decoration that you may have. You can change that by putting replace air after the fill command. Doing this will prevent it from setting grass to ice though and it will not work under water anymore, so it may not always work in those situations.

/execute at @e[type=potion] if entity @p[distance=3..5] run fill ~2 ~2 ~2 ~-2 ~-2 ~-2 ice replace air

Note 3: Throwing the potion directly at your target may break it, before it "explodes", making it uneffective

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.