-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added "FrameModel" tag to fix issue #2
- Loading branch information
1 parent
d65344a
commit f91f992
Showing
9 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
data/custom_blocks/functions/item_frame/check_add_item_from_frame.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Checks if the item frame has a custom block placed by the player in it then updates the item | ||
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 | ||
|
||
|
15 changes: 15 additions & 0 deletions
15
data/custom_blocks/functions/item_frame/check_removed_item_from_frame.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Resets compare storage | ||
data remove storage custom_blocks:nbt_compare | ||
|
||
# Get nbt tags to compare and save result to #match in cbCompareResult | ||
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 | ||
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 | ||
|
||
# Update item back to its default state | ||
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 | ||
|
||
# Reset cbCompareResult and remove tag from item frame | ||
scoreboard players set #match cbCompareResult 1 | ||
execute as @e[type=#custom_blocks:item_frames,tag=updated,predicate=!custom_blocks:frame_item_player_placed] run tag @s remove updated | ||
|
||
|
10 changes: 10 additions & 0 deletions
10
data/custom_blocks/functions/item_frame/update_item_in_frame.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Called from item_frame_check.mcfunction | ||
|
||
# Updates item display for item frame and adds a tag to prevent loop | ||
data modify entity @s Item.tag.CustomModelDataNorm set from entity @s Item.tag.CustomModelData | ||
data modify entity @s Item.tag.CustomModelData set from entity @s Item.tag.BlockProperties.FrameModel | ||
data modify entity @s Item.tag.displayName set from entity @s Item.tag.display.Name | ||
data modify entity @s Item.tag.display.Name set value "" | ||
tag @s add updated | ||
|
||
|
9 changes: 9 additions & 0 deletions
9
data/custom_blocks/functions/item_frame/update_item_out_frame.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Called from check_removed_item_from_frame.mcfunction | ||
|
||
# Update item back to its default state | ||
data modify entity @s Item.tag.CustomModelData set from entity @s Item.tag.CustomModelDataNorm | ||
data modify entity @s Item.tag.display.Name set from entity @s Item.tag.displayName | ||
data remove entity @s Item.tag.CustomModelDataNorm | ||
data remove entity @s Item.tag.displayName | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
execute as @a run function custom_blocks:place/set_storage | ||
function custom_blocks:break/spawn_drop | ||
|
||
function custom_blocks:item_frame/check_add_item_from_frame | ||
function custom_blocks:item_frame/check_removed_item_from_frame | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
gamerule commandBlockOutput false | ||
gamerule logAdminCommands false | ||
|
||
|
||
scoreboard objectives add cbCompareResult dummy | ||
scoreboard players set #match cbCompareResult 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"condition": "entity_properties", | ||
"entity": "this", | ||
"predicate": { | ||
"nbt": "{Item:{tag:{BlockEntityTag:{Lock:\"CustomBlocks:Block\"}}}}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"values": [ | ||
"minecraft:item_frame", | ||
"minecraft:glow_item_frame" | ||
] | ||
} |