Skip to content

Commit

Permalink
file format improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
TheThanathor committed Sep 21, 2023
1 parent ded438e commit 167bc4d
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @s = furniture item display
# at @s
# run from break/destroy with @s item.tag.data
# $(technical_id) = furniture's technical_id
# $(furniture_id) = furniture's id

$loot spawn ~.5 ~.25 ~.5 loot gm4_furniture:furniture/$(technical_id)
$loot spawn ~.5 ~.25 ~.5 loot gm4_furniture:furniture/$(furniture_id)
execute if score $furniture_color gm4_furniture_data matches 1.. positioned ~.5 ~.25 ~.5 store result entity @e[type=item,limit=1,sort=nearest] Item.tag.gm4_furniture.color int 1 run scoreboard players get $furniture_color gm4_furniture_data
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# at @s
# run from interact/process

data modify storage gm4_furniture:temp technical_id set string entity @s CustomName 23 -2
# find this furniture's item_display and store its furniture_id
scoreboard players operation $check_id gm4_furniture_id = @s gm4_furniture_id
execute as @e[type=item_display,tag=gm4_furniture.display,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id run data modify storage gm4_furniture:temp furniture_id set from entity @s item.tag.data.furniture_id
# resolve function call
function gm4_furniture:interact/custom/resolve_function with storage gm4_furniture:temp
data remove storage gm4_furniture:temp technical_id
data remove storage gm4_furniture:temp furniture_id
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# @s = furniture's interacted interaction entity
# at @s
# run from interact/custom/process with storage gm4_furniture:temp
# $(techical_id) = technical_id
# $(furniture_id) = furniture_id

$function gm4_furniture:interact/custom/furniture/$(technical_id)
$function gm4_furniture:interact/custom/furniture/$(furniture_id)
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# at @s
# run from interact/paint/detect

# find this furniture's main interaction entity and try to paint its linked item display
# find this furniture's item_display and try to paint it
scoreboard players operation $check_id gm4_furniture_id = @s gm4_furniture_id
execute as @e[type=interaction,tag=gm4_furniture.main,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id at @s positioned ~-0.4999 ~0.0001 ~-0.4999 as @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] store success score $paint_changed gm4_furniture_data run data modify entity @s item.tag.display.color set from storage gm4_furniture:temp color
execute as @e[type=item_display,tag=gm4_furniture.display,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id store success score $paint_changed gm4_furniture_data run data modify entity @s item.tag.display.color set from storage gm4_furniture:temp color

# if furniture was painted mark interaction as resolved and play paint sound
execute if score $paint_changed gm4_furniture_data matches 1 run playsound item.dye.use player @a[distance=..8] ~ ~ ~ 1 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ execute if score $valid_placement gm4_furniture_data matches 0 run setblock ~ ~
execute if score $valid_placement gm4_furniture_data matches 0 run return 0

# spawn the furniture_station
summon item_display ~ ~-0.4999 ~ {Tags:["gm4_furniture","gm4_furniture.display","gm4_furniture.furniture_station","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.furniture_station"',item:{id:"leather_horse_armor",Count:1,tag:{data:{technical_id:"furniture_station"},CustomModelData:3420150}},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.5f,0f],scale:[1f,1f,1f]}}
summon item_display ~ ~-0.4999 ~ {Tags:["gm4_furniture","gm4_furniture.display","gm4_furniture.furniture_station","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.furniture_station"',item:{id:"leather_horse_armor",Count:1,tag:{data:{furniture_id:"furniture_station"},CustomModelData:3420150}},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.5f,0f],scale:[1f,1f,1f]}}
summon interaction ~-0.0001 ~-0.5001 ~-0.0001 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.furniture_station","gm4_furniture.main","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture.furniture_station"',height:1.0002f,width:1.0002f,response:1b}
summon interaction ^0.25 ^-0.5 ^0.26 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.furniture_station","gm4_furniture.swap_tool","gm4_furniture.next","gm4_furniture.additional","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture.furniture_station"',height:1f,width:0.5f,response:1b}
summon interaction ^-0.25 ^-0.5 ^0.26 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.furniture_station","gm4_furniture.swap_tool","gm4_furniture.prev","gm4_furniture.additional","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture.furniture_station"',height:1f,width:0.5f,response:1b}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# @s = player that just placed a furniture player head
# at the center of the furniture player head that was placed
# run from place/prep_place with storage gm4_furniture:temp furniture_data
# $(technical_id) = furniture's technical_id
# $(furniture_id) = furniture's id

$execute if score $rotation gm4_furniture_data matches 1 rotated 0 0 run function gm4_furniture:place/furniture/$(technical_id)
$execute if score $rotation gm4_furniture_data matches 2 rotated 90 0 run function gm4_furniture:place/furniture/$(technical_id)
$execute if score $rotation gm4_furniture_data matches 3 rotated 180 0 run function gm4_furniture:place/furniture/$(technical_id)
$execute if score $rotation gm4_furniture_data matches 4 rotated -90 0 run function gm4_furniture:place/furniture/$(technical_id)
$execute if score $rotation gm4_furniture_data matches 1 rotated 0 0 run function gm4_furniture:place/furniture/$(furniture_id)
$execute if score $rotation gm4_furniture_data matches 2 rotated 90 0 run function gm4_furniture:place/furniture/$(furniture_id)
$execute if score $rotation gm4_furniture_data matches 3 rotated 180 0 run function gm4_furniture:place/furniture/$(furniture_id)
$execute if score $rotation gm4_furniture_data matches 4 rotated -90 0 run function gm4_furniture:place/furniture/$(furniture_id)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# @s = furniture station wandering trader
# at @s
# run from technical/furniture_station/build_trades/build_trade with storage gm4_furniture:temp trade_data[0]
# $(technical_id) = furniture's technical_id
# $(furniture_id) = furniture's id

$loot replace block 29999998 1 7134 container.0 loot gm4_furniture:furniture/$(technical_id)
$loot replace block 29999998 1 7134 container.0 loot gm4_furniture:furniture/$(furniture_id)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"functions": [
{
"function": "set_nbt",
"tag": "{CustomModelData:3420150,gm4_furniture:{technical_id:\"furniture_station\"},SkullOwner:{Id:[I;1862739911,-1668725896,-1286726243,-1817885533],Name:\"furniture_station\",Properties:{textures:[{Signature:\"gm4_furniture\",Value:\"ewogICJ0aW1lc3RhbXAiIDogMTY5Mjg3NTg0Njc2OCwKICAicHJvZmlsZUlkIiA6ICJhNWZlYWViNDdhYjA0ZDZiYTk2ZjMyOGJjMDQ3MDZjMyIsCiAgInByb2ZpbGVOYW1lIiA6ICJYeW5kcmEyIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzMzMDU1YjMzMGVmZTY0ZTQxMmQxZDc4MTE5MTM5YzRkMTA3YjZlMDdkNmUyMGU5MTVkYWE5MjFlYTgzMDgwMiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9\"}]}}}"
"tag": "{CustomModelData:3420150,gm4_furniture:{furniture_id:\"furniture_station\"},SkullOwner:{Id:[I;1862739911,-1668725896,-1286726243,-1817885533],Name:\"furniture_station\",Properties:{textures:[{Signature:\"gm4_furniture\",Value:\"ewogICJ0aW1lc3RhbXAiIDogMTY5Mjg3NTg0Njc2OCwKICAicHJvZmlsZUlkIiA6ICJhNWZlYWViNDdhYjA0ZDZiYTk2ZjMyOGJjMDQ3MDZjMyIsCiAgInByb2ZpbGVOYW1lIiA6ICJYeW5kcmEyIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzMzMDU1YjMzMGVmZTY0ZTQxMmQxZDc4MTE5MTM5YzRkMTA3YjZlMDdkNmUyMGU5MTVkYWE5MjFlYTgzMDgwMiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9\"}]}}}"
},
{
"function": "minecraft:set_name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ execute if score $placement_blocked gm4_furniture_data matches 1 run scoreboard
execute if score $placement_blocked gm4_furniture_data matches 1 run kill @e[type=marker,tag=gm4_furniture.marked_block]

# if placement is not valid cancel placement
execute if score $valid_placement gm4_furniture_data matches 0 run loot spawn ~ ~ ~ loot gm4_furniture:furniture/{{ technical_id }}
execute if score $valid_placement gm4_furniture_data matches 0 run loot spawn ~ ~ ~ loot gm4_furniture:furniture/{{ category }}/{{ technical_id }}
execute if score $valid_placement gm4_furniture_data matches 0 run return 0

# set variables
Expand All @@ -46,18 +46,17 @@ scoreboard players set $table gm4_furniture_data {{ table }}
scoreboard players set $custom_interaction gm4_furniture_data {{ custom_interaction }}

# spawn the furniture
execute positioned ~ ~-0.4999 ~ run summon item_display ~ ~0.{{ sittable }} ~ {Tags:["gm4_furniture","gm4_furniture.display","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.{{ technical_id }}"',item:{id:"leather_horse_armor",Count:1,tag:{data:{technical_id:"{{ technical_id }}"},CustomModelData:{{ cmd }}}},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.5f,0f],scale:[{{ scale }}f,{{ scale }}f,{{ scale }}f]}}
summon interaction ~-0.0001 ~-0.5001 ~-0.0001 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.main","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture.{{ technical_id }}"',height:1.0002f,width:1.0002f,response:1b}
execute positioned ~ ~-0.4999 ~ run summon item_display ~ ~0.{{ sittable }} ~ {Tags:["gm4_furniture","gm4_furniture.display","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.{{ category }}.{{ technical_id }}"',item:{id:"leather_horse_armor",Count:1,tag:{data:{furniture_id:"{{ category }}/{{ technical_id }}"},CustomModelData:{{ cmd }}}},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.5f,0f],scale:[{{ scale }}f,{{ scale }}f,{{ scale }}f]}}
summon interaction ~-0.0001 ~-0.5001 ~-0.0001 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.main","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture.{{ category }}.{{ technical_id }}"',height:1.0002f,width:1.0002f,response:1b}
setblock ~ ~ ~ {{ block_id }}

# add placement tags
execute if score $wall_only gm4_furniture_data matches 1 run tag @e[type=interaction,tag=gm4_new_furniture] add gm4_furniture.on_wall
execute if score $ceiling_only gm4_furniture_data matches 1 run tag @e[type=interaction,tag=gm4_new_furniture] add gm4_furniture.on_ceiling

# spawn extensions if they exist and set id
execute at @e[type=marker,tag=gm4_furniture.marked_block] run summon interaction ~-0.0001 ~-0.5001 ~-0.0001 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.additional","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture.{{ technical_id }}"',height:1.0002f,width:1.0002f,response:1b}
# spawn extensions if they exist
execute at @e[type=marker,tag=gm4_furniture.marked_block] run summon interaction ~-0.0001 ~-0.5001 ~-0.0001 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.additional","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture.{{ category }}.{{ technical_id }}"',height:1.0002f,width:1.0002f,response:1b}
execute at @e[type=marker,tag=gm4_furniture.marked_block] run setblock ~ ~ ~ {{ block_id }}
execute store result score @e[type=interaction,tag=gm4_new_furniture] gm4_furniture_id run scoreboard players add $next_id gm4_furniture_id 1

# add custom interaction tags
execute if score $custom_interaction gm4_furniture_data matches 1 run tag @e[type=interaction,tag=gm4_new_furniture] add gm4_furniture.custom_interaction
Expand All @@ -73,14 +72,15 @@ execute if score $dyable gm4_furniture_data matches 1 run tag @e[type=interactio
execute if score $sittable gm4_furniture_data matches 1.. run tag @e[type=interaction,tag=gm4_new_furniture,distance=..8] add gm4_furniture.sittable
scoreboard players set $sit_height gm4_furniture_data 50
execute if score $sittable gm4_furniture_data matches 1.. store result entity @e[type=item_display,tag=gm4_new_furniture,distance=..2,limit=1,sort=nearest] transformation.translation[1] float 0.01 run scoreboard players operation $sit_height gm4_furniture_data -= $sittable gm4_furniture_data
execute if score $sittable gm4_furniture_data matches 1.. at @e[type=marker,tag=gm4_furniture.marked_block] positioned ~ ~-0.4999 ~ run summon item_display ~ ~0.{{ sittable }} ~ {Tags:["gm4_furniture","gm4_furniture.seat","gm4_furniture.sittable","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.{{ technical_id }}_seat"',item:{id:"air",Count:1},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[1f,1f,1f]}}
execute if score $sittable gm4_furniture_data matches 1.. at @e[type=marker,tag=gm4_furniture.marked_block] positioned ~ ~-0.4999 ~ run summon item_display ~ ~0.{{ sittable }} ~ {Tags:["gm4_furniture","gm4_furniture.seat","gm4_furniture.sittable","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.{{ category }}.{{ technical_id }}_seat"',item:{id:"air",Count:1},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0f,0f],scale:[1f,1f,1f]}}

# rotate furniture depending on rotation set by player (if rotation is 1 default rotation can be kept)
execute if score $rotation gm4_furniture_data matches 2.. as @e[tag=gm4_new_furniture,distance=..8] run data modify entity @s Rotation set from storage gm4_furniture:data Rotation

# mark block as placed
# mark block as placed and set id
playsound minecraft:block.barrel.close block @a[distance=..6] ~ ~ ~ 1 1.6
tag @e[distance=..2] remove gm4_new_furniture
execute store result score @e[tag=gm4_new_furniture] gm4_furniture_id run scoreboard players add $next_id gm4_furniture_id 1
tag @e[tag=gm4_new_furniture] remove gm4_new_furniture

# cleanup
kill @e[type=marker,tag=gm4_furniture.marked_block]
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{CustomModelData:{{ cmd }},gm4_furniture:{technical_id:\"{{ technical_id }}\",color:16383998},SkullOwner:{Name:\"{{ technical_id }}\"}}"
"tag": "{CustomModelData:{{ cmd }},gm4_furniture:{furniture_id:\"{{ category }}/{{ technical_id }}\",color:16383998},SkullOwner:{Name:\"{{ category }}.{{ technical_id }}\"}}"
},
{
"function": "minecraft:set_name",
"name": [
{
"translate": "block.gm4_furniture.gm4_{{ technical_id }}",
"translate": "block.gm4_furniture.{{ category }}.{{ technical_id }}",
"fallback": "{{ display_name }}",
"color": "white",
"italic": false
Expand Down
Loading

0 comments on commit 167bc4d

Please sign in to comment.