Skip to content

Commit

Permalink
Add intermediate light levels 3 and 12
Browse files Browse the repository at this point in the history
- Added intermediate light levels 3 and 12 (#14)
- Some more tag changes
  - Added magma cream to light level 3 items
  - Added enchanted golden apple, sculk catalyst and enchanted book to light level 6 items
  - Moved allay from 9 to light level 6 entities
  - Moved dragon fireball from 15 to light level 12 entities
  - Added magma cube to light level 3 entities
- Fixed loading issues due to missing tags in Minecraft 1.17x
  • Loading branch information
Tschipcraft committed May 19, 2024
1 parent 4b48a55 commit caeb9ef
Show file tree
Hide file tree
Showing 78 changed files with 1,102 additions and 50 deletions.
4 changes: 2 additions & 2 deletions META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ version="${version}+mod"
displayName="Dynamic Lights"
description='''Supported entities and items will emit light by using the light block added in 21w13a.
§lSupported Items:§r Torches, Lanterns, Campfires, Glowstone, Glowstone Dust, Blaze Rods, Blaze Powder, Spectral Arrows, Lava Buckets, Sea Lanterns, Prismarine Crystals, Froglights, Glow Ink Sacs, Glow Berries, Glow Item Frames, Glow Lichen, Jack o'Lanterns, Shroomlights, End Rods, End Crystals, Fire Charge, Amethyst Shards, Nether Stars, Ender Chests and Beacons
§lSupported Items:§r Torches, Lanterns, Campfires, Glowstone, Glowstone Dust, Magma Blocks, Blaze Rods, Blaze Powder, Spectral Arrows, Lava Buckets, Sea Lanterns, Prismarine Crystals, Sea Pickles, Froglights, Glow Ink Sacs, Glow Berries, Glow Item Frames, Glow Lichen, Sculk Catalysts, Vaults, Jack o'Lanterns, Shroomlights, End Rods, End Crystals, Fire Charge, Amethyst Shards, Crying Obsidian, Nether Stars, Totems, Ender Chests, Enchanting Tables and Beacons
Additionally, all enchanted items will emit light level 6 while Fire Aspect, Riptide or Channeling enchanted items emit light level 9.
§lSupported Entities:§r Allays, Glow Squids, Glow Item Frames, Blazes, TNT, End Crystals, Fireballs, Spectral Arrows, Shulker Bullets, Firework Rockets and Flying Wither Skulls
§lSupported Entities:§r Allays, Glow Squids, Glow Item Frames, Blazes, TNT, End Crystals, Fireballs, Spectral Arrows, Shulker Bullets, Magma Cubes, Firework Rockets and Flying Wither Skulls
This mod is completely server-side!
Expand Down
7 changes: 7 additions & 0 deletions data/dynamiclights/functions/api/place_light/12.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##by Tschipcraft
# Places a dynamic light block with light level 12 near the provided location (~ ~ ~) that will disappear after 1 tick
# Additionally sets the score #check_passed ts.dl.temp to 1

scoreboard players set #check_passed ts.dl.temp 1

function dynamiclights:internal/place_light/12/exec
7 changes: 7 additions & 0 deletions data/dynamiclights/functions/api/place_light/3.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##by Tschipcraft
# Places a dynamic light block with light level 3 near the provided location (~ ~ ~) that will disappear after 1 tick
# Additionally sets the score #check_passed ts.dl.temp to 1

scoreboard players set #check_passed ts.dl.temp 1

function dynamiclights:internal/place_light/3/exec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## In Rain? (exclusive 1.19.4+ feature)
scoreboard players reset @s ts.dl.in_rain
execute if score $global ts.dl.version matches 3337.. if score $rain_sensitive ts.dl.settings matches 1..2 if predicate dynamiclights:world/is_raining run function dynamiclights:internal/water/rain_check
execute if score $global ts.dl.version matches 3337.. if score $rain_sensitive ts.dl.settings matches 1..2 if predicate dynamiclights:world/is_raining run function dynamiclights:internal/water/rain_check_1194

## In water?
scoreboard players add @s ts.dl.in_water 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
##by Tschipcraft
# Initiates finding a valid location to place the dynamic light

# Reset check score
scoreboard players set #block_placed ts.dl.temp 0

# Try current location
execute if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon

# If not valid, try deeper layer
execute unless score #block_placed ts.dl.temp matches 1 run function dynamiclights:internal/place_light/12/find_place/layer_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
##by Tschipcraft
# Finds a location to place a dynamic light

execute positioned ~ ~1 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~ ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~ ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~ ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~ ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon

# Try deeper layer
execute unless score #block_placed ts.dl.temp matches 1 run function dynamiclights:internal/place_light/12/find_place/layer_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##by Tschipcraft
# Finds a location to place a dynamic light

execute positioned ~ ~2 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~ ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~ ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~ ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~ ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon


execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~1 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~1 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~1 ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~1 ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/12/summon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##by Tschipcraft
# Places the light block

fill ~ ~ ~ ~ ~ ~ minecraft:light[waterlogged=true,level=12] replace minecraft:water[level=0]
execute if block ~ ~ ~ minecraft:cave_air run tag @s add ts.dl.cave_air
execute unless block ~ ~ ~ minecraft:light run fill ~ ~ ~ ~ ~ ~ minecraft:light[waterlogged=false,level=12] replace #dynamiclights:air
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##by Tschipcraft
# Checks if the light level from the previous iteration marker is lower or higher and about to be removed
# Renews the previous iteration marker

scoreboard players set #light_exists ts.dl.temp 1
execute if score @s ts.dl.l.level matches ..11 run function dynamiclights:internal/place_light/12/update
execute if score @s[tag=ts.dl.remove] ts.dl.l.level matches 13.. run function dynamiclights:internal/place_light/12/update
tag @s remove ts.dl.remove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##by Tschipcraft
# Gives an old light a new light level

fill ~ ~ ~ ~ ~ ~ minecraft:light[level=12,waterlogged=false] replace minecraft:light[waterlogged=false]
fill ~ ~ ~ ~ ~ ~ minecraft:light[level=12,waterlogged=true] replace minecraft:light[waterlogged=true]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
##by Tschipcraft
# Places a dynamic light block with light level 12 in the world

# Check if a dynamic light already exists here
scoreboard players set #light_exists ts.dl.temp 0
execute align xyz if block ~ ~ ~ minecraft:light as @e[type=minecraft:marker,tag=ts.dl.light,distance=..0.1,limit=1,sort=nearest] at @s run function dynamiclights:internal/place_light/12/prev_it/check

# Summon a new dynamic light
execute if score #light_exists ts.dl.temp matches 0 unless block ~ ~ ~ minecraft:light run function dynamiclights:internal/place_light/12/summon_new

scoreboard players set #block_placed ts.dl.temp 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##by Tschipcraft
# Sets attributes to new dynamic light entity and places light block

tag @s remove ts.dl.new_light

function dynamiclights:internal/place_light/12/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##by Tschipcraft
# Summons a new dynamic light entity

execute align xyz run summon minecraft:marker ~ ~ ~ {Tags:["ts.dl.light","ts.dl.new_light","global.ignore","global.ignore.kill","global.ignore.pos","smithed.block"],Invulnerable:1b,Silent:1b,CustomName:'{"text":"Dynamic Light [12]"}'}
execute align xyz as @e[type=minecraft:marker,tag=ts.dl.new_light,distance=..0.1,sort=nearest,limit=1] at @s run function dynamiclights:internal/place_light/12/summon_exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##by Tschipcraft
# Sets the light level for a dynamic light entity and updates the block

scoreboard players set @s ts.dl.l.level 12
# Update existing dynamic light block
execute if score #light_exists ts.dl.temp matches 1 run function dynamiclights:internal/place_light/12/prev_it/update
# Place new light block (checking for player placed light blocks is done in summon.mcfunction)
execute if score #light_exists ts.dl.temp matches 0 run function dynamiclights:internal/place_light/12/place_block
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
##by Tschipcraft
# Initiates finding a valid location to place the dynamic light

# Reset check score
scoreboard players set #block_placed ts.dl.temp 0

# Try current location
execute if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon

# If not valid, try deeper layer
execute unless score #block_placed ts.dl.temp matches 1 run function dynamiclights:internal/place_light/3/find_place/layer_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
##by Tschipcraft
# Finds a location to place a dynamic light

execute positioned ~ ~1 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~ ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~ ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~ ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~ ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon

# Try deeper layer
execute unless score #block_placed ts.dl.temp matches 1 run function dynamiclights:internal/place_light/3/find_place/layer_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##by Tschipcraft
# Finds a location to place a dynamic light

execute positioned ~ ~2 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~ ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~ ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~ ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~ ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon


execute unless score #block_placed ts.dl.temp matches 1 positioned ~1 ~1 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~-1 ~1 ~ if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon

execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~1 ~1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon
execute unless score #block_placed ts.dl.temp matches 1 positioned ~ ~1 ~-1 if predicate dynamiclights:world/place_light/valid_pos run function dynamiclights:internal/place_light/3/summon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##by Tschipcraft
# Places the light block

fill ~ ~ ~ ~ ~ ~ minecraft:light[waterlogged=true,level=3] replace minecraft:water[level=0]
execute if block ~ ~ ~ minecraft:cave_air run tag @s add ts.dl.cave_air
execute unless block ~ ~ ~ minecraft:light run fill ~ ~ ~ ~ ~ ~ minecraft:light[waterlogged=false,level=3] replace #dynamiclights:air
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##by Tschipcraft
# Checks if the light level from the previous iteration marker is lower or higher and about to be removed
# Renews the previous iteration marker

scoreboard players set #light_exists ts.dl.temp 1
execute if score @s ts.dl.l.level matches ..2 run function dynamiclights:internal/place_light/3/update
execute if score @s[tag=ts.dl.remove] ts.dl.l.level matches 4.. run function dynamiclights:internal/place_light/3/update
tag @s remove ts.dl.remove
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##by Tschipcraft
# Gives an old light a new light level

fill ~ ~ ~ ~ ~ ~ minecraft:light[level=3,waterlogged=false] replace minecraft:light[waterlogged=false]
fill ~ ~ ~ ~ ~ ~ minecraft:light[level=3,waterlogged=true] replace minecraft:light[waterlogged=true]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
##by Tschipcraft
# Places a dynamic light block with light level 3 in the world

# Check if a dynamic light already exists here
scoreboard players set #light_exists ts.dl.temp 0
execute align xyz if block ~ ~ ~ minecraft:light as @e[type=minecraft:marker,tag=ts.dl.light,distance=..0.1,limit=1,sort=nearest] at @s run function dynamiclights:internal/place_light/3/prev_it/check

# Summon a new dynamic light
execute if score #light_exists ts.dl.temp matches 0 unless block ~ ~ ~ minecraft:light run function dynamiclights:internal/place_light/3/summon_new

scoreboard players set #block_placed ts.dl.temp 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##by Tschipcraft
# Sets attributes to new dynamic light entity and places light block

tag @s remove ts.dl.new_light

function dynamiclights:internal/place_light/3/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##by Tschipcraft
# Summons a new dynamic light entity

execute align xyz run summon minecraft:marker ~ ~ ~ {Tags:["ts.dl.light","ts.dl.new_light","global.ignore","global.ignore.kill","global.ignore.pos","smithed.block"],Invulnerable:1b,Silent:1b,CustomName:'{"text":"Dynamic Light [3]"}'}
execute align xyz as @e[type=minecraft:marker,tag=ts.dl.new_light,distance=..0.1,sort=nearest,limit=1] at @s run function dynamiclights:internal/place_light/3/summon_exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##by Tschipcraft
# Sets the light level for a dynamic light entity and updates the block

scoreboard players set @s ts.dl.l.level 3
# Update existing dynamic light block
execute if score #light_exists ts.dl.temp matches 1 run function dynamiclights:internal/place_light/3/prev_it/update
# Place new light block (checking for player placed light blocks is done in summon.mcfunction)
execute if score #light_exists ts.dl.temp matches 0 run function dynamiclights:internal/place_light/3/place_block

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
scoreboard players set #check_passed ts.dl.temp 0

execute if predicate dynamiclights:entity/should_emit_light_level/15 align xyz run function dynamiclights:api/place_light/15
execute unless score #check_passed ts.dl.temp matches 1 if predicate dynamiclights:entity/should_emit_light_level/12 align xyz run function dynamiclights:api/place_light/12
execute unless score #check_passed ts.dl.temp matches 1 if predicate dynamiclights:entity/should_emit_light_level/9 align xyz run function dynamiclights:api/place_light/9
execute unless score #check_passed ts.dl.temp matches 1 if predicate dynamiclights:entity/should_emit_light_level/6 align xyz run function dynamiclights:api/place_light/6
execute unless score #check_passed ts.dl.temp matches 1 if predicate dynamiclights:entity/should_emit_light_level/3 align xyz run function dynamiclights:api/place_light/3
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ scoreboard players set .global ts.dl.i.is_ript 0
scoreboard players set .global ts.dl.i.is_chann 0

# Light Level
execute if predicate dynamiclights:entity/light_level/3/has_mainhand_item run scoreboard players set .global ts.dl.i.type 1
execute if predicate dynamiclights:entity/light_level/6/has_mainhand_item run scoreboard players set .global ts.dl.i.type 2
execute if predicate dynamiclights:entity/light_level/9/has_mainhand_item run scoreboard players set .global ts.dl.i.type 3
execute if predicate dynamiclights:entity/light_level/12/has_mainhand_item run scoreboard players set .global ts.dl.i.type 4
execute if predicate dynamiclights:entity/light_level/15/has_mainhand_item run scoreboard players set .global ts.dl.i.type 5

# Water Check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"predicate": {
"equipment": {
"mainhand": {
"tag": "minecraft:trimmable_armor",
"tag": "dynamiclights:trimmable_armor",
"count": {
"min": 1
},
Expand All @@ -26,7 +26,7 @@
"predicate": {
"equipment": {
"offhand": {
"tag": "minecraft:trimmable_armor",
"tag": "dynamiclights:trimmable_armor",
"count": {
"min": 1
},
Expand All @@ -44,7 +44,7 @@
"predicate": {
"equipment": {
"head": {
"tag": "minecraft:trimmable_armor",
"tag": "dynamiclights:trimmable_armor",
"count": {
"min": 1
},
Expand All @@ -62,7 +62,7 @@
"predicate": {
"equipment": {
"chest": {
"tag": "minecraft:trimmable_armor",
"tag": "dynamiclights:trimmable_armor",
"count": {
"min": 1
},
Expand All @@ -80,7 +80,7 @@
"predicate": {
"equipment": {
"legs": {
"tag": "minecraft:trimmable_armor",
"tag": "dynamiclights:trimmable_armor",
"count": {
"min": 1
},
Expand All @@ -98,7 +98,7 @@
"predicate": {
"equipment": {
"feet": {
"tag": "minecraft:trimmable_armor",
"tag": "dynamiclights:trimmable_armor",
"count": {
"min": 1
},
Expand Down

0 comments on commit caeb9ef

Please sign in to comment.