Skip to content

Commit 9aab63f

Browse files
committed
Add per-player toggle
Added per-player toggle for Dynamic Lights (closes #37, #26, #47)
1 parent 289a8bf commit 9aab63f

17 files changed

+100
-13
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- Added Curios API and Curios API Continuation support (closes [#52](https://github.com/Tschipcraft/dynamiclights/issues/52))
2-
- Added global toggle for Dynamic Lights (closes [#56](https://github.com/Tschipcraft/dynamiclights/issues/56))
2+
- Added global and per-player toggle for Dynamic Lights (closes [#56](https://github.com/Tschipcraft/dynamiclights/issues/56), closes [#37](https://github.com/Tschipcraft/dynamiclights/issues/37), closes [#26](https://github.com/Tschipcraft/dynamiclights/issues/26), closes [#47](https://github.com/Tschipcraft/dynamiclights/issues/47))
33
- Added mod support for Lucky's Wardrobe
44
- Fixed ominous item spawners not being parsed for light emitting items
55
- Fixed Dynamic Lights breaking after some time on paper servers (closes [#45](https://github.com/Tschipcraft/dynamiclights/issues/45), closes [#21](https://github.com/Tschipcraft/dynamiclights/issues/21))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"criteria": {
3+
"trigger_menu": {
4+
"trigger": "minecraft:tick",
5+
"conditions": {
6+
"player": [
7+
{
8+
"condition": "minecraft:entity_scores",
9+
"entity": "this",
10+
"scores": {
11+
"ts.dl.toggle": {
12+
"min": 1
13+
}
14+
}
15+
}
16+
]
17+
}
18+
}
19+
},
20+
"rewards": {
21+
"function": "dynamiclights:settings/toggle_enable_player"
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"criteria": {
3+
"trigger_menu": {
4+
"trigger": "minecraft:tick",
5+
"conditions": {
6+
"player": [
7+
{
8+
"condition": "minecraft:entity_scores",
9+
"entity": "this",
10+
"scores": {
11+
"ts.dl.toggle": {
12+
"min": 1
13+
}
14+
}
15+
}
16+
]
17+
}
18+
}
19+
},
20+
"rewards": {
21+
"function": "dynamiclights:settings/toggle_enable_player"
22+
}
23+
}

data/dynamiclights/function/install.mcfunction

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,19 @@ execute unless score $rain_sensitive ts.dl.settings matches -1..2 run scoreboard
6060
execute unless score $unlimited ts.dl.settings matches -1..2 run scoreboard players set $unlimited ts.dl.settings 0
6161

6262
scoreboard objectives add tschipcraft.menu trigger
63+
scoreboard objectives add ts.dl.toggle trigger
6364
scoreboard players enable @a tschipcraft.menu
65+
scoreboard players enable @a ts.dl.toggle
6466

6567
scoreboard objectives add tvc_ignore dummy
6668

6769
## Set load status
6870
# 18 for v1.8
6971
scoreboard players set dynamiclights load.status 18
7072

71-
# Reset advancement
73+
# Reset advancements
7274
advancement revoke @a only tschipcraft:menu
75+
advancement revoke @a only dynamiclights:toggle_enable
7376

7477
## Schedule main function
7578
schedule function dynamiclights:internal/main 5t

data/dynamiclights/function/internal/main.mcfunction

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tag @e[type=minecraft:marker,tag=ts.dl.light] add ts.dl.remove
1010
execute as @e[type=minecraft:tnt] at @s run function dynamiclights:internal/explosion_detection/tnt
1111

1212
# Core
13-
execute if score $enable ts.dl.settings matches 1..2 unless score $global ts.dl.tnt.fuse matches 1 as @e[type=!#dynamiclights:dyn_ignore,tag=!smithed.strict,tag=!global.ignore,tag=!global.ignore.gui] unless entity @s[type=minecraft:player,gamemode=spectator] at @s run function dynamiclights:internal/main_exec
13+
execute if score $enable ts.dl.settings matches 1..2 unless score $global ts.dl.tnt.fuse matches 1 as @e[type=!#dynamiclights:dyn_ignore,tag=!smithed.strict,tag=!global.ignore,tag=!global.ignore.gui,tag=!ts.dl.ignore] unless entity @s[type=minecraft:player,gamemode=spectator] at @s run function dynamiclights:internal/main_exec
1414

1515
# Clear old lights
1616
execute as @e[type=minecraft:marker,tag=ts.dl.remove] at @s run function dynamiclights:internal/remove_light

data/dynamiclights/function/reset.mcfunction

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ kill @e[type=minecraft:armor_stand,tag=ts.dl.i.parser]
88
# Reset explosion alarm
99
function dynamiclights:internal/explosion_detection/reset
1010

11-
# Reset advancement
11+
# Reset advancements
1212
advancement revoke @a only tschipcraft:menu
1313
scoreboard players enable @a tschipcraft.menu
14+
advancement revoke @a only dynamiclights:toggle_enable
15+
scoreboard players enable @a ts.dl.toggle
1416

1517
# Reset parsed data
1618
scoreboard objectives remove ts.dl.i.type

data/dynamiclights/function/settings/core.mcfunction

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
tellraw @s {"text":"\n=-=Dynamic Lights Settings=-=","bold":true,"color":"dark_green"}
44

5-
execute if score $enable ts.dl.settings matches 1 run tellraw @s [{"text":"[✔] ","bold":true,"color":"green","hoverEvent":{"action":"show_text","contents":[{"text":"Click here to toggle Dynamic Lights "},{"text":"off","color":"red"},{"text":"."}]},"clickEvent":{"action":"run_command","value":"/function dynamiclights:settings/toggle_enable"}},{"text":"Enable Dynamic Lights","color":"white"}]
6-
execute if score $enable ts.dl.settings matches 0 run tellraw @s [{"text":"[❌] ","bold":true,"color": "red","hoverEvent":{"action":"show_text","contents":[{"text":"Click here to toggle Dynamic Lights "},{"text":"on","color":"green"},{"text":"."}]},"clickEvent":{"action":"run_command","value":"/function dynamiclights:settings/toggle_enable"}},{"text":"Enable Dynamic Lights","color":"white"}]
5+
execute if score $enable ts.dl.settings matches 1 run tellraw @s [{"text":"[✔] ","bold":true,"color":"green","hoverEvent":{"action":"show_text","contents":[{"text":"Click here to toggle Dynamic Lights "},{"text":"off","color":"red"},{"text":"."}]},"clickEvent":{"action":"run_command","value":"/function dynamiclights:settings/toggle_enable_global"}},{"text":"Enable Dynamic Lights","color":"white"}]
6+
execute if score $enable ts.dl.settings matches 0 run tellraw @s [{"text":"[❌] ","bold":true,"color": "red","hoverEvent":{"action":"show_text","contents":[{"text":"Click here to toggle Dynamic Lights "},{"text":"on","color":"green"},{"text":"."}]},"clickEvent":{"action":"run_command","value":"/function dynamiclights:settings/toggle_enable_global"}},{"text":"Enable Dynamic Lights","color":"white"}]
77
execute if score $enable ts.dl.settings matches -1 run tellraw @s [{"text":"[❌] Enable Dynamic Lights","bold":false,"color":"gray","hoverEvent":{"action":"show_text","contents":[{"text":"This setting is getting controlled globally and can't be changed here."}]}}]
88
execute if score $enable ts.dl.settings matches 2 run tellraw @s [{"text":"[✔] Enable Dynamic Lights","bold":false,"color":"gray","hoverEvent":{"action":"show_text","contents":[{"text":"This setting is getting controlled globally and can't be changed here."}]}}]
9-
execute if score $enable ts.dl.settings matches -1..0 run tellraw @s {"text":"-- \u26a0 Dynamic Lights disabled \u26a0 --","color":"red"}
9+
execute if score $enable ts.dl.settings matches -1..0 run tellraw @s {"text":"-- \u26a0 Dynamic Lights disabled \u26a0 --","color":"red","hoverEvent":{"action":"show_text","contents":[{"text":"Click here to toggle Dynamic Lights "},{"text":"on","color":"green"},{"text":"."}]},"clickEvent":{"action":"run_command","value":"/function dynamiclights:settings/toggle_enable_global"}}
1010

11+
execute as @s[tag=!ts.dl.ignore] run tellraw @s [{"text":"[✔] ","bold":true,"color":"green","hoverEvent":{"action":"show_text","contents":[{"text":"Click here to toggle Dynamic Lights "},{"text":"off","color":"red"},{"text":" for "},{"selector": "@s"},{"text": "."}]},"clickEvent":{"action":"run_command","value":"/trigger ts.dl.toggle"}},{"text":"Enable Dynamic Lights for yourself","color":"white"}]
12+
execute as @s[tag=ts.dl.ignore] run tellraw @s [{"text":"[❌] ","bold":true,"color": "red","hoverEvent":{"action":"show_text","contents":[{"text":"Click here to toggle Dynamic Lights "},{"text":"on","color":"green"},{"text":" for "},{"selector": "@s"},{"text": "."}]},"clickEvent":{"action":"run_command","value":"/trigger ts.dl.toggle"}},{"text":"Enable Dynamic Lights for yourself","color":"white"}]
1113

1214
tellraw @s {"text":"\nEnable light emitting from...","bold":true,"color":"white"}
1315

data/dynamiclights/function/settings/toggle_enable.mcfunction renamed to data/dynamiclights/function/settings/toggle_enable_global.mcfunction

File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
##by Tschipcraft
2+
3+
execute as @s[tag=!ts.dl.ignore] run tellraw @s ["",{"text":"\n-> Disabled "},{"text":"Dynamic Lights for yourself","color":"yellow"}]
4+
execute as @s[tag=ts.dl.ignore] run tellraw @s ["",{"text":"\n-> Enabled "},{"text":"Dynamic Lights for yourself","color":"yellow"}]
5+
6+
execute store success score #temp ts.dl.toggle run tag @s add ts.dl.ignore
7+
8+
execute if score #temp ts.dl.toggle matches 0 run tag @s remove ts.dl.ignore
9+
scoreboard players reset @s ts.dl.toggle
10+
scoreboard players enable @a ts.dl.toggle
11+
advancement revoke @a only dynamiclights:toggle_enable
12+
execute at @s run function dynamiclights:settings

data/dynamiclights/function/uninstall.mcfunction

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ scoreboard objectives remove ts.dl.temp
2525

2626
scoreboard objectives remove ts.dl.mess.welc
2727
scoreboard objectives remove ts.dl.settings
28+
scoreboard objectives remove ts.dl.toggle
2829
scoreboard objectives remove tschipcraft.menu
2930

3031
scoreboard objectives remove ts.dl.version

0 commit comments

Comments
 (0)