#Get target selector for entity which was last interacted with?

1 messages · Page 1 of 1 (latest)

fleet river
#

I'm trying to use an advancement to detect a player interacting with an entity, so I can trigger a function which affects that entity's data, via the data command. To do this, I need the entity's UUID, or maybe a target selector which can select the last-interacted-with entity. How can I do this? Is there a a way to get additional information from the trigger?

    "criteria": {
        "sole_criterion": {
            "trigger": "minecraft:player_interacted_with_entity",
            "conditions": {
                "item": {
                    "items": [ "minecraft:potion" ],
                    "potion": "minecraft:thick"
                },
                "entity": {
                    "type": "minecraft:villager"
                }
            }
        }
    }```
acoustic briarBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

foggy fjord
#

No there is not. You'll need to have the reward function try to find the corresponding entity with as much accuracy as possible

#

Searching for nearest entity type in front of the player with a small distance should be more than enough in 95% of cases

fleet river
#

huh ok

#

thank you

#

so interactions with mobs are hardcoded? they arent data?

foggy fjord
#

I don't even know how to answer that question

#

It's pretty much covered by "no there is not a way to get additional information from the trigger"

fleet river
#

alright

#

how would you define in front of the player

foggy fjord
#

You can use caret notation to provide relative coordinates based on the executors rotation

#

For example, execute positioned ^3 ^2 ^1 ... will execute one block in front of the executor, two blocks above their feet, and three blocks to (I believe) the left

fleet river
#

thank you