Skip to content

Commit f91f992

Browse files
Added "FrameModel" tag to fix issue #2
1 parent d65344a commit f91f992

File tree

9 files changed

+57
-1
lines changed

9 files changed

+57
-1
lines changed

data/custom_blocks/functions/break/spawn_drop.mcfunction

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ data remove storage custom_blocks:drop_block DisplayName
44
data remove storage custom_blocks:drop_block Lore
55
data remove storage custom_blocks:drop_block CustomModelData
66
data remove storage custom_blocks:drop_block CustomModelDataVertical
7+
data remove storage custom_blocks:drop_block FrameModel
78
data remove storage custom_blocks:drop_block CustomName
89
data remove storage custom_blocks:drop_block Tags
910
data remove storage custom_blocks:drop_block SetblockCommand
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Checks if the item frame has a custom block placed by the player in it then updates the item
2+
execute as @e[type=#custom_blocks:item_frames,tag=!updated,predicate=custom_blocks:frame_item_player_placed] run function custom_blocks:item_frame/update_item_in_frame
3+
4+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Resets compare storage
2+
data remove storage custom_blocks:nbt_compare
3+
4+
# Get nbt tags to compare and save result to #match in cbCompareResult
5+
execute at @e[type=#custom_blocks:item_frames,tag=updated,predicate=!custom_blocks:frame_item_player_placed] as @e[type=item,predicate=custom_blocks:is_placer,distance=..3,limit=1] run data modify storage custom_blocks:nbt_compare nbt set from entity @s Item.tag.CustomModelData
6+
execute store success score #match cbCompareResult at @e[type=#custom_blocks:item_frames,tag=updated,predicate=!custom_blocks:frame_item_player_placed] as @e[type=item,predicate=custom_blocks:is_placer,distance=..3,limit=1] run data modify storage custom_blocks:nbt_compare nbt set from entity @s Item.tag.BlockProperties.FrameModel
7+
8+
# Update item back to its default state
9+
execute if score #match cbCompareResult matches 0 at @e[type=#custom_blocks:item_frames,tag=updated,predicate=!custom_blocks:frame_item_player_placed] as @e[type=item,predicate=custom_blocks:is_placer,distance=..3,limit=1] run function custom_blocks:item_frame/update_item_out_frame
10+
11+
# Reset cbCompareResult and remove tag from item frame
12+
scoreboard players set #match cbCompareResult 1
13+
execute as @e[type=#custom_blocks:item_frames,tag=updated,predicate=!custom_blocks:frame_item_player_placed] run tag @s remove updated
14+
15+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Called from item_frame_check.mcfunction
2+
3+
# Updates item display for item frame and adds a tag to prevent loop
4+
data modify entity @s Item.tag.CustomModelDataNorm set from entity @s Item.tag.CustomModelData
5+
data modify entity @s Item.tag.CustomModelData set from entity @s Item.tag.BlockProperties.FrameModel
6+
data modify entity @s Item.tag.displayName set from entity @s Item.tag.display.Name
7+
data modify entity @s Item.tag.display.Name set value ""
8+
tag @s add updated
9+
10+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Called from check_removed_item_from_frame.mcfunction
2+
3+
# Update item back to its default state
4+
data modify entity @s Item.tag.CustomModelData set from entity @s Item.tag.CustomModelDataNorm
5+
data modify entity @s Item.tag.display.Name set from entity @s Item.tag.displayName
6+
data remove entity @s Item.tag.CustomModelDataNorm
7+
data remove entity @s Item.tag.displayName
8+
9+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
execute as @a run function custom_blocks:place/set_storage
22
function custom_blocks:break/spawn_drop
33

4+
function custom_blocks:item_frame/check_add_item_from_frame
5+
function custom_blocks:item_frame/check_removed_item_from_frame
6+
47

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
gamerule commandBlockOutput false
22
gamerule logAdminCommands false
33

4-
4+
scoreboard objectives add cbCompareResult dummy
5+
scoreboard players set #match cbCompareResult 1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"condition": "entity_properties",
3+
"entity": "this",
4+
"predicate": {
5+
"nbt": "{Item:{tag:{BlockEntityTag:{Lock:\"CustomBlocks:Block\"}}}}"
6+
}
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"values": [
3+
"minecraft:item_frame",
4+
"minecraft:glow_item_frame"
5+
]
6+
}

0 commit comments

Comments
 (0)