Skip to content

Commit a942536

Browse files
committed
Fix Hologram Removal Not Respecting Item Frame Rotation
1 parent 4120368 commit a942536

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
# @s = hologram AEC if empty item frame is nearby
1+
# @s = hologram text display if empty item frame is nearby
2+
# at @s positioned ^ ^ ^-0.3 (block face the hologram was placed from)
23
# run from main
34

4-
data merge entity @e[type=#gm4_holographic_tags:item_frames,limit=1,sort=nearest,distance=..0.1] {Tags:["gm4_hologram"],Item:{id:"minecraft:name_tag",count:1,components:{"minecraft:repair_cost":0}}}
5-
data modify entity @e[type=#gm4_holographic_tags:item_frames,limit=1,sort=nearest,distance=..0.1] Item.components."minecraft:custom_name" set from entity @s text.text
5+
# prepare data to reduce selector count
6+
data modify storage gm4_holographic_tags:temp properties.rotation_hologram set from entity @s Rotation
7+
execute store result storage gm4_holographic_tags:temp properties.rotation_x_hologram int 1 run data get storage gm4_holographic_tags:temp properties.rotation_hologram[0]
8+
execute store result storage gm4_holographic_tags:temp properties.rotation_y_hologram int 1 run data get storage gm4_holographic_tags:temp properties.rotation_hologram[1]
9+
data modify storage gm4_holographic_tags:temp properties.text set from entity @s text.text
610

11+
# attempt move data from hologram to item frame, if destroy failed, also fail this function
12+
execute as @e[type=#gm4_holographic_tags:item_frames,limit=1,sort=nearest,distance=..0.1] unless function gm4_holographic_tags:read_hologram_data run return fail
13+
data remove storage gm4_holographic_tags:temp properties
14+
15+
# particles & hologram removal
716
particle minecraft:block{block_state:"minecraft:stripped_birch_log"} ~ ~ ~ .2 .2 .2 .1 10
817
kill @s
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Moves data from the hologram to the item frame, unless their rotations are different
2+
# @s = item frame ready to receive a nametag
3+
# at block face hologram was placed from
4+
# run from return_name_tag
5+
6+
# check if the rotation matches
7+
data modify storage gm4_holographic_tags:temp properties.rotation_item_frame set from entity @s Rotation
8+
execute store result storage gm4_holographic_tags:temp properties.rotation_x_item_frame int 1 run data get storage gm4_holographic_tags:temp properties.rotation_item_frame[0]
9+
execute store result storage gm4_holographic_tags:temp properties.rotation_y_item_frame int 1 run data get storage gm4_holographic_tags:temp properties.rotation_item_frame[1]
10+
11+
execute store success storage gm4_holographic_tags:temp properties.rotation_x_differs int 1 run data modify storage gm4_holographic_tags:temp properties.rotation_x_hologram set from storage gm4_holographic_tags:temp properties.rotation_x_item_frame
12+
execute if data storage gm4_holographic_tags:temp properties{rotation_x_differs:1} run return fail
13+
execute store success storage gm4_holographic_tags:temp properties.rotation_y_differs int 1 run data modify storage gm4_holographic_tags:temp properties.rotation_y_hologram set from storage gm4_holographic_tags:temp properties.rotation_y_item_frame
14+
execute if data storage gm4_holographic_tags:temp properties{rotation_y_differs:1} run return fail
15+
16+
17+
# rotation matched, move data
18+
data merge entity @s {Tags:["gm4_hologram"],Item:{id:"minecraft:name_tag",count:1,components:{"minecraft:repair_cost":0}}}
19+
data modify entity @s Item.components."minecraft:custom_name" set from storage gm4_holographic_tags:temp properties.text
20+
21+
# signal that data transfer was successful
22+
return 1

0 commit comments

Comments
 (0)