Skip to content

Commit

Permalink
Fix items getting wrongly recognized by slot contents predicate
Browse files Browse the repository at this point in the history
- Fixed some items getting recognized by the newly added slot contents predicate when they shouldn't (e.g. from the first slot in chest/hopper minecarts/boats or the first player hotbar slot)
- Added support for falling blocks, block displays and ominous item spawners in versions 24w11a and above
- Added separate mod support tag lists for modded items
- Tidied up predicate comments
- Updated version checker to 1.20.5 Release Candidate 2
  • Loading branch information
Tschipcraft committed Apr 19, 2024
1 parent b1a267f commit c3efcb6
Show file tree
Hide file tree
Showing 36 changed files with 113 additions and 18 deletions.
4 changes: 2 additions & 2 deletions data/dynamiclights/functions/internal/sources/core.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Dispatches dynamic light around the world
# @s - entity that may emit light

# These entities use a different NBT tag for storing the item and need special parsing for detection before 24w11a
execute if score $global ts.dl.version matches ..3822 as @s[type=#dynamiclights:parse] unless score @s ts.dl.i.type matches 0..15 run function dynamiclights:internal/sources/parse/main
# These entities use a different NBT tag for storing the item and need special parsing (since 24w11a these are only falling blocks and block displays)
execute as @s[type=#dynamiclights:parse] unless score @s ts.dl.i.type matches 0..15 run function dynamiclights:internal/sources/parse/main

# Offsets for exploding entities
execute as @s[type=#dynamiclights:may_block_explosion] positioned ~ ~2 ~ run function dynamiclights:internal/sources/entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ execute as @s[type=minecraft:item] run data modify entity c295ddee-4c15-4e5b-83b
execute as @s[type=minecraft:item_frame] run data modify entity c295ddee-4c15-4e5b-83ba-2fbce873a1d5 HandItems[0] set from entity @s Item
execute as @s[type=minecraft:glow_item_frame] run data modify entity c295ddee-4c15-4e5b-83ba-2fbce873a1d5 HandItems[0] set from entity @s Item
execute as @s[type=minecraft:falling_block] run data modify entity c295ddee-4c15-4e5b-83ba-2fbce873a1d5 HandItems[0].id set from entity @s BlockState.Name
# Extra case for item and block display entities
# Extra cases for item and block display entities
function dynamiclights:internal/sources/parse/extension_1194

execute as c295ddee-4c15-4e5b-83ba-2fbce873a1d5 run function dynamiclights:internal/sources/parse/main_exec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

scoreboard objectives add ts.dl.version dummy
execute store result score $global ts.dl.version run data get entity @r DataVersion
execute unless score $global tvc_ignore matches 1 if score $global ts.dl.version matches 3800.. run tellraw @a [{"text":"[Dynamic Lights] ","color":"gray"},{"text":"?","bold":true,"color":"gold"},{"text":" Minecraft version 1.20.5 or above detected! This data pack/mod may not work correctly anymore! Please make sure to check for updates in the menu! (","color":"gold"},{"text":"/trigger tschipcraft.menu","underlined":true,"color":"gold","clickEvent":{"action":"run_command","value":"/trigger tschipcraft.menu"},"hoverEvent":{"action":"show_text","contents":"Click here"}},{"text":")","color":"gold"}]
execute unless score $global tvc_ignore matches 1 if score $global ts.dl.version matches 3900.. run tellraw @a [{"text":"[Dynamic Lights] ","color":"gray"},{"text":"?","bold":true,"color":"gold"},{"text":" Minecraft version 1.20.6 or above detected! This data pack/mod may not work correctly anymore! Please make sure to check for updates in the menu! (","color":"gold"},{"text":"/trigger tschipcraft.menu","underlined":true,"color":"gold","clickEvent":{"action":"run_command","value":"/trigger tschipcraft.menu"},"hoverEvent":{"action":"show_text","contents":"Click here"}},{"text":")","color":"gold"}]
#execute if score $global ts.dl.version matches 2976..3106 run say 1.19 detected!
#execute if score $global ts.dl.version matches 2731..2975 run say 1.18 detected!
#execute if score $global ts.dl.version matches 2587..2730 run say 1.17 detected!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns true, if the item in the mainhand is a light level 15 item (Used by the item parser)",
"//comment": "This predicate returns true, if the item in the mainhand is a light level 15 item (solely used by the item parser)",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns true, if the item in the mainhand is a light level 6 item (Used by the item parser)",
"//comment": "This predicate returns true, if the item in the mainhand is a light level 6 item (solely used by the item parser)",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns true, if the item in the mainhand is a light level 9 item (Used by the item parser)",
"//comment": "This predicate returns true, if the item in the mainhand is a light level 9 item (solely used by the item parser)",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns false if the tested entity is holding a item that should extinguish inside water (Specified in tags/items/water_sensitive/turn_off)",
"//comment": "This predicate returns false if the tested entity is holding or wearing an item that should extinguish inside water (specified in tags/items/water_sensitive/turn_off)",
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns false if the tested entity is holding a item that should illuminate inside water (Specified in tags/items/water_sensitive/turn_on)",
"//comment": "This predicate returns false if the tested entity is holding or wearing an item that should illuminate inside water (specified in tags/items/water_sensitive/turn_on)",
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
Expand Down
1 change: 1 addition & 0 deletions data/dynamiclights/tags/entity_types/reparse.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"//comment": "These entities need special parsing and are dynamic item holders, meaning that they may change their item over time. They will get reparsed every 4 seconds by default.",
"//version_notice": "Only needed until 24w11a.",
"replace": false,
"values": [
"#dynamiclights:reparse_interactible",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"//comment": "These entities need special parsing and are dynamic item holders, meaning that they may change their item over time. They are interactible by players and should listen to player interact events.",
"//version_notice": "Only needed until 24w11a.",
"replace": false,
"values": [
"minecraft:item_frame",
Expand Down
8 changes: 8 additions & 0 deletions data/dynamiclights/tags/items/mod_support/light_level/15.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"//comment": "Items listed here will emit light level 15 - Intended to get populated by mods",
"replace": false,
"values": [
{"id": "#c:lanterns", "required": false},
{"id": "#c:lava_buckets", "required": false}
]
}
9 changes: 9 additions & 0 deletions data/dynamiclights/tags/items/mod_support/light_level/6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"//comment": "Items listed here will emit light level 6 - Intended to get populated by mods",
"replace": false,
"values": [
{"id": "#c:amethyst_blocks", "required": false},
{"id": "#forge:storage_blocks/amethyst", "required": false},
{"id": "#forge:nether_stars", "required": false}
]
}
9 changes: 9 additions & 0 deletions data/dynamiclights/tags/items/mod_support/light_level/9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"//comment": "Items listed here will emit light level 9 - Intended to get populated by mods",
"replace": false,
"values": [
{"id": "#c:glow_berries", "required": false},
{"id": "#c:glowstone_dusts", "required": false},
{"id": "#forge:rods/blaze", "required": false}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"//comment": "Items listed here will only emit light outside water - Intended to get populated by mods",
"replace": false,
"values": [
{"id": "#c:lava_buckets", "required": false}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"//comment": "Items listed here will only emit light inside water - Intended to get populated by mods",
"replace": false,
"values": [
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns true, if the item in the mainhand is a light level 15 item (Used by the item parser)",
"//comment": "This predicate returns true, if the item in the mainhand is a light level 15 item (solely used by the item parser)",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns true, if the item in the mainhand is a light level 6 item (Used by the item parser)",
"//comment": "This predicate returns true, if the item in the mainhand is a light level 6 item (solely used by the item parser)",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns true, if the item in the mainhand is a light level 9 item (Used by the item parser)",
"//comment": "This predicate returns true, if the item in the mainhand is a light level 9 item (solely used by the item parser)",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns false if the tested entity is holding a item that should extinguish inside water (Specified in tags/items/water_sensitive/turn_off)",
"//comment": "This predicate returns false if the tested entity is holding or wearing an item that should extinguish inside water (specified in tags/items/water_sensitive/turn_off)",
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns false if the tested entity is holding a item that should illuminate inside water (Specified in tags/items/water_sensitive/turn_on)",
"//comment": "This predicate returns false if the tested entity is holding or wearing an item that should illuminate inside water (specified in tags/items/water_sensitive/turn_on)",
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"//version_notice": "This advancement is not needed anymore, since item frame content is now checkable via the slot contents. Take a look at tags/entity_types/single_slot_entities.json.",
"criteria": {
"player_interacted": {
"trigger": "minecraft:impossible"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
##by Tschipcraft

summon armor_stand ~ ~ ~ {UUID:[I;-1030365714,1276464731,-2084950084,-395075115],NoGravity:1b,Silent:1b,Invulnerable:1b,Small:1b,Marker:1b,Invisible:1b,NoBasePlate:1b,Tags:["ts.dl.i.parser"],HandItems:[{id:"minecraft:structure_void",Count:1b},{}],DisabledSlots:4144959}

# Copy NBT data
execute as @s[type=minecraft:falling_block] run data modify entity c295ddee-4c15-4e5b-83ba-2fbce873a1d5 HandItems[0].id set from entity @s BlockState.Name
execute as @s[type=minecraft:block_display] run data modify entity c295ddee-4c15-4e5b-83ba-2fbce873a1d5 HandItems[0].id set from entity @s block_state.Name

execute as c295ddee-4c15-4e5b-83ba-2fbce873a1d5 run function dynamiclights:internal/sources/parse/main_exec

# Transfer scores
scoreboard players operation @s ts.dl.i.type = .global ts.dl.i.type
scoreboard players operation @s ts.dl.i.is_ench = .global ts.dl.i.is_ench
scoreboard players operation @s ts.dl.i.is_ameth = .global ts.dl.i.is_ameth
scoreboard players operation @s ts.dl.i.is_firea = .global ts.dl.i.is_firea
scoreboard players operation @s ts.dl.i.is_ript = .global ts.dl.i.is_ript
scoreboard players operation @s ts.dl.i.is_chann = .global ts.dl.i.is_chann

# Item frame checking is not neccessary anymore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#minecraft:trimmable_armor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"count": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"count": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#dynamiclights:light_level/15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#dynamiclights:light_level/6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#dynamiclights:light_level/9",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[
{
"//comment": "This predicate returns true if the item in the head should not light up, because the entity is inside water.",
"//comment": "This predicate returns true if the item in the contents slot should not light up, because the entity is inside water.",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#dynamiclights:water_sensitive/turn_off",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[
{
"//comment": "This predicate returns true if the item in the head should not light up, because the entity is outside water.",
"//comment": "This predicate returns true if the item in the contents slot should not light up, because the entity is outside water.",
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#dynamiclights:water_sensitive/turn_on",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns false if the tested entity is holding a item that should extinguish inside water (Specified in tags/items/water_sensitive/turn_off)",
"//comment": "This predicate returns false if the tested entity is holding or wearing an item that should extinguish inside water (specified in tags/items/water_sensitive/turn_off)",
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
Expand Down Expand Up @@ -40,6 +40,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#dynamiclights:water_sensitive/turn_off",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"//comment": "This predicate returns false if the tested entity is holding a item that should illuminate inside water (Specified in tags/items/water_sensitive/turn_on)",
"//comment": "This predicate returns false if the tested entity is holding or wearing an item that should illuminate inside water (specified in tags/items/water_sensitive/turn_on)",
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
Expand Down Expand Up @@ -40,6 +40,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "#dynamiclights:single_slot_entities",
"slots": {
"contents": {
"items": "#dynamiclights:water_sensitive/turn_on",
Expand Down
9 changes: 9 additions & 0 deletions overlay_35/data/dynamiclights/tags/entity_types/parse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"//comment": "These entities use a different NBT tag for storing their item and need special parsing for detection.",
"//version_notice": "Mentions for single slot entities are not needed here anymore since 24w11a. Instead, take a look at single_slot_entities.json.",
"replace": false,
"values": [
"minecraft:falling_block",
{"id": "minecraft:block_display", "required": false}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"//comment": "Single slot item holder entities that correctly expose their slots contents tag to check for light emitting items.",
"replace": false,
"values": [
"#minecraft:arrows",
"minecraft:trident",
"minecraft:item",
"minecraft:item_display",
"minecraft:item_frame",
"minecraft:glow_item_frame",
{"id": "minecraft:ominous_item_spawner", "required": false}
]
}

0 comments on commit c3efcb6

Please sign in to comment.