From 3c3bd036d75373749a65388146b0b1de6134adbd Mon Sep 17 00:00:00 2001 From: Aksiome <54895777+aksiome@users.noreply.github.com> Date: Thu, 6 Mar 2025 20:31:08 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20tag=20to=20check=20if?= =?UTF-8?q?=20interaction=20is=20hovered=20(#350)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/_templates/changelog/v3.0.0.md | 5 ++ docs/modules/interaction.md | 58 ++++++++++++------- .../function/on_event/hover/hover.mcfunction | 2 +- .../on_event/hover_enter/as_target.mcfunction | 1 + .../on_event/hover_leave/as_target.mcfunction | 1 + .../on_event/hover_leave/try_leave.mcfunction | 2 +- .../{check_id.json => match_id.json} | 0 .../test/on_hover_once.mcfunction | 37 ++++++++++++ 8 files changed, 82 insertions(+), 24 deletions(-) rename modules/bs.interaction/data/bs.interaction/predicate/{check_id.json => match_id.json} (100%) create mode 100644 modules/bs.interaction/data/bs.interaction/test/on_hover_once.mcfunction diff --git a/docs/_templates/changelog/v3.0.0.md b/docs/_templates/changelog/v3.0.0.md index a4f7bb7df1..d23cd63f3a 100644 --- a/docs/_templates/changelog/v3.0.0.md +++ b/docs/_templates/changelog/v3.0.0.md @@ -55,6 +55,11 @@ - 🐛 **[#320](https://github.com/mcbookshelf/bookshelf/issues/320)** - Fixed functions that were unusable outside the Overworld. +### `🖱️ bs.interaction` + +- ✨ **[#300](https://github.com/mcbookshelf/bookshelf/issues/300)** - Added `bs.interaction.hovered` tag to check if an interaction is currently hovered. + + ### `🏃 bs.move` - ⚠️ **[#282](https://github.com/mcbookshelf/Bookshelf/issues/282)** - Updated `on_collison` callback: scores now use the `bs.lambda` objective, and the input requires a full command instead of a function path. Additionally, `on_collision/*` functions have been renamed to `callback/*`. diff --git a/docs/modules/interaction.md b/docs/modules/interaction.md index 49b72d13c5..c1d74be8d0 100644 --- a/docs/modules/interaction.md +++ b/docs/modules/interaction.md @@ -244,6 +244,42 @@ You can find below all tags available in this API. --- +### Is Hovered? + +**`bs.interaction.hovered`** + +Determine if an interaction is currently hovered by a player. + +```{note} +This is useful in `hover_enter` and `hover_leave` events, which are per player. Since `hover_leave` triggers when a player stops hovering but doesn't check if all players have stopped, this tag can be used to determine when every player has left the interaction. +``` + +> **Credits**: Aksiome + +--- + +### Is Source? + +**`bs.interaction.source`** + +Usable only in the callback of an event. +Determine if the current entity is the source of the event. + +> **Credits**: theogiraudet + +--- + +### Is Target? + +**`bs.interaction.target`** + +Usable only in the callback of an event. +Determine if the current entity is the target of the event. + +> **Credits**: theogiraudet + +--- + ### Listen to a Specific Event? :::::{tab-set} @@ -284,28 +320,6 @@ Determine if the current interaction listen to leave hover interaction. --- -### Is Source? - -**`bs.interaction.source`** - -Usable only in the callback of an event. -Determine if the current entity is the source of the event. - -> **Credits**: theogiraudet - ---- - -### Is Target? - -**`bs.interaction.target`** - -Usable only in the callback of an event. -Determine if the current entity is the target of the event. - -> **Credits**: theogiraudet - ---- -