From 3d61925e5982f28ad9e7048aeb98b4d02b8b4727 Mon Sep 17 00:00:00 2001 From: Thanathor Date: Wed, 30 Aug 2023 21:13:15 +0200 Subject: [PATCH] fix EVERYTHING --- .../advancements/hit_furniture.json | 7 +++- .../advancements/hit_furniture_station.json | 7 +++- .../advancements/interact_with_furniture.json | 7 +++- .../advancements/place_furniture.json | 27 +++++++++------ .../advancements/use_paintbrush_on_horse.json | 7 +++- .../functions/break/destroy.mcfunction | 10 ++++++ .../functions/break/detect_hit.mcfunction | 6 +++- .../functions/break/drop_item.mcfunction | 5 +++ .../functions/break/find_main.mcfunction | 8 ++++- .../functions/break/process_hit.mcfunction | 11 +++++- .../functions/break/remove_block.mcfunction | 6 +++- .../break/remove_furniture_station.mcfunction | 4 +++ .../functions/interact/detect.mcfunction | 18 ++++------ .../interact/paint/detect.mcfunction | 9 +++-- .../interact/paint/process.mcfunction | 10 ++++-- .../functions/interact/process.mcfunction | 19 +++++++++++ .../functions/interact/sit/detect.mcfunction | 4 --- .../functions/interact/sit/process.mcfunction | 10 +++++- .../place/check_size/depth_loop.mcfunction | 5 +-- .../place/check_size/depth_offset.mcfunction | 2 +- .../place/check_size/depth_prep.mcfunction | 5 +-- .../place/check_size/height_loop.mcfunction | 5 +-- .../place/check_size/height_offset.mcfunction | 2 +- .../place/check_size/height_prep.mcfunction | 3 +- .../place/check_size/length_loop.mcfunction | 2 +- .../place/check_size/length_offset.mcfunction | 2 +- .../place/check_size/length_prep.mcfunction | 4 +-- .../functions/place/resolve_id.mcfunction | 5 +++ .../furniture_station}/hit.mcfunction | 4 ++- .../paintbrush/remove_from_horse.mcfunction | 8 ++++- .../paintbrush/return_from_horse.mcfunction | 8 +++++ .../paintbrush/used_on_horse.mcfunction | 9 +++-- .../technical/drop_horse_paintbrush.json | 29 ++++++++++++++++ .../tags/blocks/furniture_blocks.json | 6 ++++ .../templates/functions/template.mcfunction | 15 +++++--- gm4_furniture/generate.py | 34 +++++++++++++++---- 36 files changed, 252 insertions(+), 71 deletions(-) create mode 100644 gm4_furniture/data/gm4_furniture/functions/interact/process.mcfunction delete mode 100644 gm4_furniture/data/gm4_furniture/functions/interact/sit/detect.mcfunction rename gm4_furniture/data/gm4_furniture/functions/{interact/sawmill => technical/furniture_station}/hit.mcfunction (55%) create mode 100644 gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/return_from_horse.mcfunction create mode 100644 gm4_furniture/data/gm4_furniture/loot_tables/technical/drop_horse_paintbrush.json create mode 100644 gm4_furniture/data/gm4_furniture/tags/blocks/furniture_blocks.json diff --git a/gm4_furniture/data/gm4_furniture/advancements/hit_furniture.json b/gm4_furniture/data/gm4_furniture/advancements/hit_furniture.json index 3069fa9e28..3ee944c227 100644 --- a/gm4_furniture/data/gm4_furniture/advancements/hit_furniture.json +++ b/gm4_furniture/data/gm4_furniture/advancements/hit_furniture.json @@ -1,6 +1,6 @@ { "criteria": { - "requirement": { + "hit_furniture": { "trigger": "minecraft:player_hurt_entity", "conditions": { "player": [ @@ -31,6 +31,11 @@ } } }, + "requirements": [ + [ + "hit_furniture" + ] + ], "rewards": { "function": "gm4_furniture:break/detect_hit" } diff --git a/gm4_furniture/data/gm4_furniture/advancements/hit_furniture_station.json b/gm4_furniture/data/gm4_furniture/advancements/hit_furniture_station.json index 79082986d9..78384f632f 100644 --- a/gm4_furniture/data/gm4_furniture/advancements/hit_furniture_station.json +++ b/gm4_furniture/data/gm4_furniture/advancements/hit_furniture_station.json @@ -1,6 +1,6 @@ { "criteria": { - "requirement": { + "hit_furniture_station": { "trigger": "minecraft:player_hurt_entity", "conditions": { "player": [ @@ -31,6 +31,11 @@ } } }, + "requirements": [ + [ + "hit_furniture_station" + ] + ], "rewards": { "function": "gm4_furniture:interact/furniture_station/hit" } diff --git a/gm4_furniture/data/gm4_furniture/advancements/interact_with_furniture.json b/gm4_furniture/data/gm4_furniture/advancements/interact_with_furniture.json index f171a1b3de..6e4cb5a113 100644 --- a/gm4_furniture/data/gm4_furniture/advancements/interact_with_furniture.json +++ b/gm4_furniture/data/gm4_furniture/advancements/interact_with_furniture.json @@ -1,6 +1,6 @@ { "criteria": { - "requirement": { + "interact_with_furniture": { "trigger": "minecraft:player_interacted_with_entity", "conditions": { "player": [], @@ -17,6 +17,11 @@ } } }, + "requirements": [ + [ + "interact_with_furniture" + ] + ], "rewards": { "function": "gm4_furniture:interact/detect" } diff --git a/gm4_furniture/data/gm4_furniture/advancements/place_furniture.json b/gm4_furniture/data/gm4_furniture/advancements/place_furniture.json index ab8a39e6c8..9c9cfb9ad8 100644 --- a/gm4_furniture/data/gm4_furniture/advancements/place_furniture.json +++ b/gm4_furniture/data/gm4_furniture/advancements/place_furniture.json @@ -3,17 +3,6 @@ "placed_furniture": { "trigger": "minecraft:placed_block", "conditions": { - "location": [ - { - "condition": "minecraft:match_tool", - "predicate": { - "items": [ - "minecraft:player_head" - ], - "nbt": "{SkullOwner:{Properties:{textures:[{Signature:\"gm4_furniture\"}]}}}" - } - } - ], "player": [ { "condition": "minecraft:value_check", @@ -39,10 +28,26 @@ }, "range": 0 } + ], + "location": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": [ + "minecraft:player_head" + ], + "nbt": "{SkullOwner:{Properties:{textures:[{Signature:\"gm4_furniture\"}]}}}" + } + } ] } } }, + "requirements": [ + [ + "placed_furniture" + ] + ], "rewards": { "function": "gm4_furniture:place/place_furniture" } diff --git a/gm4_furniture/data/gm4_furniture/advancements/use_paintbrush_on_horse.json b/gm4_furniture/data/gm4_furniture/advancements/use_paintbrush_on_horse.json index 907c746189..48e4d2417f 100644 --- a/gm4_furniture/data/gm4_furniture/advancements/use_paintbrush_on_horse.json +++ b/gm4_furniture/data/gm4_furniture/advancements/use_paintbrush_on_horse.json @@ -1,6 +1,6 @@ { "criteria": { - "requirement": { + "used_paintbrush": { "trigger": "minecraft:player_interacted_with_entity", "conditions": { "player": [], @@ -22,6 +22,11 @@ } } }, + "requirements": [ + [ + "used_paintbrush" + ] + ], "rewards": { "function": "gm4_furniture:technical/paintbrush/used_on_horse" } diff --git a/gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction index 5e8dacea58..a30b1082d3 100644 --- a/gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction @@ -1,6 +1,16 @@ +# destroy this furniture +# @s = furniture main interaction entity +# at @s +# run from break/process_hit +# unless breaking player was in creative drop the item execute if score $creative gm4_furniture_data matches 0 positioned ~-0.4999 ~0.0001 ~-0.4999 as @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] run function gm4_furniture:break/drop_item with entity @s item.tag.data +# remove any furniture blocks that match the id execute as @e[type=interaction,tag=gm4_furniture,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id at @s run function gm4_furniture:break/remove_block + +# if the broken furniture was a furniture station run some extra code execute if entity @s[tag=gm4_furniture.furniture_station] run function gm4_furniture:break/remove_furniture_station + +# destroy sound playsound minecraft:entity.armor_stand.break block @a[distance=..8] ~ ~ ~ 1 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction index b81602e0ce..bef75ea63a 100644 --- a/gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction @@ -1,6 +1,10 @@ - +# detect hitting a furniture +# @s = player punching furniture +# at @s advancement revoke @s only gm4_furniture:hit_furniture +# mark if the player is in creative mode execute store success score $creative gm4_furniture_data if entity @s[gamemode=creative] +# locate the hit furniture execute as @e[type=interaction,tag=gm4_furniture,distance=..8] if data entity @s attack at @s run function gm4_furniture:break/find_main diff --git a/gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction index 1bc940ac4b..451d0698e8 100644 --- a/gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction @@ -1,2 +1,7 @@ +# drop destroyed furniture's item +# @s = furniture item display +# at @s +# run from break/destroy with @s item.tag.data +# $(loot_table) = loot table path for this furniture item $loot spawn ~.5 ~.25 ~.5 loot $(loot_table) diff --git a/gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction index 66fda88303..d57294c941 100644 --- a/gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction @@ -1,5 +1,11 @@ +# locate the main/central interaction for the hit furniture +# @s = furniture interaction that was hit +# at @s +# run from break/detect_hit -execute store result score $hit gm4_furniture_last_hit run time query gametime +# find a main furniture interaction entity matching the hit id 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 run function gm4_furniture:break/process_hit + +# cleanup data remove entity @s attack diff --git a/gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction index d0826bd81c..64acc9ca8c 100644 --- a/gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction @@ -1,10 +1,19 @@ +# process hit furniture +# @s = furniture main interaction entity +# at @s +# run from break/find_main +# check how much time has passed since the last hit (or ignore that if the player was in creative) +execute store result score $hit gm4_furniture_last_hit run time query gametime scoreboard players operation $check_break gm4_furniture_last_hit = $hit gm4_furniture_last_hit scoreboard players operation $check_break gm4_furniture_last_hit -= @s gm4_furniture_last_hit -execute if score $creative gm4_furniture_data matches 1 run scoreboard players set $check_break gm4_furniture_last_hit 0 +# if >=4 ticks have passed or player is in creative destroy furniture +execute if score $creative gm4_furniture_data matches 1 run scoreboard players set $check_break gm4_furniture_last_hit 0 execute if score $check_break gm4_furniture_last_hit matches ..4 run function gm4_furniture:break/destroy +# otherwise store this hit time in furniture's score for the next check execute unless score $check_break gm4_furniture_last_hit matches ..4 run scoreboard players operation @s gm4_furniture_last_hit = $hit gm4_furniture_last_hit +# hit sounds playsound minecraft:entity.armor_stand.hit block @a[distance=..8] ~ ~ ~ 1 1 playsound minecraft:entity.player.attack.strong block @a[distance=..8] ~ ~ ~ 1 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/break/remove_block.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/remove_block.mcfunction index 5451e91190..b9cc28bbd9 100644 --- a/gm4_furniture/data/gm4_furniture/functions/break/remove_block.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/break/remove_block.mcfunction @@ -1,4 +1,8 @@ +# remove this furniture block +# @s = furniture interaction entity +# at @s +# run from break/destroy -execute positioned ~0.0001 ~0.5001 ~0.0001 run setblock ~ ~ ~ air +execute positioned ~0.0001 ~0.5001 ~0.0001 run fill ~ ~ ~ ~ ~ ~ air replace #gm4_furniture:furniture_blocks execute positioned ~-0.4999 ~0.0001 ~-0.4999 run kill @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] kill @s diff --git a/gm4_furniture/data/gm4_furniture/functions/break/remove_furniture_station.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/remove_furniture_station.mcfunction index 318b91d687..a3ee35e5d4 100644 --- a/gm4_furniture/data/gm4_furniture/functions/break/remove_furniture_station.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/break/remove_furniture_station.mcfunction @@ -1,3 +1,7 @@ +# remove the flower pot and wandering trader when a furniture station is destroyed +# furniture station interaction entity +# at @s +# run from break/destroy setblock ~ ~2 ~ air execute as @e[type=wandering_trader,tag=gm4_furniture,distance=..4] if score @s gm4_furniture_id = $check_id gm4_furniture_id run tp @s ~ -100000 ~ diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction index c004bf23d1..2da973538f 100644 --- a/gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction @@ -1,13 +1,9 @@ - +# detect interacting (right-click) on furniture +# @s = player interacting with furniture +# at @s advancement revoke @s only gm4_furniture:interact_with_furniture -scoreboard players set $interaction_processed gm4_furniture_data 0 - -# check for painting -execute if predicate gm4_furniture:holding_paintbrush run function gm4_furniture:interact/paint/detect - -# check for sitting -execute if score $interaction_processed gm4_furniture_data matches 0 unless predicate gm4_furniture:holding_paintbrush run function gm4_furniture:interact/sit/detect - -# cleanup if nothing else triggered -execute if score $interaction_processed gm4_furniture_data matches 0 as @e[type=interaction,tag=gm4_furniture,distance=..8] if data entity @s interaction run data remove entity @s interaction +# find interaction entity that was interacted with +tag @s add gm4_furniture_target +execute as @e[type=interaction,tag=gm4_furniture,distance=..8] if data entity @s interaction at @s run function gm4_furniture:interact/process +tag @s remove gm4_furniture_target diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction index 0d1e010da4..e97b82c11c 100644 --- a/gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction @@ -1,4 +1,9 @@ +# detect interaction on paintable furniture by a player holding a paintbrush +# @s = furniture's interacted interaction entity +# at @s +# run from interact/process -data modify storage gm4_furniture:temp color set from entity @s SelectedItem.tag.display.color -execute if data storage gm4_furniture:temp color as @e[type=interaction,tag=gm4_furniture.dyable,distance=..8] if data entity @s interaction at @s run function gm4_furniture:interact/paint/process +# store color from paintbrush and process application if there is some +data modify storage gm4_furniture:temp color set from entity @p[tag=gm4_furniture_target] SelectedItem.tag.display.color +execute if data storage gm4_furniture:temp color run function gm4_furniture:interact/paint/process data remove storage gm4_furniture:temp color diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/paint/process.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/paint/process.mcfunction index dff5b0ca93..3692d4a962 100644 --- a/gm4_furniture/data/gm4_furniture/functions/interact/paint/process.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/interact/paint/process.mcfunction @@ -1,8 +1,12 @@ +# check if this furniture should be painted +# @s = furniture's interacted interaction entity +# at @s +# run from interact/paint/detect -scoreboard players set $interaction_processed gm4_furniture_data 1 - +# find this furniture's main interaction entity and try to paint its linked item display 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 -data remove entity @s interaction +# 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 +execute if score $paint_changed gm4_furniture_data matches 1 run scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/process.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/process.mcfunction new file mode 100644 index 0000000000..f48226a47f --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/process.mcfunction @@ -0,0 +1,19 @@ +# process interacting (right-click) on furniture +# @s = furniture's interacted interaction entity +# at @s +# run from itneract/detect + +# first successful interaction will be used, any lower down this list will be ignored +scoreboard players set $interaction_processed gm4_furniture_data 0 + +# check for custom interactions +# TODO + +# check for painting +execute if score $interaction_processed gm4_furniture_data matches 0 if entity @s[tag=gm4_furniture.dyable] if entity @p[tag=gm4_furniture_target,predicate=gm4_furniture:holding_paintbrush] run function gm4_furniture:interact/paint/detect + +# check for sitting +execute if score $interaction_processed gm4_furniture_data matches 0 if entity @s[tag=gm4_furniture.sittable] positioned ~-0.4999 ~0.0001 ~-0.4999 run function gm4_furniture:interact/sit/process + +# cleanup +data remove entity @s interaction diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/sit/detect.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/sit/detect.mcfunction deleted file mode 100644 index 5c08c1d110..0000000000 --- a/gm4_furniture/data/gm4_furniture/functions/interact/sit/detect.mcfunction +++ /dev/null @@ -1,4 +0,0 @@ - -tag @s add gm4_furniture_target -execute as @e[type=interaction,tag=gm4_furniture.sittable,distance=..8] if data entity @s interaction at @s positioned ~-0.4999 ~0.0001 ~-0.4999 run function gm4_furniture:interact/sit/process -tag @s remove gm4_furniture_target diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/sit/process.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/sit/process.mcfunction index 79357e0980..ac6d735ab5 100644 --- a/gm4_furniture/data/gm4_furniture/functions/interact/sit/process.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/interact/sit/process.mcfunction @@ -1,4 +1,12 @@ +# get interacting player to sit at this furniture block +# @s = furniture's interacted interaction entity +# at @s +# run from interact/process +# make player ride the linked item_display (if this is not the main interaction entity item_display will be invisible) +# the item_display is offset from the ground to dictate sit height ride @p[tag=gm4_furniture_target] dismount ride @p[tag=gm4_furniture_target] mount @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] -data remove entity @s interaction + +# mark interaction as resolved +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_loop.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_loop.mcfunction index 970119114e..634337b879 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_loop.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_loop.mcfunction @@ -9,5 +9,6 @@ execute if score $placement_blocked gm4_furniture_data matches 0 align y if enti execute if score $placement_blocked gm4_furniture_data matches 1 run return 0 summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]} -scoreboard players remove $depth gm4_furniture_data 1 -execute if score $depth gm4_furniture_data matches 1.. positioned ^ ^ ^1 run function gm4_furniture:place/check_size/depth_loop +scoreboard players add $depth_done gm4_furniture_data 1 +execute if score $depth_done gm4_furniture_data = $depth gm4_furniture_data run scoreboard players reset $depth_done gm4_furniture_data +execute if score $depth_done gm4_furniture_data < $depth gm4_furniture_data positioned ^ ^ ^-1 run function gm4_furniture:place/check_size/depth_loop diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_offset.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_offset.mcfunction index f5208954db..4a1672d2c4 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_offset.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_offset.mcfunction @@ -7,4 +7,4 @@ execute unless block ~ ~ ~ #gm4:replaceable run scoreboard players set $placement_blocked gm4_furniture_data 1 execute if score $placement_blocked gm4_furniture_data matches 0 align y if entity @e[type=interaction,tag=gm4_furniture,tag=!gm4_new_furniture,distance=..0.1] run scoreboard players set $placement_blocked gm4_furniture_data 1 execute if score $placement_blocked gm4_furniture_data matches 1 run return 0 -summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]} +summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block","gm4_furniture.depth_marker"]} diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_prep.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_prep.mcfunction index 233b64594d..40c789043b 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_prep.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_prep.mcfunction @@ -3,7 +3,8 @@ # at the center of the placed block rotated along axis to face towards player or away from the wall, or at any placed marker # run from any in place/furniture/ -execute if score $depth gm4_furniture_data matches 3.. at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^-1 run function gm4_furniture:place/check_size/depth_offset +execute as @e[type=marker,tag=gm4_furniture.marked_block] run data modify entity @s Rotation set from storage gm4_furniture:data Rotation +execute if score $depth gm4_furniture_data matches 3.. at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^1 run function gm4_furniture:place/check_size/depth_offset execute if score $depth gm4_furniture_data matches 3.. run scoreboard players remove $depth gm4_furniture_data 1 scoreboard players remove $depth gm4_furniture_data 1 -execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^1 run function gm4_furniture:place/check_size/depth_loop +execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block,tag=!gm4_furniture.depth_marker] positioned ^ ^ ^-1 run function gm4_furniture:place/check_size/depth_loop diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_loop.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_loop.mcfunction index 3583e0d548..db332140a0 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_loop.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_loop.mcfunction @@ -9,5 +9,6 @@ execute if score $placement_blocked gm4_furniture_data matches 0 align y if enti execute if score $placement_blocked gm4_furniture_data matches 1 run return 0 summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]} -scoreboard players remove $height gm4_furniture_data 1 -execute if score $height gm4_furniture_data matches 1.. positioned ^ ^ ^1 run function gm4_furniture:place/check_size/height_loop +scoreboard players add $height_done gm4_furniture_data 1 +execute if score $height_done gm4_furniture_data = $height gm4_furniture_data run scoreboard players reset $height_done gm4_furniture_data +execute if score $height_done gm4_furniture_data < $height gm4_furniture_data positioned ^ ^1 ^ run function gm4_furniture:place/check_size/height_loop diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_offset.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_offset.mcfunction index 7abdf623e8..60508397b7 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_offset.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_offset.mcfunction @@ -7,4 +7,4 @@ execute unless block ~ ~ ~ #gm4:replaceable run scoreboard players set $placement_blocked gm4_furniture_data 1 execute if score $placement_blocked gm4_furniture_data matches 0 align y if entity @e[type=interaction,tag=gm4_furniture,tag=!gm4_new_furniture,distance=..0.1] run scoreboard players set $placement_blocked gm4_furniture_data 1 execute if score $placement_blocked gm4_furniture_data matches 1 run return 0 -summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]} +summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block","gm4_furniture.height_marker"]} diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_prep.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_prep.mcfunction index c0df450528..ef1961bf4a 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_prep.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_prep.mcfunction @@ -4,7 +4,8 @@ # run from any in place/furniture/ # height is only offset down if this is a wall placed furniture (painting) +execute as @e[type=marker,tag=gm4_furniture.marked_block] run data modify entity @s Rotation set from storage gm4_furniture:data Rotation execute if score $height gm4_furniture_data matches 3.. if score $wall_only gm4_furniture_data matches 1 at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^-1 ^ run function gm4_furniture:place/check_size/height_offset execute if score $height gm4_furniture_data matches 3.. if score $wall_only gm4_furniture_data matches 1 run scoreboard players remove $height gm4_furniture_data 1 scoreboard players remove $height gm4_furniture_data 1 -execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^1 run function gm4_furniture:place/check_size/height_loop +execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block,tag=!gm4_furniture.height_marker] positioned ^ ^1 ^ run function gm4_furniture:place/check_size/height_loop diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_loop.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_loop.mcfunction index 6c204395bd..a795f21f7d 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_loop.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_loop.mcfunction @@ -10,4 +10,4 @@ execute if score $placement_blocked gm4_furniture_data matches 1 run return 0 summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]} scoreboard players remove $length gm4_furniture_data 1 -execute if score $length gm4_furniture_data matches 1.. positioned ^-1 ^ ^ run function gm4_furniture:place/check_size/length_loop +execute if score $length gm4_furniture_data matches 1.. positioned ^1 ^ ^ run function gm4_furniture:place/check_size/length_loop diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_offset.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_offset.mcfunction index cfa6d0b0b6..88193d1a8a 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_offset.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_offset.mcfunction @@ -7,5 +7,5 @@ execute unless block ~ ~ ~ #gm4:replaceable run scoreboard players set $placement_blocked gm4_furniture_data 1 execute if score $placement_blocked gm4_furniture_data matches 0 align y if entity @e[type=interaction,tag=gm4_furniture,tag=!gm4_new_furniture,distance=..0.1] run scoreboard players set $placement_blocked gm4_furniture_data 1 execute if score $placement_blocked gm4_furniture_data matches 1 run return 0 -summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]} +summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block","gm4_furniture.length_marker"]} scoreboard players remove $length gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_prep.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_prep.mcfunction index 9b178395af..3743a392ab 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_prep.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_prep.mcfunction @@ -3,6 +3,6 @@ # at the center of the placed block rotated along axis to face towards player or away from the wall # run from any in place/furniture/ -execute if score $length gm4_furniture_data matches 3.. positioned ^1 ^ ^ run function gm4_furniture:place/check_size/length_offset +execute if score $length gm4_furniture_data matches 3.. positioned ^-1 ^ ^ run function gm4_furniture:place/check_size/length_offset scoreboard players remove $length gm4_furniture_data 1 -execute if score $placement_blocked gm4_furniture_data matches 0 positioned ^-1 ^ ^ run function gm4_furniture:place/check_size/length_loop +execute if score $placement_blocked gm4_furniture_data matches 0 positioned ^1 ^ ^ run function gm4_furniture:place/check_size/length_loop diff --git a/gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction index 4b69b7f7f7..51bde6ff45 100644 --- a/gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction @@ -1,3 +1,8 @@ +# run the function belonging to the placed furniture +# @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 +# $(function) = function path (gm4_furniture:place/furniture/) $execute if score $rotation gm4_furniture_data matches 1 rotated 0 0 run function $(function) $execute if score $rotation gm4_furniture_data matches 2 rotated 90 0 run function $(function) diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/sawmill/hit.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/hit.mcfunction similarity index 55% rename from gm4_furniture/data/gm4_furniture/functions/interact/sawmill/hit.mcfunction rename to gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/hit.mcfunction index eff59e554b..52e4af20ab 100644 --- a/gm4_furniture/data/gm4_furniture/functions/interact/sawmill/hit.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/hit.mcfunction @@ -1,4 +1,6 @@ - +# when a player punches the top block of a furniture station swap the category +# @s = player hitting the furniture station wandering trader +# at @s advancement revoke @s only gm4_furniture:hit_furniture_station execute as @e[type=wandering_trader,tag=gm4_furniture.furniture_station,distance=..8,nbt={HurtTime:10s}] at @s run say hit diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/remove_from_horse.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/remove_from_horse.mcfunction index 692f215e64..a479ed1b05 100644 --- a/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/remove_from_horse.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/remove_from_horse.mcfunction @@ -1,3 +1,9 @@ +# remove paintbrush from horse if it is found +# @s = horse wearing a paintbrush as horse armor +# at unspecified +# run from main +data modify storage gm4_furniture:temp paintbrush_data set from entity @s ArmorItems[2].tag +loot spawn ~ ~1.6 ~ loot gm4_furniture:technical/drop_horse_paintbrush item replace entity @s horse.armor with air -loot spawn ~ ~1.6 ~ loot gm4_furniture:items/paintbrush +data remove storage gm4_furniture:temp paintbrush_data diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/return_from_horse.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/return_from_horse.mcfunction new file mode 100644 index 0000000000..cb2c9a7c24 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/return_from_horse.mcfunction @@ -0,0 +1,8 @@ +# return paintbrush from horse to player +# @s = horse equipped with paintbrush +# at @s +# run from technical/paintbrush/used_on_horse + +item replace entity @p[tag=gm4_furniture_target] weapon.mainhand with air +item replace entity @p[tag=gm4_furniture_target] weapon.mainhand from entity @s horse.armor +item replace entity @s horse.armor with air diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/used_on_horse.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/used_on_horse.mcfunction index 2b82b3c8d4..98f055b7ae 100644 --- a/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/used_on_horse.mcfunction +++ b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/used_on_horse.mcfunction @@ -1,9 +1,8 @@ - +# resolve paintbrush being equpped on a horse by right clicking +# @s = player that right clicked a horse with a paintbrush +# at @s advancement revoke @s only gm4_furniture:use_paintbrush_on_horse tag @s add gm4_furniture_target -execute as @e[type=horse,distance=..8] if data entity @s ArmorItems[2].tag{gm4_furniture:"paintbrush"} store success score $armor_replaced gm4_furniture_data run item replace entity @s horse.armor with air -execute if score $armor_replaced gm4_furniture_data matches 1 run item replace entity @s weapon.mainhand with air -execute if score $armor_replaced gm4_furniture_data matches 1 run loot replace entity @s weapon.mainhand loot gm4_furniture:items/paintbrush -scoreboard players reset $armor_replaced gm4_furniture_data +execute as @e[type=horse,distance=..8] if data entity @s ArmorItems[2].tag{gm4_furniture:"paintbrush"} run function gm4_furniture:technical/paintbrush/return_from_horse tag @s remove gm4_furniture_target diff --git a/gm4_furniture/data/gm4_furniture/loot_tables/technical/drop_horse_paintbrush.json b/gm4_furniture/data/gm4_furniture/loot_tables/technical/drop_horse_paintbrush.json new file mode 100644 index 0000000000..210273d024 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/loot_tables/technical/drop_horse_paintbrush.json @@ -0,0 +1,29 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:loot_table", + "name": "gm4_furniture:items/paintbrush", + "functions": [ + { + "function": "minecraft:copy_nbt", + "source": { + "type": "minecraft:storage", + "source": "gm4_furniture:temp" + }, + "ops": [ + { + "source": "paintbrush_data", + "target": "{}", + "op": "merge" + } + ] + } + ] + } + ] + } + ] +} diff --git a/gm4_furniture/data/gm4_furniture/tags/blocks/furniture_blocks.json b/gm4_furniture/data/gm4_furniture/tags/blocks/furniture_blocks.json new file mode 100644 index 0000000000..b9c4edb442 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/tags/blocks/furniture_blocks.json @@ -0,0 +1,6 @@ +{ + "values": [ + "minecraft:barrier", + "minecraft:light" + ] +} diff --git a/gm4_furniture/data/gm4_furniture/templates/functions/template.mcfunction b/gm4_furniture/data/gm4_furniture/templates/functions/template.mcfunction index 3e0421d3b4..32b9245fdb 100644 --- a/gm4_furniture/data/gm4_furniture/templates/functions/template.mcfunction +++ b/gm4_furniture/data/gm4_furniture/templates/functions/template.mcfunction @@ -2,10 +2,17 @@ # @s = player who placed the furniture player head # at the center of the placed block rotated along axis to face towards player or away from the wall # run from place/resolve_id +# this function was generated by generate.py # first perform checks to see if furniture fits where it was placed scoreboard players set $valid_placement gm4_furniture_data 1 +# store rotation in storage +execute if score $rotation gm4_furniture_data matches 1 run data modify storage gm4_furniture:data Rotation set value [0F,0F] +execute if score $rotation gm4_furniture_data matches 2 run data modify storage gm4_furniture:data Rotation set value [90F,0F] +execute if score $rotation gm4_furniture_data matches 3 run data modify storage gm4_furniture:data Rotation set value [180F,0F] +execute if score $rotation gm4_furniture_data matches 4 run data modify storage gm4_furniture:data Rotation set value [-90F,0F] + # wall only furniture must be placed on a wall scoreboard players set $wall_only gm4_furniture_data {{ wall_only }} execute if score $wall_only gm4_furniture_data matches 1 unless score $wall_placement gm4_furniture_data matches 1 run scoreboard players set $valid_placement gm4_furniture_data 0 @@ -13,14 +20,14 @@ execute if score $wall_only gm4_furniture_data matches 1 unless score $wall_plac # wall placed furniture is not allowed to have depth, if any size is bigger than 1 check if there is space scoreboard players set $length gm4_furniture_data {{ length }} scoreboard players set $depth gm4_furniture_data {{ depth }} -scoreboard players set $heigth gm4_furniture_data {{ heigth }} +scoreboard players set $height gm4_furniture_data {{ height }} execute if score $wall_placement gm4_furniture_data matches 1 if score $depth gm4_furniture_data matches 2.. run scoreboard players set $valid_placement gm4_furniture_data 0 scoreboard players set $placement_blocked gm4_furniture_data 0 execute if score $valid_placement gm4_furniture_data matches 1 if score $length gm4_furniture_data matches 2.. run function gm4_furniture:place/check_size/length_prep summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block","gm4_furniture.middle"]} setblock ~ ~ ~ air execute if score $valid_placement gm4_furniture_data matches 1 if score $depth gm4_furniture_data matches 2.. run function gm4_furniture:place/check_size/depth_prep -execute if score $valid_placement gm4_furniture_data matches 1 if score $heigth gm4_furniture_data matches 2.. run function gm4_furniture:place/check_size/heigth_prep +execute if score $valid_placement gm4_furniture_data matches 1 if score $height gm4_furniture_data matches 2.. run function gm4_furniture:place/check_size/height_prep kill @e[type=marker,tag=gm4_furniture.middle,distance=..2,limit=1,sort=nearest] execute if score $placement_blocked gm4_furniture_data matches 1 run scoreboard players set $valid_placement gm4_furniture_data 0 execute if score $placement_blocked gm4_furniture_data matches 1 run kill @e[type=marker,tag=gm4_furniture.marked_block] @@ -58,9 +65,7 @@ execute if score $sittable gm4_furniture_data matches 1.. store result entity @e 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]}} # 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] at @s run tp @s ~ ~ ~ 90 0 -execute if score $rotation gm4_furniture_data matches 3 as @e[tag=gm4_new_furniture,distance=..8] at @s run tp @s ~ ~ ~ 180 0 -execute if score $rotation gm4_furniture_data matches 4 as @e[tag=gm4_new_furniture,distance=..8] at @s run tp @s ~ ~ ~ -90 0 +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 playsound minecraft:block.barrel.close block @a[distance=..6] ~ ~ ~ 1 1.6 diff --git a/gm4_furniture/generate.py b/gm4_furniture/generate.py index 4c6c8b034d..5e663db1e1 100644 --- a/gm4_furniture/generate.py +++ b/gm4_furniture/generate.py @@ -2,7 +2,7 @@ class furnitures: - def __init__(self, technical_id, display_name, cmd, block_id="barrier", sittable=0, dyable=0, wall_only=0, length=1, depth=1, heigth=1, table=0, scale=1): + def __init__(self, technical_id, display_name, cmd, block_id="barrier", sittable=0, dyable=0, wall_only=0, length=1, depth=1, height=1, table=0, scale=1): self.technical_id = technical_id self.display_name = display_name self.cmd = cmd @@ -12,7 +12,7 @@ def __init__(self, technical_id, display_name, cmd, block_id="barrier", sittable self.dyable = dyable self.length = length self.depth = depth - self.heigth = heigth + self.height = height self.table = table self.scale = scale @@ -33,11 +33,11 @@ def beet_default(ctx: Context): furniture_list.append(furnitures( 'wooden_bench_2', 'Wooden Bench', 3420206, sittable=50, length=3)) furniture_list.append(furnitures( - 'dyable_armchair_1', 'Cloth Armchair', 3420207, sittable=1, dyable=1)) + 'dyable_armchair_1', 'Cloth Armchair', 3420207, sittable=50, dyable=1)) furniture_list.append(furnitures( - 'wooden_candelabra_1', 'Candelabra', 3420208, block_id="light[level=15]", dyable=1)) + 'wooden_3_candle_holder_1', 'Candelabra', 3420208, block_id="light[level=15]", dyable=1)) furniture_list.append(furnitures( - 'wooden_candelabra_2', 'Candelabra', 3420209, block_id="light[level=15]", dyable=1)) + 'wooden_5_candle_holder_1', 'Candelabra', 3420209, block_id="light[level=15]", dyable=1)) furniture_list.append(furnitures( 'dyable_stool_1', 'Ottoman', 3420210, sittable=50, dyable=1)) furniture_list.append(furnitures( @@ -46,6 +46,28 @@ def beet_default(ctx: Context): 'wooden_table_2', 'Wooden Table', 3420212, table=1)) furniture_list.append(furnitures( 'dyable_wooden_table_1', 'Wooden Table with Cloth', 3420213, dyable=1, table=1)) + furniture_list.append(furnitures( + 'dyable_wooden_sofa_1', 'Wooden Sofa with Cushions', 3420214, sittable=50, dyable=1, length=3)) + furniture_list.append(furnitures( + '2x1_log_seat_1', 'Log Bench', 3420215, sittable=50, length=2)) + furniture_list.append(furnitures( + '1x1_log_seat_1', 'Log Seat', 3420216, sittable=50)) + furniture_list.append(furnitures( + 'stone_frog_statue', 'Frog Statue', 3420217)) + furniture_list.append(furnitures( + 'wooden_wall_candle_holder_1', 'Wall Candle', 3420218, block_id="light[level=15]", dyable=1, wall_only=1)) + furniture_list.append(furnitures( + 'dyable_wooden_chair_1', 'Wooden Chair with Cushions', 3420219, sittable=50, dyable=1)) + furniture_list.append(furnitures( + 'gold_5_candle_holder_1', 'Gold Candelabra', 3420220, block_id="light[level=15]", dyable=1)) + furniture_list.append(furnitures( + 'gold_3_candle_holder_1', 'Gold Candelabra', 3420221, block_id="light[level=15]", dyable=1)) + furniture_list.append(furnitures( + 'iron_5_candle_holder_1', 'Iron Candelabra', 3420222, block_id="light[level=15]", dyable=1)) + furniture_list.append(furnitures( + 'iron_3_candle_holder_1', 'Iron Candelabra', 3420223, block_id="light[level=15]", dyable=1)) + furniture_list.append(furnitures( + '2x2_wooden_table_2', 'Wooden Table', 3420224, length=2, depth=2, table=1)) for furniture_data in furniture_list: @@ -72,7 +94,7 @@ def beet_default(ctx: Context): "dyable": furniture_data.dyable, "length": furniture_data.length, "depth": furniture_data.depth, - "heigth": furniture_data.heigth, + "height": furniture_data.height, "table": furniture_data.table, "scale": furniture_data.scale, }