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

✨ init bs.gui #234

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[
{
"name": "clear_events",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#clear-events",
"authors": [
"Aksiome"
],
"created": {
"date": "2024/11/01",
"version": "1.21.3"
},
"updated": {
"date": "2024/11/01",
"version": "1.21.3"
}
},
{
"name": "on_hover",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#on-event",
"authors": [
"Aksiome",
"theogiraudet"
],
"created": {
"date": "2024/03/30",
"version": "24w13a"
},
"updated": {
"date": "2024/11/01",
"version": "1.21.3"
},
"weak_dependencies": [
"bs.log"
]
},
{
"name": "on_hover_enter",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#on-event",
"authors": [
"Aksiome",
"theogiraudet"
],
"created": {
"date": "2024/03/30",
"version": "24w13a"
},
"updated": {
"date": "2024/11/01",
"version": "1.21.3"
},
"weak_dependencies": [
"bs.log"
]
},
{
"name": "on_hover_leave",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#on-event",
"authors": [
"Aksiome",
"theogiraudet"
],
"created": {
"date": "2024/03/30",
"version": "24w13a"
},
"updated": {
"date": "2024/11/01",
"version": "1.21.3"
},
"weak_dependencies": [
"bs.log"
]
},
{
"name": "on_left_click",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#on-event",
"authors": [
"Aksiome",
"theogiraudet"
],
"created": {
"date": "2024/03/30",
"version": "24w13a"
},
"updated": {
"date": "2024/11/01",
"version": "1.21.3"
},
"weak_dependencies": [
"bs.log"
]
},
{
"name": "on_right_click",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#on-event",
"authors": [
"Aksiome",
"theogiraudet"
],
"created": {
"date": "2024/03/30",
"version": "24w13a"
},
"updated": {
"date": "2024/11/01",
"version": "1.21.3"
},
"weak_dependencies": [
"bs.log"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "bs.interaction",
"display_name": "Interaction",
"description": "A low-level API to create GUI based on Interaction entity by binding events to it.",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html",
"authors": [
"Aksiome",
"theogiraudet"
],
"weak_dependencies": [
"bs.log"
],
"features": [
"bs.interaction:clear_events",
"bs.interaction:on_hover",
"bs.interaction:on_hover_enter",
"bs.interaction:on_hover_leave",
"bs.interaction:on_left_click",
"bs.interaction:on_right_click"
]
}
9 changes: 9 additions & 0 deletions datapacks/Bookshelf/data/bs.interaction/.metadata/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "bs.interaction",
"display_name": "Interaction",
"description": "A low-level API to create GUI based on Interaction entity by binding events to it.",
"documentation": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html",
"weak_dependencies": [
"bs.log"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"criteria": {
"requirement": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:interaction",
"nbt": "{ Tags: [ \"bs.interaction.listen_left_click\" ] }",
"distance": {
"absolute": {
"max": 24
}
}
}
}
]
}
}
},
"rewards": {
"function": "bs.interaction:on_event/left_click/left_click"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"criteria": {
"requirement": {
"trigger": "minecraft:player_interacted_with_entity",
"conditions": {
"entity": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:interaction",
"nbt": "{ Tags: [ \"bs.interaction.listen_right_click\" ] }",
"distance": {
"absolute": {
"max": 24
}
}
}
}
]
}
}
},
"rewards": {
"function": "bs.interaction:on_event/right_click/right_click"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
#
# Documentation of the feature: https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html
# ------------------------------------------------------------------------------------------------------------

tellraw @s [{"text": "[bs.interaction documentation]", "color": "dark_aqua", "clickEvent": {"action": "open_url", "value": "https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html"}, "hoverEvent": {"action": "show_text", "contents": "Click to open URL"}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

forceload add -30000000 1600
execute unless entity B5-0-0-0-2 run summon minecraft:text_display -30000000 0 1600 {UUID:[I;181,0,0,2],Tags:["bs.entity","bs.persistent","smithed.entity","smithed.strict"],view_range:0f}

scoreboard objectives add bs.ctx dummy [{"text":"BS ","color":"dark_gray"},{"text":"Context","color":"aqua"}]
scoreboard objectives add bs.data dummy [{"text":"BS ","color":"dark_gray"},{"text":"Data","color":"aqua"}]
scoreboard objectives add bs.const dummy [{"text":"BS ","color":"dark_gray"},{"text":"Constants","color":"aqua"}]

scoreboard objectives add bs.interaction.id dummy [{"text":"BS ","color":"dark_gray"},{"text":"Interaction ID","color":"aqua"}]
scoreboard objectives add bs.interaction.hover dummy [{"text":"BS ","color":"dark_gray"},{"text":"Interaction Hover","color":"aqua"}]
scoreboard objectives add bs.interaction.logout minecraft.custom:leave_game [{"text":"BS ","color":"dark_gray"},{"text":"Interaction Logout","color":"aqua"}]

scoreboard players set 2 bs.const 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

kill B5-0-0-0-2
forceload remove -30000000 1600

execute as @e[type=minecraft:interaction] run function #bs.interaction:clear_events {with:{}}

scoreboard objectives remove bs.interaction.id

scoreboard objectives remove bs.ctx
scoreboard objectives remove bs.data
scoreboard objectives remove bs.const

data remove storage bs:data interaction
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
#
# Documentation of the feature: https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#default-callback
# ------------------------------------------------------------------------------------------------------------

# Note:
# Glows the current entity.

data modify entity @s Glowing set value 1b
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
#
# Documentation of the feature: https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#default-callback
# ------------------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
#
# Documentation of the feature: https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#default-callback
# ------------------------------------------------------------------------------------------------------------

# Note:
# Unglows the current entity.

data modify entity @s Glowing set value 0b
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
#
# Documentation of the feature: https://bookshelf.docs.gunivers.net/en/latest/modules/interaction.html#clear-events
# ------------------------------------------------------------------------------------------------------------

$data modify storage bs:ctx _ set value $(with)
execute store result storage bs:ctx y int 1 run scoreboard players get @s bs.interaction.id
return run function bs.interaction:clear_events/remove_matching with storage bs:ctx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ------------------------------------------------------------------------------------------------------------
# Copyright (c) 2024 Gunivers
#
# This file is part of the Bookshelf project (https://github.com/Gunivers/Bookshelf).
#
# This source code is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Conditions:
# - You may use this file in compliance with the MPL v2.0
# - Any modifications must be documented and disclosed under the same license
#
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

$execute store result score #i bs.ctx run data remove storage bs:data interaction.$(y)[$(_)]

$execute unless data storage bs:data interaction.$(y)[-1] run scoreboard players reset @s bs.interaction.id
$execute unless data storage bs:data interaction.$(y)[{type:"hover"}] run tag @s remove bs.interaction.listen_hover
$execute unless data storage bs:data interaction.$(y)[{type:"hover_enter"}] run tag @s remove bs.interaction.listen_hover_enter
$execute unless data storage bs:data interaction.$(y)[{type:"hover_leave"}] run tag @s remove bs.interaction.listen_hover_leave
$execute unless data storage bs:data interaction.$(y)[{type:"left_click"}] run tag @s remove bs.interaction.listen_left_click
$execute unless data storage bs:data interaction.$(y)[{type:"right_click"}] run tag @s remove bs.interaction.listen_right_click

execute unless entity @s[tag=bs.interaction.listen_hover] \
unless entity @s[tag=bs.interaction.listen_hover_enter] \
unless entity @s[tag=bs.interaction.listen_hover_leave] \
run tag @s remove bs.interaction.is_hoverable

execute unless entity @s[tag=bs.interaction.is_hoverable] run scoreboard players set #interaction.process bs.data 0

return run scoreboard players get #i bs.ctx
Loading
Loading