From 938f29d0d12365dfa0b239f9f0138e6136f18f1f Mon Sep 17 00:00:00 2001 From: Tschipcraft <78470530+Tschipcraft@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:47:33 +0100 Subject: [PATCH] Expand predicates to all entities + Adapt Smithed Conventions **- Mobs holding or wearing light emitting items will now produce light** **- Item frames containing light emitting items will now also produce light** - Allays will now emit light level 9 - Added all the Froglights to light level 15 items - Fixed #1 - Fixed #2 - Adapted to Smithed Conventions - Inactive lights will now be preserved - Increased light updates to 1 tick (2 ticks before) - Active dynamic light radius increased to 65 blocks (30 before) --- data/dynamiclights/functions/core.mcfunction | 18 ++++++++ .../dynamiclights/functions/delete.mcfunction | 2 +- .../functions/find_target.mcfunction | 31 -------------- .../functions/install.mcfunction | 8 ++-- .../functions/install_trigger.mcfunction | 1 + .../functions/light/core.mcfunction | 25 +++++++++++ .../light/resolve_light_override.mcfunction | 5 +++ .../light/resolve_no_space.mcfunction | 11 +++++ data/dynamiclights/functions/main.mcfunction | 37 ++++++----------- data/dynamiclights/functions/menu.mcfunction | 17 ++++---- .../functions/menu_reset.mcfunction | 4 ++ .../functions/messages/how_to_use.mcfunction | 6 +-- .../functions/messages/welcome.mcfunction | 6 +-- data/dynamiclights/functions/reset.mcfunction | 2 +- .../functions/sources/core.mcfunction | 5 +++ .../functions/sources/entity.mcfunction | 6 +++ .../functions/sources/item.mcfunction | 41 ++++++++++--------- .../functions/sources/player.mcfunction | 15 ------- .../functions/summon_light.mcfunction | 7 +++- .../summon_redstone_light.mcfunction | 7 +++- .../functions/summon_soul_light.mcfunction | 7 +++- .../functions/uninstall.mcfunction | 12 +++--- .../predicates/campfire_check.json | 19 +++++++++ data/dynamiclights/predicates/spectator.json | 14 +++++++ data/dynamiclights/predicates/visible.json | 10 +++++ .../tags/entity_types/always_glow.json | 3 +- .../tags/entity_types/dl_exclude.mcfunction | 11 ----- .../tags/entity_types/dyn_ignore.json | 14 +++++++ data/dynamiclights/tags/items/light.json | 5 ++- data/minecraft/tags/functions/load.json | 3 +- data/minecraft/tags/functions/tick.json | 5 --- 31 files changed, 213 insertions(+), 144 deletions(-) create mode 100644 data/dynamiclights/functions/core.mcfunction delete mode 100644 data/dynamiclights/functions/find_target.mcfunction create mode 100644 data/dynamiclights/functions/light/core.mcfunction create mode 100644 data/dynamiclights/functions/light/resolve_light_override.mcfunction create mode 100644 data/dynamiclights/functions/light/resolve_no_space.mcfunction create mode 100644 data/dynamiclights/functions/menu_reset.mcfunction create mode 100644 data/dynamiclights/functions/sources/core.mcfunction create mode 100644 data/dynamiclights/functions/sources/entity.mcfunction delete mode 100644 data/dynamiclights/functions/sources/player.mcfunction create mode 100644 data/dynamiclights/predicates/campfire_check.json create mode 100644 data/dynamiclights/predicates/spectator.json create mode 100644 data/dynamiclights/predicates/visible.json delete mode 100644 data/dynamiclights/tags/entity_types/dl_exclude.mcfunction create mode 100644 data/dynamiclights/tags/entity_types/dyn_ignore.json delete mode 100644 data/minecraft/tags/functions/tick.json diff --git a/data/dynamiclights/functions/core.mcfunction b/data/dynamiclights/functions/core.mcfunction new file mode 100644 index 0000000..e523ae5 --- /dev/null +++ b/data/dynamiclights/functions/core.mcfunction @@ -0,0 +1,18 @@ +## by Tschipcraft + +# Items +function dynamiclights:sources/core + +# Debug +#execute as @e[type=minecraft:marker] at @s run particle minecraft:dust 0 90 90 1 + +# Entities +execute as @s[type=#dynamiclights:always_glow] at @s run function dynamiclights:summon_soul_light +execute as @s[type=#dynamiclights:always_burn] at @s unless entity @s[type=minecraft:tnt,nbt={Fuse:1s}] unless entity @s[type=minecraft:tnt,nbt={Fuse:2s}] run function dynamiclights:summon_light + +# Light block sadly blocks explosion +#execute as @s[type=minecraft:creeper,nbt={ignited:1b},tag=!global.ignore,tag=!smithed.strict] at @s run function dynamiclights:summon_light + +# Extension for More Mobs +execute as @s[type=minecraft:wither_skeleton,tag=mm_magma_1] at @s run function dynamiclights:summon_redstone_light +execute as @s[type=minecraft:wither_skeleton,tag=mm_magma_2] at @s run function dynamiclights:summon_soul_light diff --git a/data/dynamiclights/functions/delete.mcfunction b/data/dynamiclights/functions/delete.mcfunction index 5e9669a..0c7150b 100644 --- a/data/dynamiclights/functions/delete.mcfunction +++ b/data/dynamiclights/functions/delete.mcfunction @@ -2,4 +2,4 @@ execute if block ~ ~ ~ light[waterlogged=true] run fill ~ ~ ~ ~ ~ ~ water replace light execute if block ~ ~ ~ light[waterlogged=false] run fill ~ ~ ~ ~ ~ ~ air replace light -kill @s[type=marker] +kill @s[type=marker,tag=ts.dynamiclights.light] diff --git a/data/dynamiclights/functions/find_target.mcfunction b/data/dynamiclights/functions/find_target.mcfunction deleted file mode 100644 index ec16f27..0000000 --- a/data/dynamiclights/functions/find_target.mcfunction +++ /dev/null @@ -1,31 +0,0 @@ -##by Tschipcraft - -execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~ ~1 ~ #dynamiclights:air run tp @s ~ ~1 ~ -execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~1 ~ ~ #dynamiclights:air run tp @s ~1 ~ ~ -execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~ ~ ~1 #dynamiclights:air run tp @s ~ ~ ~1 -execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~-1 ~ ~ #dynamiclights:air run tp @s ~-1 ~ ~ -execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] run tp @s ~ ~ ~-1 - -execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] run tp @s ~ ~2 ~ - -execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] run kill @s - -execute as @s[tag=!redstone_light] at @s as @e[type=marker,tag=redstone_light,tag=!new_light,distance=..0.5] at @s run function dynamiclights:delete -execute as @s[tag=!soul_light,tag=!redstone_light] at @s as @e[type=marker,tag=soul_light,tag=!new_light,distance=..0.5] at @s run function dynamiclights:delete -execute as @s[tag=soul_light] at @s as @e[type=marker,tag=redstone_light,tag=!new_light,distance=..0.5] at @s run function dynamiclights:delete - -execute as @s[tag=redstone_light] at @s if entity @e[type=marker,tag=redstone_light,tag=!new_light,distance=..0.5] run kill @e[type=marker,tag=redstone_light,tag=!new_light,distance=..0.5] -execute as @s[tag=soul_light] at @s if entity @e[type=marker,tag=soul_light,tag=!new_light,distance=..0.5] run kill @e[type=marker,tag=soul_light,tag=!new_light,distance=..0.5] -execute as @s[tag=!redstone_light,tag=!soul_light] at @s if entity @e[type=marker,tag=light,tag=!new_light,distance=..0.5] run kill @e[type=marker,tag=light,tag=!new_light,distance=..0.5] - -execute as @s[tag=!redstone_light,tag=!soul_light] at @s if block ~ ~ ~ water[level=0] run fill ~ ~ ~ ~ ~ ~ light[waterlogged=true,level=15] replace water -execute as @s[tag=!redstone_light,tag=!soul_light] at @s unless block ~ ~ ~ water unless block ~ ~ ~ light run fill ~ ~ ~ ~ ~ ~ light[waterlogged=false,level=15] replace air - -execute as @s[tag=redstone_light] at @s if block ~ ~ ~ water[level=0] run fill ~ ~ ~ ~ ~ ~ light[waterlogged=true,level=6] replace water -execute as @s[tag=redstone_light] at @s unless block ~ ~ ~ water unless block ~ ~ ~ light run fill ~ ~ ~ ~ ~ ~ light[waterlogged=false,level=6] replace air - -execute as @s[tag=soul_light] at @s if block ~ ~ ~ water[level=0] run fill ~ ~ ~ ~ ~ ~ light[waterlogged=true,level=9] replace water -execute as @s[tag=soul_light] at @s unless block ~ ~ ~ water unless block ~ ~ ~ light run fill ~ ~ ~ ~ ~ ~ light[waterlogged=false,level=9] replace air - - -tag @s remove new_light diff --git a/data/dynamiclights/functions/install.mcfunction b/data/dynamiclights/functions/install.mcfunction index 3336dfc..97fa6e6 100644 --- a/data/dynamiclights/functions/install.mcfunction +++ b/data/dynamiclights/functions/install.mcfunction @@ -1,9 +1,9 @@ ##by Tschipcraft -scoreboard objectives add dl_welcome dummy -scoreboard objectives add dl_how_to_use trigger -scoreboard objectives add dl_unlimited dummy -scoreboard objectives add menu trigger +scoreboard objectives add ts.dl.mess.welc dummy +scoreboard objectives add ts.dl.mess.how trigger +scoreboard objectives add ts.dl.unlimited dummy +scoreboard objectives add tschipcraft.menu trigger scoreboard objectives add tvc_ignore dummy diff --git a/data/dynamiclights/functions/install_trigger.mcfunction b/data/dynamiclights/functions/install_trigger.mcfunction index 354b8ed..a676e81 100644 --- a/data/dynamiclights/functions/install_trigger.mcfunction +++ b/data/dynamiclights/functions/install_trigger.mcfunction @@ -1,3 +1,4 @@ ##by Tschipcraft +function dynamiclights:version_checker function dynamiclights:install diff --git a/data/dynamiclights/functions/light/core.mcfunction b/data/dynamiclights/functions/light/core.mcfunction new file mode 100644 index 0000000..055e981 --- /dev/null +++ b/data/dynamiclights/functions/light/core.mcfunction @@ -0,0 +1,25 @@ +##by Tschipcraft + +# Find target +execute at @s unless block ~ ~ ~ #dynamiclights:air run function dynamiclights:light/resolve_no_space + +# Clean already placed lights +execute as @s[tag=ts.dynamiclights.redstone_light] at @s as @e[type=marker,tag=ts.dynamiclights.redstone_light,tag=!ts.dynamiclights.new_light,distance=..0.5] run kill @s +execute as @s[tag=ts.dynamiclights.soul_light] at @s as @e[type=marker,tag=ts.dynamiclights.soul_light,tag=!ts.dynamiclights.new_light,distance=..0.5] run kill @s +execute as @s[tag=!ts.dynamiclights.redstone_light,tag=!ts.dynamiclights.soul_light] at @s as @e[type=marker,tag=ts.dynamiclights.light,tag=!ts.dynamiclights.new_light,distance=..0.5] run kill @s + +# Override light levels +execute as @s at @s if entity @e[type=marker,tag=ts.dynamiclights.light,tag=!ts.dynamiclights.new_light,distance=..0.5] at @s run function dynamiclights:light/resolve_light_override + +# Place light +execute as @s[tag=!ts.dynamiclights.redstone_light,tag=!ts.dynamiclights.soul_light] at @s if block ~ ~ ~ water[level=0] run fill ~ ~ ~ ~ ~ ~ light[waterlogged=true,level=15] replace water +execute as @s[tag=!ts.dynamiclights.redstone_light,tag=!ts.dynamiclights.soul_light] at @s unless block ~ ~ ~ water unless block ~ ~ ~ light run fill ~ ~ ~ ~ ~ ~ light[waterlogged=false,level=15] replace #dynamiclights:air + +execute as @s[tag=ts.dynamiclights.redstone_light] at @s if block ~ ~ ~ water[level=0] run fill ~ ~ ~ ~ ~ ~ light[waterlogged=true,level=6] replace water +execute as @s[tag=ts.dynamiclights.redstone_light] at @s unless block ~ ~ ~ water unless block ~ ~ ~ light run fill ~ ~ ~ ~ ~ ~ light[waterlogged=false,level=6] replace #dynamiclights:air + +execute as @s[tag=ts.dynamiclights.soul_light] at @s if block ~ ~ ~ water[level=0] run fill ~ ~ ~ ~ ~ ~ light[waterlogged=true,level=9] replace water +execute as @s[tag=ts.dynamiclights.soul_light] at @s unless block ~ ~ ~ water unless block ~ ~ ~ light run fill ~ ~ ~ ~ ~ ~ light[waterlogged=false,level=9] replace #dynamiclights:air + + +tag @s remove ts.dynamiclights.new_light diff --git a/data/dynamiclights/functions/light/resolve_light_override.mcfunction b/data/dynamiclights/functions/light/resolve_light_override.mcfunction new file mode 100644 index 0000000..e831cb1 --- /dev/null +++ b/data/dynamiclights/functions/light/resolve_light_override.mcfunction @@ -0,0 +1,5 @@ +##by Tschipcraft - overrides or merges existing lights + +execute as @s[tag=!ts.dynamiclights.redstone_light] at @s as @e[type=marker,tag=ts.dynamiclights.redstone_light,tag=!ts.dynamiclights.new_light,distance=..0.5] at @s run function dynamiclights:delete +execute as @s[tag=!ts.dynamiclights.soul_light,tag=!redstone_light] at @s as @e[type=marker,tag=soul_light,tag=!ts.dynamiclights.new_light,distance=..0.5] at @s run function dynamiclights:delete +execute as @s[tag=ts.dynamiclights.soul_light] at @s as @e[type=marker,tag=ts.dynamiclights.redstone_light,tag=!ts.dynamiclights.new_light,distance=..0.5] at @s run function dynamiclights:delete diff --git a/data/dynamiclights/functions/light/resolve_no_space.mcfunction b/data/dynamiclights/functions/light/resolve_no_space.mcfunction new file mode 100644 index 0000000..27a147f --- /dev/null +++ b/data/dynamiclights/functions/light/resolve_no_space.mcfunction @@ -0,0 +1,11 @@ +##by Tschipcraft - tries to find a place to place the light + +execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~ ~1 ~ #dynamiclights:air run tp @s ~ ~1 ~ +execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~1 ~ ~ #dynamiclights:air run tp @s ~1 ~ ~ +execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~ ~ ~1 #dynamiclights:air run tp @s ~ ~ ~1 +execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] if block ~-1 ~ ~ #dynamiclights:air run tp @s ~-1 ~ ~ +execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] run tp @s ~ ~ ~-1 + +execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] run tp @s ~ ~2 ~ + +execute at @s unless block ~ ~ ~ #dynamiclights:air unless block ~ ~ ~ water[level=0] run kill @s diff --git a/data/dynamiclights/functions/main.mcfunction b/data/dynamiclights/functions/main.mcfunction index 50c5f11..a3e09f1 100644 --- a/data/dynamiclights/functions/main.mcfunction +++ b/data/dynamiclights/functions/main.mcfunction @@ -1,31 +1,18 @@ ## by Tschipcraft -tag @e[type=minecraft:marker,tag=light] add old_light - -# Items -execute as @a[gamemode=!spectator] at @s positioned ~ ~1 ~ run function dynamiclights:sources/player - -execute as @e[type=minecraft:item] at @s run function dynamiclights:sources/item - -# Debug -#execute as @e[type=minecraft:marker] at @s run particle minecraft:dust 0 90 90 1 - -# Entities -execute as @e[type=#dynamiclights:always_glow] at @s run function dynamiclights:summon_soul_light -execute as @e[type=#dynamiclights:always_burn] at @s unless entity @s[type=tnt,nbt={Fuse:1s}] unless entity @s[type=tnt,nbt={Fuse:2s}] run function dynamiclights:summon_light - -#execute as @e[type=creeper,nbt={ignited:1b}] at @s if entity @a[gamemode=!spectator,distance=..30] run function dynamiclights:summon_light - -#Extension for More Mobs -execute as @e[type=minecraft:wither_skeleton,tag=magma_1] at @s run function dynamiclights:summon_redstone_light -execute as @e[type=minecraft:wither_skeleton,tag=magma_2] at @s run function dynamiclights:summon_soul_light - -# OnFire -execute unless score global dl_unlimited matches 1 as @e[type=!#dynamiclights:dl_exclude] at @s if entity @a[gamemode=!spectator,distance=..30] if predicate dynamiclights:is_on_fire run function dynamiclights:summon_light -execute if score global dl_unlimited matches 1 as @e[type=!#dynamiclights:dl_exclude] at @s if predicate dynamiclights:is_on_fire run function dynamiclights:summon_light +# Marking old lights +tag @e[type=minecraft:marker,tag=ts.dynamiclights.light] add ts.dynamiclights.old_light +# Core +execute unless score global ts.dl.unlimited matches 1 as @e at @s if entity @a[gamemode=!spectator,distance=..65] run function dynamiclights:core +execute if score global ts.dl.unlimited matches 1 as @e at @s run function dynamiclights:core +#execute as @e at @s run function dynamiclights:core # Clearing old lights and repeat -execute as @e[type=minecraft:marker,tag=old_light] at @s run function dynamiclights:delete +execute unless score global ts.dl.unlimited matches 1 as @e[type=minecraft:marker,tag=ts.dynamiclights.old_light] at @s if entity @a[gamemode=!spectator,distance=..65] run function dynamiclights:delete +execute if score global ts.dl.unlimited matches 1 as @e[type=minecraft:marker,tag=ts.dynamiclights.old_light] at @s run function dynamiclights:delete + +# Menu +function dynamiclights:menu -schedule function dynamiclights:main 2t +schedule function dynamiclights:main 1t diff --git a/data/dynamiclights/functions/menu.mcfunction b/data/dynamiclights/functions/menu.mcfunction index bf8ee56..8db2d65 100644 --- a/data/dynamiclights/functions/menu.mcfunction +++ b/data/dynamiclights/functions/menu.mcfunction @@ -1,13 +1,10 @@ ##by Tschipcraft -## menu message -scoreboard players enable @a menu -scoreboard players add @a dl_welcome 0 -execute as @a[scores={menu=1..60,dl_welcome=1}] run scoreboard players set @s dl_welcome 0 -execute as @a[scores={dl_welcome=0}] run function dynamiclights:messages/welcome -execute as @a[scores={dl_how_to_use=1}] run function dynamiclights:messages/how_to_use +## Menu message +scoreboard players enable @a tschipcraft.menu +#scoreboard players add @a ts.dl.mess.welcome 0 - don't show menu on first boot +execute as @a[scores={tschipcraft.menu=1..}] run scoreboard players set @s ts.dl.mess.welc 0 +execute as @a[scores={ts.dl.mess.welc=0}] run function dynamiclights:messages/welcome +execute as @a[scores={ts.dl.mess.how=1}] run function dynamiclights:messages/how_to_use -execute as @a[scores={menu=1..60,dl_welcome=1}] run scoreboard players set @s dl_welcome 2 -execute as @a[scores={menu=61..}] run scoreboard players set @s dl_welcome 1 -scoreboard players reset @a[scores={menu=122..}] menu -scoreboard players add @a[scores={menu=1..}] menu 1 +execute as @a[scores={tschipcraft.menu=1..}] run schedule function dynamiclights:menu_reset 1t diff --git a/data/dynamiclights/functions/menu_reset.mcfunction b/data/dynamiclights/functions/menu_reset.mcfunction new file mode 100644 index 0000000..e6f0627 --- /dev/null +++ b/data/dynamiclights/functions/menu_reset.mcfunction @@ -0,0 +1,4 @@ +##by Tschipcraft + +scoreboard players reset @a[scores={tschipcraft.menu=1..}] ts.dl.mess.welc +scoreboard players reset @a[scores={tschipcraft.menu=1..}] tschipcraft.menu diff --git a/data/dynamiclights/functions/messages/how_to_use.mcfunction b/data/dynamiclights/functions/messages/how_to_use.mcfunction index a127b4b..a3153fa 100644 --- a/data/dynamiclights/functions/messages/how_to_use.mcfunction +++ b/data/dynamiclights/functions/messages/how_to_use.mcfunction @@ -1,5 +1,5 @@ ## by Tschipcraft -tellraw @s ["",{"text":"=-= How to use =-=","bold":true,"color":"gold"},{"text":"\n"},{"text":"Burning entities/items such as torches or lanterns now emit light!","color":"green"}] -scoreboard players reset @s dl_how_to_use -scoreboard players enable @s dl_how_to_use +tellraw @s ["",{"text":"=-= How to use =-=","bold":true,"color":"gold"},{"text":"\n"},{"text":"Supported entities/items such as torches or lanterns now emit light!","color":"green"}] +scoreboard players reset @s ts.dl.mess.how +scoreboard players enable @s ts.dl.mess.how diff --git a/data/dynamiclights/functions/messages/welcome.mcfunction b/data/dynamiclights/functions/messages/welcome.mcfunction index 69ee5c0..cfd30f3 100644 --- a/data/dynamiclights/functions/messages/welcome.mcfunction +++ b/data/dynamiclights/functions/messages/welcome.mcfunction @@ -1,5 +1,5 @@ ## by Tschipcraft -tellraw @s ["",{"text":"➤ Dynamic Lights by Tschipcraft installed!","italic":false,"color":"green"},{"text":"\n"},{"text":"[How to use]","color":"light_purple","clickEvent":{"action":"run_command","value":"/trigger dl_how_to_use"},"hoverEvent":{"action":"show_text","contents":"Click here"}},{"text":" "},{"text":"[Reset]","color":"red","clickEvent":{"action":"run_command","value":"/function dynamiclights:reset"},"hoverEvent":{"action":"show_text","contents":["",{"text":"Reset the whole data pack.","color":"white"}]}},{"text":" "},{"text":"[Uninstall]","color":"dark_red","clickEvent":{"action":"run_command","value":"/function dynamiclights:uninstall"},"hoverEvent":{"action":"show_text","contents":["",{"text":"Uninstall the data pack. ","color":"white"},{"text":"Note: No entities/items will glow anymore!","color":"red"}]}},{"text":" "},{"text":"[Check for updates] ","color":"blue","clickEvent":{"action":"open_url","value":"https://tschipcraft.ddns.net/update/test.html?pack=dynamiclights&v=1.4"},"hoverEvent":{"action":"show_text","contents":"Click here to check for updates."}}] -scoreboard players set @s dl_welcome 1 -scoreboard players enable @s dl_how_to_use +tellraw @s ["",{"text":"➤ Dynamic Lights by Tschipcraft installed!","italic":false,"color":"green"},{"text":"\n"},{"text":"[How to use]","color":"light_purple","clickEvent":{"action":"run_command","value":"/trigger ts.dl.mess.how"},"hoverEvent":{"action":"show_text","contents":"Click here"}},{"text":" "},{"text":"[Reset]","color":"red","clickEvent":{"action":"run_command","value":"/function dynamiclights:reset"},"hoverEvent":{"action":"show_text","contents":["",{"text":"Reset the whole data pack.","color":"white"}]}},{"text":" "},{"text":"[Uninstall]","color":"dark_red","clickEvent":{"action":"run_command","value":"/function dynamiclights:uninstall"},"hoverEvent":{"action":"show_text","contents":["",{"text":"Uninstall the data pack. ","color":"white"},{"text":"Note: No entities/items will glow anymore!","color":"red"}]}},{"text":" "},{"text":"[Check for updates] ","color":"blue","clickEvent":{"action":"open_url","value":"https://tschipcraft.ddns.net/update/test.html?pack=dynamiclights&v=1.5"},"hoverEvent":{"action":"show_text","contents":"Click here to check for updates."}}] +scoreboard players set @s ts.dl.mess.welc 1 +scoreboard players enable @s ts.dl.mess.how diff --git a/data/dynamiclights/functions/reset.mcfunction b/data/dynamiclights/functions/reset.mcfunction index 8952ab1..3633d91 100644 --- a/data/dynamiclights/functions/reset.mcfunction +++ b/data/dynamiclights/functions/reset.mcfunction @@ -1,5 +1,5 @@ ##by Tschipcraft -execute as @e[type=minecraft:marker,tag=light] at @s run function dynamiclights:delete +execute as @e[type=minecraft:marker,tag=ts.dynamiclights.light] at @s run function dynamiclights:delete say Successfully reseted Dynamic lights! diff --git a/data/dynamiclights/functions/sources/core.mcfunction b/data/dynamiclights/functions/sources/core.mcfunction new file mode 100644 index 0000000..3633f06 --- /dev/null +++ b/data/dynamiclights/functions/sources/core.mcfunction @@ -0,0 +1,5 @@ +##by Tschipcraft + +execute as @s[type=minecraft:item] run function dynamiclights:sources/item +execute as @s[type=minecraft:item_frame] run function dynamiclights:sources/item +execute as @s[type=!#dynamiclights:dyn_ignore,tag=!global.ignore,tag=!smithed.strict] positioned ~ ~1 ~ unless entity @s[type=player,gamemode=spectator] run function dynamiclights:sources/entity diff --git a/data/dynamiclights/functions/sources/entity.mcfunction b/data/dynamiclights/functions/sources/entity.mcfunction new file mode 100644 index 0000000..4c33b3d --- /dev/null +++ b/data/dynamiclights/functions/sources/entity.mcfunction @@ -0,0 +1,6 @@ +##by Tschipcraft + +execute if predicate dynamiclights:light if predicate dynamiclights:campfire_check run function dynamiclights:summon_light +execute if predicate dynamiclights:visible if predicate dynamiclights:campfire_check if predicate dynamiclights:soul_light run function dynamiclights:summon_soul_light +execute if predicate dynamiclights:visible if predicate dynamiclights:redstone_light run function dynamiclights:summon_redstone_light +execute if predicate dynamiclights:is_on_fire run function dynamiclights:summon_light diff --git a/data/dynamiclights/functions/sources/item.mcfunction b/data/dynamiclights/functions/sources/item.mcfunction index 9b07960..ee90bbe 100644 --- a/data/dynamiclights/functions/sources/item.mcfunction +++ b/data/dynamiclights/functions/sources/item.mcfunction @@ -3,7 +3,7 @@ # Light execute as @s[nbt={Item:{id:"minecraft:torch"}}] run function dynamiclights:summon_light execute as @s[nbt={Item:{id:"minecraft:lantern"}}] run function dynamiclights:summon_light -execute as @s[nbt={Item:{id:"minecraft:campfire"}}] run function dynamiclights:summon_light +execute as @s[nbt={Item:{id:"minecraft:campfire"}}] unless entity @s[nbt={Item:{tag:{BlockStateTag:{lit:"false"}}}}] run function dynamiclights:summon_light execute as @s[nbt={Item:{id:"minecraft:glowstone"}}] run function dynamiclights:summon_light execute as @s[nbt={Item:{id:"minecraft:lava_bucket"}}] run function dynamiclights:summon_light execute as @s[nbt={Item:{id:"minecraft:sea_lantern"}}] run function dynamiclights:summon_light @@ -12,26 +12,29 @@ execute as @s[nbt={Item:{id:"minecraft:jack_o_lantern"}}] run function dynamicli execute as @s[nbt={Item:{id:"minecraft:shroomlight"}}] run function dynamiclights:summon_light execute as @s[nbt={Item:{id:"minecraft:end_rod"}}] run function dynamiclights:summon_light execute as @s[nbt={Item:{id:"minecraft:beacon"}}] run function dynamiclights:summon_light +execute as @s[nbt={Item:{id:"minecraft:ochre_froglight"}}] run function dynamiclights:summon_light +execute as @s[nbt={Item:{id:"minecraft:pearlescent_froglight"}}] run function dynamiclights:summon_light +execute as @s[nbt={Item:{id:"minecraft:verdant_froglight"}}] run function dynamiclights:summon_light # Glow -execute as @s[nbt={Item:{id:"minecraft:soul_torch"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:soul_lantern"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:soul_campfire"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:glow_ink_sac"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:glow_berries"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:glow_item_frame"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:glow_lichen"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:prismarine_crystals"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:blaze_rod"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:spectral_arrow"}}] run function dynamiclights:summon_soul_light -execute as @s[nbt={Item:{id:"minecraft:end_crystal"}}] run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:soul_torch"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:soul_lantern"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:soul_campfire"}}] if predicate dynamiclights:visible unless entity @s[nbt={Item:{tag:{BlockStateTag:{lit:"false"}}}}] run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:glow_ink_sac"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:glow_berries"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:glow_item_frame"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:glow_lichen"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:prismarine_crystals"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:blaze_rod"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:spectral_arrow"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light +execute as @s[nbt={Item:{id:"minecraft:end_crystal"}}] if predicate dynamiclights:visible run function dynamiclights:summon_soul_light # Flimmer -execute as @s[nbt={Item:{id:"minecraft:redstone_torch"}}] run function dynamiclights:summon_redstone_light -execute as @s[nbt={Item:{id:"minecraft:fire_charge"}}] run function dynamiclights:summon_redstone_light -execute as @s[nbt={Item:{id:"minecraft:nether_star"}}] run function dynamiclights:summon_redstone_light -execute as @s[nbt={Item:{id:"minecraft:blaze_powder"}}] run function dynamiclights:summon_redstone_light -execute as @s[nbt={Item:{id:"minecraft:amethyst_shard"}}] run function dynamiclights:summon_redstone_light -execute as @s[nbt={Item:{id:"minecraft:ender_chest"}}] run function dynamiclights:summon_redstone_light +execute as @s[nbt={Item:{id:"minecraft:redstone_torch"}}] if predicate dynamiclights:visible run function dynamiclights:summon_redstone_light +execute as @s[nbt={Item:{id:"minecraft:fire_charge"}}] if predicate dynamiclights:visible run function dynamiclights:summon_redstone_light +execute as @s[nbt={Item:{id:"minecraft:nether_star"}}] if predicate dynamiclights:visible run function dynamiclights:summon_redstone_light +execute as @s[nbt={Item:{id:"minecraft:blaze_powder"}}] if predicate dynamiclights:visible run function dynamiclights:summon_redstone_light +execute as @s[nbt={Item:{id:"minecraft:amethyst_shard"}}] if predicate dynamiclights:visible run function dynamiclights:summon_redstone_light +execute as @s[nbt={Item:{id:"minecraft:ender_chest"}}] if predicate dynamiclights:visible run function dynamiclights:summon_redstone_light -execute as @s[nbt={Item:{tag:{Enchantments:[{}]}}}] run function dynamiclights:summon_redstone_light +execute as @s[nbt={Item:{tag:{Enchantments:[{}]}}}] if predicate dynamiclights:visible run function dynamiclights:summon_redstone_light diff --git a/data/dynamiclights/functions/sources/player.mcfunction b/data/dynamiclights/functions/sources/player.mcfunction deleted file mode 100644 index 78c0fee..0000000 --- a/data/dynamiclights/functions/sources/player.mcfunction +++ /dev/null @@ -1,15 +0,0 @@ -##by Tschipcraft - - -execute if predicate dynamiclights:light run function dynamiclights:summon_light -execute if predicate dynamiclights:soul_light run function dynamiclights:summon_soul_light -execute if predicate dynamiclights:redstone_light run function dynamiclights:summon_redstone_light - - -## Enchantments - -# Mainhand -execute as @s[nbt={SelectedItem:{tag:{Enchantments:[{}]}}}] run function dynamiclights:summon_redstone_light - -# Offhand -execute as @s[nbt={Inventory:[{tag:{Enchantments:[{}]},Slot:-106b}]}] run function dynamiclights:summon_redstone_light diff --git a/data/dynamiclights/functions/summon_light.mcfunction b/data/dynamiclights/functions/summon_light.mcfunction index 959f0ef..ed7e36f 100644 --- a/data/dynamiclights/functions/summon_light.mcfunction +++ b/data/dynamiclights/functions/summon_light.mcfunction @@ -1,5 +1,8 @@ ##by Tschipcraft -execute align xyz positioned ~0.5 ~ ~0.5 run summon minecraft:marker ~ ~ ~ {Tags:["light","new_light"]} +execute align xyz positioned ~0.5 ~ ~0.5 run summon minecraft:marker ~ ~ ~ {Tags:["ts.dynamiclights.light","ts.dynamiclights.new_light","global.ignore","smithed.entity","smithed.strict"],Invulnerable:1b} -execute as @e[type=minecraft:marker,tag=new_light] at @s run function dynamiclights:find_target +# Resolve potential problems and place the light +execute as @e[type=minecraft:marker,tag=ts.dynamiclights.new_light] at @s run function dynamiclights:light/core + +#say A light triggered! \ No newline at end of file diff --git a/data/dynamiclights/functions/summon_redstone_light.mcfunction b/data/dynamiclights/functions/summon_redstone_light.mcfunction index f79014c..9ca40e1 100644 --- a/data/dynamiclights/functions/summon_redstone_light.mcfunction +++ b/data/dynamiclights/functions/summon_redstone_light.mcfunction @@ -1,5 +1,8 @@ ##by Tschipcraft -execute align xyz positioned ~0.5 ~ ~0.5 run summon minecraft:marker ~ ~ ~ {Tags:["light","new_light","redstone_light"]} +execute align xyz positioned ~0.5 ~ ~0.5 run summon minecraft:marker ~ ~ ~ {Tags:["ts.dynamiclights.light","ts.dynamiclights.new_light","ts.dynamiclights.redstone_light","global.ignore","smithed.entity","smithed.strict"],Invulnerable:1b} -execute as @e[type=minecraft:marker,tag=new_light] at @s run function dynamiclights:find_target +# Resolve potential problems and place the light +execute as @e[type=minecraft:marker,tag=ts.dynamiclights.new_light] at @s run function dynamiclights:light/core + +#say A redstone light triggered! \ No newline at end of file diff --git a/data/dynamiclights/functions/summon_soul_light.mcfunction b/data/dynamiclights/functions/summon_soul_light.mcfunction index 110f61b..cfcff7b 100644 --- a/data/dynamiclights/functions/summon_soul_light.mcfunction +++ b/data/dynamiclights/functions/summon_soul_light.mcfunction @@ -1,5 +1,8 @@ ##by Tschipcraft -execute align xyz positioned ~0.5 ~ ~0.5 run summon minecraft:marker ~ ~ ~ {Tags:["light","new_light","soul_light"]} +execute align xyz positioned ~0.5 ~ ~0.5 run summon minecraft:marker ~ ~ ~ {Tags:["ts.dynamiclights.light","ts.dynamiclights.new_light","ts.dynamiclights.soul_light","global.ignore","smithed.entity","smithed.strict"],Invulnerable:1b} -execute as @e[type=minecraft:marker,tag=new_light] at @s run function dynamiclights:find_target +# Resolve potential problems and place the light +execute as @e[type=minecraft:marker,tag=ts.dynamiclights.new_light] at @s run function dynamiclights:light/core + +#say A soul light triggered! \ No newline at end of file diff --git a/data/dynamiclights/functions/uninstall.mcfunction b/data/dynamiclights/functions/uninstall.mcfunction index 75b588c..ee1cff9 100644 --- a/data/dynamiclights/functions/uninstall.mcfunction +++ b/data/dynamiclights/functions/uninstall.mcfunction @@ -1,15 +1,15 @@ ##by Tschipcraft -execute as @e[type=minecraft:marker,tag=light] at @s run function dynamiclights:delete +execute as @e[type=minecraft:marker,tag=ts.dynamiclights.light] at @s run function dynamiclights:delete -scoreboard objectives remove dl_welcome -scoreboard objectives remove dl_how_to_use -scoreboard objectives remove dl_unlimited -scoreboard objectives remove menu +scoreboard objectives remove ts.dl.mess.welc +scoreboard objectives remove ts.dl.mess.how +scoreboard objectives remove ts.dl.unlimited +scoreboard objectives remove tschipcraft.menu scoreboard objectives remove tvc_ignore -say Dynamic Lights has been uninstalled by @s! It is safe to disable and remove the data pack. +say Dynamic Lights by Tschipcraft has been uninstalled by @s! It is safe to disable and remove the data pack. datapack disable "file/dynamiclights" datapack disable "file/dynamiclights.zip" diff --git a/data/dynamiclights/predicates/campfire_check.json b/data/dynamiclights/predicates/campfire_check.json new file mode 100644 index 0000000..af8f2dc --- /dev/null +++ b/data/dynamiclights/predicates/campfire_check.json @@ -0,0 +1,19 @@ +{ + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "items": [ + "minecraft:campfire", + "minecraft:soul_campfire" + ], + "nbt": "{BlockStateTag:{lit:\"false\"}}" + } + } + } + } +} + \ No newline at end of file diff --git a/data/dynamiclights/predicates/spectator.json b/data/dynamiclights/predicates/spectator.json new file mode 100644 index 0000000..785ffb3 --- /dev/null +++ b/data/dynamiclights/predicates/spectator.json @@ -0,0 +1,14 @@ +{ + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:player", + "type_specific": { + "type": "player", + "gamemode": "spectator" + } + } + } +} \ No newline at end of file diff --git a/data/dynamiclights/predicates/visible.json b/data/dynamiclights/predicates/visible.json new file mode 100644 index 0000000..9b468e0 --- /dev/null +++ b/data/dynamiclights/predicates/visible.json @@ -0,0 +1,10 @@ +{ + "condition": "minecraft:location_check", + "predicate": { + "light": { + "light": { + "max": 9 + } + } + } +} diff --git a/data/dynamiclights/tags/entity_types/always_glow.json b/data/dynamiclights/tags/entity_types/always_glow.json index 579110e..29b76a9 100644 --- a/data/dynamiclights/tags/entity_types/always_glow.json +++ b/data/dynamiclights/tags/entity_types/always_glow.json @@ -5,6 +5,7 @@ "minecraft:glow_item_frame", "minecraft:spectral_arrow", "minecraft:firework_rocket", - "minecraft:wither_skull" + "minecraft:wither_skull", + {"id": "minecraft:allay", "required": false} ] } diff --git a/data/dynamiclights/tags/entity_types/dl_exclude.mcfunction b/data/dynamiclights/tags/entity_types/dl_exclude.mcfunction deleted file mode 100644 index e3d545f..0000000 --- a/data/dynamiclights/tags/entity_types/dl_exclude.mcfunction +++ /dev/null @@ -1,11 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:area_effect_cloud", - "minecraft:marker", - "minecraft:experience_bottle", - "minecraft:experience_orb", - "minecraft:leash_knot", - "minecraft:llama_spit" - ] -} diff --git a/data/dynamiclights/tags/entity_types/dyn_ignore.json b/data/dynamiclights/tags/entity_types/dyn_ignore.json new file mode 100644 index 0000000..121267e --- /dev/null +++ b/data/dynamiclights/tags/entity_types/dyn_ignore.json @@ -0,0 +1,14 @@ +{ + "replace": false, + "values": [ + "#dynamiclights:always_burn", + "#dynamiclights:always_glow", + "minecraft:item", + "minecraft:item_frame", + "minecraft:glow_item_frame", + "minecraft:area_effect_cloud", + "minecraft:leash_knot", + "minecraft:llama_spit", + "minecraft:marker" + ] +} diff --git a/data/dynamiclights/tags/items/light.json b/data/dynamiclights/tags/items/light.json index a4ebc78..f693baa 100644 --- a/data/dynamiclights/tags/items/light.json +++ b/data/dynamiclights/tags/items/light.json @@ -11,6 +11,9 @@ "minecraft:jack_o_lantern", "minecraft:shroomlight", "minecraft:end_rod", - "minecraft:beacon" + "minecraft:beacon", + {"id": "minecraft:ochre_froglight", "required": false}, + {"id": "minecraft:pearlescent_froglight", "required": false}, + {"id": "minecraft:verdant_froglight", "required": false} ] } diff --git a/data/minecraft/tags/functions/load.json b/data/minecraft/tags/functions/load.json index 4e4404c..f2a1b08 100644 --- a/data/minecraft/tags/functions/load.json +++ b/data/minecraft/tags/functions/load.json @@ -1,6 +1,5 @@ { "values": [ - "dynamiclights:install_trigger", - "dynamiclights:version_checker" + "dynamiclights:install_trigger" ] } diff --git a/data/minecraft/tags/functions/tick.json b/data/minecraft/tags/functions/tick.json deleted file mode 100644 index 1243a97..0000000 --- a/data/minecraft/tags/functions/tick.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "values": [ - "dynamiclights:menu" - ] -}