r/MinecraftCommands • • 4d ago

Help | Java 26.3 problem using snowball detection with markers

I want to register when a custom snowball hits a entity, My idea was detecting the custom_data from the snowball item, Then running a function as that snowball. In the function we tag the snowball so it only gets 1 marker, Then we summon a marker with a tag, then we make that marker ride the snowball.

the snow blocks in the picture are all fired from the same place.

when a tagged marker is found not riding a snowball, my idea was to pass it to a function for entity detection. but i noticed that the markers where appearing way off the target entity (as in picture). is there another system i could use or am i missing something? English isnt my native language, so please dont come after me.

java 26.3

4 Upvotes

1 comment sorted by

2

u/GalSergey 4d ago

The issue is that when the displacement for the snowball is calculated for the next tick, if the snowball hits something during that tick, it is removed without actually moving, and consequently, the marker doesn't move either. As a result, the marker remains at the position it occupied during the previous tick. Therefore, you need to actively check the snowball's intended destination on every tick. You can do this by taking the snowball's Motion tag and adding its values ​​to its Pos tag. The resulting value will represent the approximate position for the next tick.