Minecraft: Force Item Entity to move to specific point, triggering explosion [1.14]

minecraft-commandsminecraft-java-edition

In the map Diversity 3, the player is tasked with putting wool into a chest, after which the wool visibly flies out of the chest, triggering an explosion and a changed block.

I'm attempting to achieve something similar: a gold ingot is spawned, flies towards a blocked cave, which sets off an explosion and opens the cave.

My problem lies in getting the gold ingot to path correctly. Currently, a repeat command block execute if entity @e[type=player,scores={deathmount=2}] run scoreboard players add @a deathmount 1 checks for the players score, and enables the chain if it's high enough.

After this, I've set up a chain that acts as follows:

/summon item -80 90 -66 {NoGravity:1b,Glowing:1b,PickupDelay:199980,Owner:"herobrine",Thrower:"notch",Tags:["triforce"],Item:{id:"minecraft:gold_ingot",Count:1b}}

First, the ingot is spawned,

/tp @e[tag=triforce] ~-.02 ~-0.1 ~-.45 

Second, it attempts to path according to the above,

/summon area_effect_cloud -82 85 -75 {NoGravity:1b,Particle:"explosion",Duration:40,Tags:["explosion"]}

When it reaches its destination, an explosion particle is spawned,

/playsound minecraft:entity.generic.explode ambient @a -82 85 -75 1 1 0.1

The sound is played,

kill @e[tag=triforce]

The ingot is killed,

setblock -82 85 -76 air replace
setblock -82 86 -76 air replace

The two blocks are replaced,

/title @a title {"text":"The way is open! Good luck!"}

And finally a voice tells the player they can enter the relevant dungeon.

What seems to occur is that the path gets cut off prematurely by the explosion. I have attempted to run the path multiple times (by chaining the same command block together) only for it to move erratically, sometimes going so far as to glitch into the ground.

I have considered taking a redstone output from the pathing command block, delaying the signal's death until the path can finish, and then reconnecting the chain once this has occured, however as it turns out, comparators cannot take an output from a chain command block, leaving that option a no-go.

Is there something obvious I'm missing here?

For reference, the coordinates I'm spawning the ingot at are x=-80 y=90 z=-66 and I'm trying to get it to path to x=-82 y=85 z=-76

Thanks for the help!

Best Answer

You can probably just change the command that summons the area effect cloud, so that it executes from an entity with the tag triforce and at the specified coordinates.
That would look something like this:

/execute positioned -82 85 -75 as @e[tag=triforce,distance=..0.5] at @s run summon area_effect_cloud ~ ~ ~ {NoGravity:1b,Particle:"explosion",Duration:40,Tags:["explosion"]}

Then you do not even have to think about correct timing, because the explosion (or the particle effect) would happen when your gold bar is at that specific location.

To make it less jagged I suggest to use the Motion tag instead of teleporting.

/summon item -80 90 -66 {NoGravity:1b,Glowing:1b,PickupDelay:199980,Owner:"herobrine",Thrower:"notch",Tags:["triforce"],Item:{id:"minecraft:gold_ingot",Count:1b},Motion:[-0.02,-0.1,-0.45]}

The item will slow down over time, so you may want it to either start faster, or repeatedly set that tag. You can do that with the command block that you currently use for teleporting.

/data modify @e[tag=triforce] Motion set value [-0.02,-0.1,-0.45]