Skip to content

Commit

Permalink
Expand predicates to all entities + Adapt Smithed Conventions
Browse files Browse the repository at this point in the history
**- 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)
  • Loading branch information
Tschipcraft committed Feb 24, 2023
1 parent 508f0bc commit 938f29d
Show file tree
Hide file tree
Showing 31 changed files with 213 additions and 144 deletions.
18 changes: 18 additions & 0 deletions data/dynamiclights/functions/core.mcfunction
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion data/dynamiclights/functions/delete.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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]
31 changes: 0 additions & 31 deletions data/dynamiclights/functions/find_target.mcfunction

This file was deleted.

8 changes: 4 additions & 4 deletions data/dynamiclights/functions/install.mcfunction
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions data/dynamiclights/functions/install_trigger.mcfunction
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
##by Tschipcraft

function dynamiclights:version_checker
function dynamiclights:install
25 changes: 25 additions & 0 deletions data/dynamiclights/functions/light/core.mcfunction
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions data/dynamiclights/functions/light/resolve_no_space.mcfunction
Original file line number Diff line number Diff line change
@@ -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
37 changes: 12 additions & 25 deletions data/dynamiclights/functions/main.mcfunction
Original file line number Diff line number Diff line change
@@ -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
17 changes: 7 additions & 10 deletions data/dynamiclights/functions/menu.mcfunction
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions data/dynamiclights/functions/menu_reset.mcfunction
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions data/dynamiclights/functions/messages/how_to_use.mcfunction
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions data/dynamiclights/functions/messages/welcome.mcfunction
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion data/dynamiclights/functions/reset.mcfunction
Original file line number Diff line number Diff line change
@@ -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!
5 changes: 5 additions & 0 deletions data/dynamiclights/functions/sources/core.mcfunction
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions data/dynamiclights/functions/sources/entity.mcfunction
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 938f29d

Please sign in to comment.