Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paper-only event player tracks|untracks <entity> #2444

Conversation

BreadcrumbIsTaken
Copy link
Contributor

@BreadcrumbIsTaken BreadcrumbIsTaken commented Mar 18, 2023

player tracks|untracks <entity>

For when the player stops or starts tracking an entity.

Contexts

  • <context.entity> - the entity being tracked or untracked
  • <context.location> = the location of the entity removed for redundancy (you can just use <context.entity.location> instead

Requested by Mergu on Discord

🛤️🛤️🛤️

@SXRWahrheit
Copy link
Contributor

Because tracking isn't defined elsewhere, I'd recommend providing an explanation for what the actual behavior is in the meta. I don't think any other feature uses this vocabulary, so it makes sense to have it in the event meta rather than a separate language meta entry.

@mergu
Copy link
Contributor

mergu commented Mar 18, 2023

https://meta.denizenscript.com/Docs/Mechanisms/entitytag.tracking_range

despawns, dies, or is unloaded would replace unloaded with "or the player moves out of its <@link ... tracking_range>"

@EventHandler
public void playerTracksEntityEvent(PlayerTrackEntityEvent event) {
entity = new EntityTag(event.getEntity());
location = new LocationTag(event.getEntity().getLocation());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this, the location can be pulled from the entity via a tag if needed

@EventHandler
public void playerUntracksEntityEvent(PlayerUntrackEntityEvent event) {
entity = new EntityTag(event.getEntity());
location = new LocationTag(event.getEntity().getLocation());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with previous comment, this can be removed

@@ -64,6 +64,7 @@ public static void init() {
ScriptEvent.registerScriptEvent(PlayerSelectsStonecutterRecipeScriptEvent.class);
ScriptEvent.registerScriptEvent(PlayerSpectatesEntityScriptEvent.class);
ScriptEvent.registerScriptEvent(PlayerStopsSpectatingScriptEvent.class);
ScriptEvent.registerScriptEvent(PlayerTracksEntityScriptEvent.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These events were added in 1.19, need a version check here

Thanks Mergu, Aya, Icecapade, and Wahrheit!
}

@EventHandler
public void playerTracksEntityEvent(PlayerTrackEntityEvent event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should follow the onX naming convention, I.e. onPlayerTracksEntity (same for the other listener)

@BreadcrumbIsTaken
Copy link
Contributor Author

Done

// @Player Always.
//
// @Example
// # Narrate when the player tracks all entities except for item frames.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any not all

@mcmonkey4eva mcmonkey4eva merged commit 7b382dc into DenizenScript:dev Mar 20, 2023
@BreadcrumbIsTaken BreadcrumbIsTaken deleted the player_tracks_stops_tracking_entity branch March 21, 2023 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants