diff --git a/gm4_furniture/README.md b/gm4_furniture/README.md new file mode 100644 index 0000000000..7a86e8f4b7 --- /dev/null +++ b/gm4_furniture/README.md @@ -0,0 +1,6 @@ +# Furniture + +Add Furniture TODO: improve this readme! + +### Features +- Add Furniture diff --git a/gm4_furniture/beet.yaml b/gm4_furniture/beet.yaml new file mode 100644 index 0000000000..192709c4da --- /dev/null +++ b/gm4_furniture/beet.yaml @@ -0,0 +1,34 @@ +id: gm4_furniture +name: Furniture +version: 1.0.X + +data_pack: + load: . + +pipeline: + - gm4_furniture.generate + - gm4.plugins.extend.module + - gm4.plugins.include.lib_custom_crafters + - gm4.plugins.include.lib_forceload + +meta: + gm4: + versioning: + required: + lib_forceload: 1.1.0 + lib_custom_crafters: 3.0.0 + schedule_loops: + - main + - slow_clock + website: + description: Furniture! + recommended: [] + notes: + - Resourcepack is required for this module to work. + video: null + wiki: https://wiki.gm4.co/wiki/Furniture + credits: + Creator: + - Thanathor + Textures by: + - Kyrius diff --git a/gm4_furniture/data/gm4_custom_crafters/tags/functions/check_recipes.json b/gm4_furniture/data/gm4_custom_crafters/tags/functions/check_recipes.json new file mode 100644 index 0000000000..42a5c540cd --- /dev/null +++ b/gm4_furniture/data/gm4_custom_crafters/tags/functions/check_recipes.json @@ -0,0 +1,5 @@ +{ + "values": [ + "gm4_furniture:check_recipes" + ] +} diff --git a/gm4_furniture/data/gm4_furniture/advancements/crafted_furniture.json b/gm4_furniture/data/gm4_furniture/advancements/crafted_furniture.json new file mode 100644 index 0000000000..3845bae151 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/advancements/crafted_furniture.json @@ -0,0 +1,21 @@ +{ + "criteria": { + "requirement": { + "trigger": "minecraft:villager_trade", + "conditions": { + "villager": [ + { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "nbt": "{Tags:[\"gm4_furniture.furniture_station\"]}" + } + } + ] + } + } + }, + "rewards": { + "function": "gm4_furniture:interact/furniture_station/craft_furniture" + } +} diff --git a/gm4_furniture/data/gm4_furniture/advancements/hit_furniture.json b/gm4_furniture/data/gm4_furniture/advancements/hit_furniture.json new file mode 100644 index 0000000000..3ee944c227 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/advancements/hit_furniture.json @@ -0,0 +1,42 @@ +{ + "criteria": { + "hit_furniture": { + "trigger": "minecraft:player_hurt_entity", + "conditions": { + "player": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type_specific": { + "type": "player", + "gamemode": "adventure" + } + } + } + } + ], + "entity": [ + { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:interaction", + "nbt": "{Tags:[\"gm4_furniture\"]}" + } + } + ] + } + } + }, + "requirements": [ + [ + "hit_furniture" + ] + ], + "rewards": { + "function": "gm4_furniture:break/detect_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 new file mode 100644 index 0000000000..6e4cb5a113 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/advancements/interact_with_furniture.json @@ -0,0 +1,28 @@ +{ + "criteria": { + "interact_with_furniture": { + "trigger": "minecraft:player_interacted_with_entity", + "conditions": { + "player": [], + "entity": [ + { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:interaction", + "nbt": "{Tags:[\"gm4_furniture\"]}" + } + } + ] + } + } + }, + "requirements": [ + [ + "interact_with_furniture" + ] + ], + "rewards": { + "function": "gm4_furniture:interact/detect" + } +} diff --git a/gm4_furniture/data/gm4_furniture/advancements/lightning.json b/gm4_furniture/data/gm4_furniture/advancements/lightning.json new file mode 100644 index 0000000000..9261906448 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/advancements/lightning.json @@ -0,0 +1,10 @@ +{ + "criteria": { + "requirement": { + "trigger": "minecraft:lightning_strike" + } + }, + "rewards": { + "function": "gm4_furniture:technical/furniture_station/lightning/detect" + } +} diff --git a/gm4_furniture/data/gm4_furniture/advancements/place_furniture.json b/gm4_furniture/data/gm4_furniture/advancements/place_furniture.json new file mode 100644 index 0000000000..9c9cfb9ad8 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/advancements/place_furniture.json @@ -0,0 +1,54 @@ +{ + "criteria": { + "placed_furniture": { + "trigger": "minecraft:placed_block", + "conditions": { + "player": [ + { + "condition": "minecraft:value_check", + "value": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "gm4_furniture" + }, + "score": "load.status" + }, + "range": 1 + }, + { + "condition": "minecraft:value_check", + "value": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "gm4_furniture_minor" + }, + "score": "load.status" + }, + "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/relog.json b/gm4_furniture/data/gm4_furniture/advancements/relog.json new file mode 100644 index 0000000000..019862a51c --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/advancements/relog.json @@ -0,0 +1,25 @@ +{ + "criteria": { + "requirement": { + "trigger": "minecraft:location", + "conditions": { + "player": [ + { + "condition": "minecraft:value_check", + "value": { + "type": "minecraft:score", + "target": "this", + "score": "gm4_furniture_relog" + }, + "range": { + "min": 1 + } + } + ] + } + } + }, + "rewards": { + "function": "gm4_furniture:technical/relog" + } +} 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 new file mode 100644 index 0000000000..62927f151e --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/advancements/use_paintbrush_on_horse.json @@ -0,0 +1,33 @@ +{ + "criteria": { + "used_paintbrush": { + "trigger": "minecraft:player_interacted_with_entity", + "conditions": { + "player": [], + "item": { + "items": [ + "minecraft:leather_horse_armor" + ], + "nbt": "{gm4_furniture:paintbrush}" + }, + "entity": [ + { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "type": "minecraft:horse" + } + } + ] + } + } + }, + "requirements": [ + [ + "used_paintbrush" + ] + ], + "rewards": { + "function": "gm4_furniture:technical/paintbrush/used_on_horse" + } +} diff --git a/gm4_furniture/data/gm4_furniture/functions/break/decimal_to_hex.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/decimal_to_hex.mcfunction new file mode 100644 index 0000000000..8f776c64df --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/decimal_to_hex.mcfunction @@ -0,0 +1,70 @@ +# transform color value from decimal to hex +# @s = furniture main interaction entity +# at @s +# run from break/destroy + +data modify storage gm4_furniture:temp color_hex set value {} + +scoreboard players operation $red gm4_furniture_data = $furniture_color gm4_furniture_data +scoreboard players operation $red gm4_furniture_data /= #65536 gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data = $red gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data /= #16 gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 0..9 store result storage gm4_furniture:temp color_hex.red_1 int 1 run scoreboard players get $add_digit gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 10 run data modify storage gm4_furniture:temp color_hex.red_1 set value "A" +execute if score $add_digit gm4_furniture_data matches 11 run data modify storage gm4_furniture:temp color_hex.red_1 set value "B" +execute if score $add_digit gm4_furniture_data matches 12 run data modify storage gm4_furniture:temp color_hex.red_1 set value "C" +execute if score $add_digit gm4_furniture_data matches 13 run data modify storage gm4_furniture:temp color_hex.red_1 set value "D" +execute if score $add_digit gm4_furniture_data matches 14 run data modify storage gm4_furniture:temp color_hex.red_1 set value "E" +execute if score $add_digit gm4_furniture_data matches 15 run data modify storage gm4_furniture:temp color_hex.red_1 set value "F" +scoreboard players operation $add_digit gm4_furniture_data = $red gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data %= #16 gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 0..9 store result storage gm4_furniture:temp color_hex.red_2 int 1 run scoreboard players get $add_digit gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 10 run data modify storage gm4_furniture:temp color_hex.red_2 set value "A" +execute if score $add_digit gm4_furniture_data matches 11 run data modify storage gm4_furniture:temp color_hex.red_2 set value "B" +execute if score $add_digit gm4_furniture_data matches 12 run data modify storage gm4_furniture:temp color_hex.red_2 set value "C" +execute if score $add_digit gm4_furniture_data matches 13 run data modify storage gm4_furniture:temp color_hex.red_2 set value "D" +execute if score $add_digit gm4_furniture_data matches 14 run data modify storage gm4_furniture:temp color_hex.red_2 set value "E" +execute if score $add_digit gm4_furniture_data matches 15 run data modify storage gm4_furniture:temp color_hex.red_2 set value "F" + +scoreboard players operation $green gm4_furniture_data = $furniture_color gm4_furniture_data +scoreboard players operation $green gm4_furniture_data /= #256 gm4_furniture_data +scoreboard players operation $green gm4_furniture_data %= #256 gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data = $green gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data /= #16 gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 0..9 store result storage gm4_furniture:temp color_hex.green_1 int 1 run scoreboard players get $add_digit gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 10 run data modify storage gm4_furniture:temp color_hex.green_1 set value "A" +execute if score $add_digit gm4_furniture_data matches 11 run data modify storage gm4_furniture:temp color_hex.green_1 set value "B" +execute if score $add_digit gm4_furniture_data matches 12 run data modify storage gm4_furniture:temp color_hex.green_1 set value "C" +execute if score $add_digit gm4_furniture_data matches 13 run data modify storage gm4_furniture:temp color_hex.green_1 set value "D" +execute if score $add_digit gm4_furniture_data matches 14 run data modify storage gm4_furniture:temp color_hex.green_1 set value "E" +execute if score $add_digit gm4_furniture_data matches 15 run data modify storage gm4_furniture:temp color_hex.green_1 set value "F" +scoreboard players operation $add_digit gm4_furniture_data = $green gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data %= #16 gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 0..9 store result storage gm4_furniture:temp color_hex.green_2 int 1 run scoreboard players get $add_digit gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 10 run data modify storage gm4_furniture:temp color_hex.green_2 set value "A" +execute if score $add_digit gm4_furniture_data matches 11 run data modify storage gm4_furniture:temp color_hex.green_2 set value "B" +execute if score $add_digit gm4_furniture_data matches 12 run data modify storage gm4_furniture:temp color_hex.green_2 set value "C" +execute if score $add_digit gm4_furniture_data matches 13 run data modify storage gm4_furniture:temp color_hex.green_2 set value "D" +execute if score $add_digit gm4_furniture_data matches 14 run data modify storage gm4_furniture:temp color_hex.green_2 set value "E" +execute if score $add_digit gm4_furniture_data matches 15 run data modify storage gm4_furniture:temp color_hex.green_2 set value "F" + +scoreboard players operation $blue gm4_furniture_data = $furniture_color gm4_furniture_data +scoreboard players operation $blue gm4_furniture_data %= #256 gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data = $blue gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data /= #16 gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 0..9 store result storage gm4_furniture:temp color_hex.blue_1 int 1 run scoreboard players get $add_digit gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 10 run data modify storage gm4_furniture:temp color_hex.blue_1 set value "A" +execute if score $add_digit gm4_furniture_data matches 11 run data modify storage gm4_furniture:temp color_hex.blue_1 set value "B" +execute if score $add_digit gm4_furniture_data matches 12 run data modify storage gm4_furniture:temp color_hex.blue_1 set value "C" +execute if score $add_digit gm4_furniture_data matches 13 run data modify storage gm4_furniture:temp color_hex.blue_1 set value "D" +execute if score $add_digit gm4_furniture_data matches 14 run data modify storage gm4_furniture:temp color_hex.blue_1 set value "E" +execute if score $add_digit gm4_furniture_data matches 15 run data modify storage gm4_furniture:temp color_hex.blue_1 set value "F" +scoreboard players operation $add_digit gm4_furniture_data = $blue gm4_furniture_data +scoreboard players operation $add_digit gm4_furniture_data %= #16 gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 0..9 store result storage gm4_furniture:temp color_hex.blue_2 int 1 run scoreboard players get $add_digit gm4_furniture_data +execute if score $add_digit gm4_furniture_data matches 10 run data modify storage gm4_furniture:temp color_hex.blue_2 set value "A" +execute if score $add_digit gm4_furniture_data matches 11 run data modify storage gm4_furniture:temp color_hex.blue_2 set value "B" +execute if score $add_digit gm4_furniture_data matches 12 run data modify storage gm4_furniture:temp color_hex.blue_2 set value "C" +execute if score $add_digit gm4_furniture_data matches 13 run data modify storage gm4_furniture:temp color_hex.blue_2 set value "D" +execute if score $add_digit gm4_furniture_data matches 14 run data modify storage gm4_furniture:temp color_hex.blue_2 set value "E" +execute if score $add_digit gm4_furniture_data matches 15 run data modify storage gm4_furniture:temp color_hex.blue_2 set value "F" diff --git a/gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction new file mode 100644 index 0000000000..e4c73cad76 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction @@ -0,0 +1,25 @@ +# destroy this furniture +# @s = furniture main interaction entity +# at @s +# run from break/process_hit +# run from break/lost_connection + +# check if furniture had color data +execute store result score $furniture_color gm4_furniture_data positioned ~-0.4999 ~0.0001 ~-0.4999 run data get entity @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] item.tag.display.color +execute if score $furniture_color gm4_furniture_data matches 16383998 run scoreboard players reset $furniture_color gm4_furniture_data +execute if score $furniture_color gm4_furniture_data matches 1.. run function gm4_furniture:break/decimal_to_hex + +# unless breaking player was in creative drop the item +execute unless score $creative gm4_furniture_data matches 1 positioned ~-0.4999 ~0.0001 ~-0.4999 as @e[type=item_display,tag=gm4_furniture.display,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 + +# cleanup +scoreboard players reset $furniture_color gm4_furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction new file mode 100644 index 0000000000..8e69fb24be --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction @@ -0,0 +1,15 @@ +# 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] + +# mark if the player is holding a paintbrush in their mainhand +execute store success score $get_color gm4_furniture_data if entity @s[predicate=gm4_furniture:holding_paintbrush] + +# locate the hit furniture +tag @s add gm4_furniture_target +execute as @e[type=interaction,tag=gm4_furniture,distance=..8] if data entity @s attack at @s run function gm4_furniture:break/find_main +tag @s remove gm4_furniture_target diff --git a/gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction new file mode 100644 index 0000000000..97eb239ecc --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction @@ -0,0 +1,8 @@ +# drop destroyed furniture's item +# @s = furniture item display +# at @s +# run from break/destroy with @s item.tag.data +# $(furniture_id) = furniture's 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 diff --git a/gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction new file mode 100644 index 0000000000..d57294c941 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction @@ -0,0 +1,11 @@ +# locate the main/central interaction for the hit furniture +# @s = furniture interaction that was hit +# at @s +# run from break/detect_hit + +# 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/get_color.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/get_color.mcfunction new file mode 100644 index 0000000000..a4814b477d --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/get_color.mcfunction @@ -0,0 +1,11 @@ +# get the color of the broken furnitur +# @s = furniture main interaction entity +# at @s +# run from break/process_hit + +# find this furniture's item_display and get its color +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 store result storage gm4_furniture:temp color int 1 run data get entity @s item.tag.display.color + +item modify entity @p[tag=gm4_furniture_target] weapon.mainhand gm4_furniture:get_color +playsound item.dye.use player @a[distance=..8] ~ ~ ~ 1 1.15 diff --git a/gm4_furniture/data/gm4_furniture/functions/break/lost_connection.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/lost_connection.mcfunction new file mode 100644 index 0000000000..a892acfa2b --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/lost_connection.mcfunction @@ -0,0 +1,8 @@ +# destroy furniture if it loses its required connection to the wall / ceiling +# @s = furniture's main interaction entity +# at @s +# run from main + +scoreboard players set $creative gm4_furniture_data 0 +scoreboard players operation $check_id gm4_furniture_id = @s gm4_furniture_id +function gm4_furniture:break/destroy diff --git a/gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction b/gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction new file mode 100644 index 0000000000..b58fed496d --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction @@ -0,0 +1,23 @@ +# process hit furniture +# @s = furniture main interaction entity +# at @s +# run from break/find_main + +# if player is holding the paintbrush instead grab the color and stop this function +execute if score $get_color gm4_furniture_data matches 1 if entity @s[tag=gm4_furniture.painted] run function gm4_furniture:break/get_color +execute if score $get_color gm4_furniture_data matches 1 run return 0 + +# 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 + +# 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 new file mode 100644 index 0000000000..6d01fbb788 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/remove_block.mcfunction @@ -0,0 +1,9 @@ +# remove this furniture block +# @s = furniture interaction entity +# at @s +# run from break/destroy + +execute positioned ~0.0001 ~0.5001 ~0.0001 run fill ~ ~ ~ ~ ~ ~ air replace #gm4_furniture:furniture_blocks[waterlogged=false] +execute positioned ~0.0001 ~0.5001 ~0.0001 run fill ~ ~ ~ ~ ~ ~ water replace #gm4_furniture:furniture_blocks[waterlogged=true] +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 new file mode 100644 index 0000000000..f57da5b79e --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/break/remove_furniture_station.mcfunction @@ -0,0 +1,9 @@ +# remove the villager when a furniture station is destroyed +# furniture station interaction entity +# at @s +# run from break/destroy + +setblock ~ ~1 ~ air +fill ~ ~2 ~ ~ ~2 ~ air replace light[level=0] +execute as @e[type=villager,tag=gm4_furniture,distance=..4] if score @s gm4_furniture_id = $check_id gm4_furniture_id run tp @s ~ -100000 ~ +execute positioned ~-0.4999 ~0.0001 ~-0.4999 run kill @e[type=item_display,tag=gm4_furniture.tool,dx=0,dy=0,dz=0] diff --git a/gm4_furniture/data/gm4_furniture/functions/check_recipes.mcfunction b/gm4_furniture/data/gm4_furniture/functions/check_recipes.mcfunction new file mode 100644 index 0000000000..8189b9066e --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/check_recipes.mcfunction @@ -0,0 +1,5 @@ +# @s = custom crafter running recipes +# run from #gm4_custom_crafters:check_recipes + +execute if score $crafted gm4_crafting matches 0 store success score $crafted gm4_crafting if score $slot_count gm4_crafting matches 5 if data storage gm4_custom_crafters:temp/crafter {Items:[{Slot:0b,id:"minecraft:string"},{Slot:1b,id:"minecraft:string"},{Slot:2b,id:"minecraft:string"},{Slot:4b,id:"minecraft:iron_ingot"},{Slot:7b,id:"minecraft:stick"}]} run loot replace block ~ ~ ~ container.0 loot gm4_furniture:crafting/paintbrush +execute if score $crafted gm4_crafting matches 0 store success score $crafted gm4_crafting if score $slot_count gm4_crafting matches 8 if data storage gm4_custom_crafters:temp/crafter {Items:[{Slot:0b,item_tags:{minecraft:{planks:1b}}},{Slot:1b,id:"minecraft:crafting_table"},{Slot:2b,item_tags:{minecraft:{planks:1b}}},{Slot:3b,item_tags:{minecraft:{planks:1b}}},{Slot:4b,id:"minecraft:iron_ingot"},{Slot:5b,item_tags:{minecraft:{planks:1b}}},{Slot:6b,item_tags:{minecraft:{planks:1b}}},{Slot:8b,item_tags:{minecraft:{planks:1b}}}]} run loot replace block ~ ~ ~ container.0 loot gm4_furniture:crafting/furniture_station diff --git a/gm4_furniture/data/gm4_furniture/functions/init.mcfunction b/gm4_furniture/data/gm4_furniture/functions/init.mcfunction new file mode 100644 index 0000000000..701d1085fa --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/init.mcfunction @@ -0,0 +1,30 @@ +execute unless score furniture gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Furniture"} +execute unless score furniture gm4_earliest_version < furniture gm4_modules run scoreboard players operation furniture gm4_earliest_version = furniture gm4_modules +scoreboard players set furniture gm4_modules 1 + +scoreboard objectives add gm4_furniture_data dummy +scoreboard objectives add gm4_furniture_last_hit dummy +scoreboard objectives add gm4_furniture_id dummy +scoreboard objectives add gm4_furniture_index dummy +scoreboard objectives add gm4_furniture_craft_sound_time dummy +scoreboard objectives add gm4_furniture_sit_height dummy +scoreboard objectives add gm4_furniture_relog custom:leave_game + +scoreboard players set #2 gm4_furniture_data 2 +scoreboard players set #16 gm4_furniture_data 16 +scoreboard players set #256 gm4_furniture_data 256 +scoreboard players set #65536 gm4_furniture_data 65536 + +team add gm4_furniture_nocol +team modify gm4_furniture_nocol collisionRule never + +# build furniture station trade data +data modify storage gm4_furniture:data furniture_station set value [] +function gm4_furniture:generate_trades +execute store result score $max_index gm4_furniture_index run data get storage gm4_furniture:data furniture_station +scoreboard players remove $max_index gm4_furniture_index 1 + +schedule function gm4_furniture:main 1t +schedule function gm4_furniture:slow_clock 1t + +#$moduleUpdateList diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_allay.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_allay.mcfunction new file mode 100644 index 0000000000..504cf2eae2 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_allay.mcfunction @@ -0,0 +1,7 @@ +# 2% chance to play an animal sound +# @s = furniture's interacted interaction entity +# at @s +# run from interact/custom/resolve_function + +execute if predicate gm4_furniture:chance/animal_statue_sound run playsound entity.allay.ambient_without_item block @a[distance=..16] ~ ~ ~ 1 0.95 +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_axolotl.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_axolotl.mcfunction new file mode 100644 index 0000000000..e72098445a --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_axolotl.mcfunction @@ -0,0 +1,7 @@ +# 2% chance to play an animal sound +# @s = furniture's interacted interaction entity +# at @s +# run from interact/custom/resolve_function + +execute if predicate gm4_furniture:chance/animal_statue_sound run playsound entity.axolotl.idle_water block @a[distance=..16] ~ ~ ~ 1 0.95 +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_bee.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_bee.mcfunction new file mode 100644 index 0000000000..58f945547e --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_bee.mcfunction @@ -0,0 +1,7 @@ +# 2% chance to play an animal sound +# @s = furniture's interacted interaction entity +# at @s +# run from interact/custom/resolve_function + +execute if predicate gm4_furniture:chance/animal_statue_sound run playsound entity.bee.loop block @a[distance=..16] ~ ~ ~ 1 0.95 +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_frog.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_frog.mcfunction new file mode 100644 index 0000000000..89b0942fdb --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_frog.mcfunction @@ -0,0 +1,7 @@ +# 2% chance to play an animal sound +# @s = furniture's interacted interaction entity +# at @s +# run from interact/custom/resolve_function + +execute if predicate gm4_furniture:chance/animal_statue_sound run playsound entity.frog.ambient block @a[distance=..16] ~ ~ ~ 1 0.95 +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_pufferfish.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_pufferfish.mcfunction new file mode 100644 index 0000000000..090e1247ea --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/custom/furniture/stone_set/statues_pufferfish.mcfunction @@ -0,0 +1,7 @@ +# 2% chance to play an animal sound +# @s = furniture's interacted interaction entity +# at @s +# run from interact/custom/resolve_function + +execute if predicate gm4_furniture:chance/animal_statue_sound run playsound entity.puffer_fish.ambient block @a[distance=..16] ~ ~ ~ 1 0.95 +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/custom/process.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/custom/process.mcfunction new file mode 100644 index 0000000000..2ac2520901 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/custom/process.mcfunction @@ -0,0 +1,11 @@ +# process custom furniture interactions +# @s = furniture's interacted interaction entity +# at @s +# run from interact/process + +# 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 furniture_id diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/custom/resolve_function.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/custom/resolve_function.mcfunction new file mode 100644 index 0000000000..18f7a830d7 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/custom/resolve_function.mcfunction @@ -0,0 +1,7 @@ +# resolve which furniture was interacted with +# @s = furniture's interacted interaction entity +# at @s +# run from interact/custom/process with storage gm4_furniture:temp +# $(furniture_id) = furniture_id + +$function gm4_furniture:interact/custom/furniture/$(furniture_id) diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction new file mode 100644 index 0000000000..2da973538f --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction @@ -0,0 +1,9 @@ +# detect interacting (right-click) on furniture +# @s = player interacting with furniture +# at @s +advancement revoke @s only gm4_furniture:interact_with_furniture + +# 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/furniture_station/craft_furniture.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/furniture_station/craft_furniture.mcfunction new file mode 100644 index 0000000000..35579155d4 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/furniture_station/craft_furniture.mcfunction @@ -0,0 +1,8 @@ +# player furniture crafting sound +# @s = furniture's interacted interaction entity +# at @s +advancement revoke @s only gm4_furniture:crafted_furniture + +execute store result score $current_time gm4_furniture_data run time query gametime +execute as @a[distance=..16] unless score @s gm4_furniture_craft_sound_time = $current_time gm4_furniture_data run playsound minecraft:entity.villager.work_fletcher block @s ~ ~ ~ 1 1.25 +execute as @a[distance=..16] run scoreboard players operation @s gm4_furniture_craft_sound_time = $current_time gm4_furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/furniture_station/swap_tool.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/furniture_station/swap_tool.mcfunction new file mode 100644 index 0000000000..337f6ccd25 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/furniture_station/swap_tool.mcfunction @@ -0,0 +1,19 @@ +# get interacting player to sit at this furniture block +# @s = furniture's interacted interaction entity +# at @s align xyz +# run from interact/process + +# if furniture station was inactive activate first +execute as @e[type=interaction,tag=gm4_furniture.reactivate,dx=0,dy=0,dz=0] at @s run function gm4_furniture:technical/furniture_station/activation/turn_active + +# move index up/down +execute if entity @s[tag=gm4_furniture.next] run scoreboard players add @e[type=villager,tag=gm4_furniture.furniture_station,dx=0,dy=0,dz=0,limit=1] gm4_furniture_index 1 +execute if entity @s[tag=gm4_furniture.prev] run scoreboard players remove @e[type=villager,tag=gm4_furniture.furniture_station,dx=0,dy=0,dz=0,limit=1] gm4_furniture_index 1 +execute as @e[type=villager,tag=gm4_furniture.furniture_station,dx=0,dy=0,dz=0,limit=1] at @s run function gm4_furniture:technical/furniture_station/build_trades/prep + +# store new index on main interaction entity +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 run scoreboard players operation @s gm4_furniture_index = $store_index gm4_furniture_data + +# mark interaction as resolved +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction new file mode 100644 index 0000000000..e97b82c11c --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction @@ -0,0 +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 + +# 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 new file mode 100644 index 0000000000..03a3e27ace --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/paint/process.mcfunction @@ -0,0 +1,14 @@ +# check if this furniture should be painted +# @s = furniture's interacted interaction entity +# at @s +# run from interact/paint/detect + +# find this furniture's item_display and try to paint it +scoreboard players operation $check_id gm4_furniture_id = @s gm4_furniture_id +scoreboard players set $paint_changed gm4_furniture_data 0 +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 +execute if score $paint_changed gm4_furniture_data matches 1 run scoreboard players set $interaction_processed gm4_furniture_data 1 +execute if score $paint_changed gm4_furniture_data matches 1 as @e[type=interaction,tag=gm4_furniture.main,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id run tag @s add gm4_furniture.painted 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..d725e63068 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/process.mcfunction @@ -0,0 +1,28 @@ +# 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 reactivating furniture tables +execute if score $interaction_processed gm4_furniture_data matches 0 if entity @s[tag=gm4_furniture.reactivate] run function gm4_furniture:technical/furniture_station/activation/turn_active + +# check for waterlogging +execute if score $interaction_processed gm4_furniture_data matches 0 if entity @p[tag=gm4_furniture_target,predicate=gm4_furniture:holding_bucket] positioned ~ ~0.5 ~ run function gm4_furniture:interact/waterlog/check + +# check for furniture station interactions +execute if score $interaction_processed gm4_furniture_data matches 0 if entity @s[tag=gm4_furniture.swap_tool] align xyz run function gm4_furniture:interact/furniture_station/swap_tool + +# 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[scores={gm4_furniture_sit_height=1..}] if entity @p[tag=gm4_furniture_target,predicate=!gm4_furniture:is_sneaking] positioned ~-0.4999 ~0.0001 ~-0.4999 run function gm4_furniture:interact/sit/find_seat + +# check for custom interactions +execute if score $interaction_processed gm4_furniture_data matches 0 if entity @s[tag=gm4_furniture.custom_interaction] run function gm4_furniture:interact/custom/process + +# cleanup +data remove entity @s interaction diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/sit/check.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/sit/check.mcfunction new file mode 100644 index 0000000000..be6464dd80 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/sit/check.mcfunction @@ -0,0 +1,9 @@ +# check if this seat entity still has an occupant, if not remove it +# @s = furniture's seat item_display entity +# at unspecified +# run from interact/sit/find_seat +# run from slow_clock + +scoreboard players set $keep_seat gm4_furniture_data 0 +execute on passengers run scoreboard players set $keep_seat gm4_furniture_data 1 +execute if score $keep_seat gm4_furniture_data matches 0 run kill @s diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/sit/find_seat.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/sit/find_seat.mcfunction new file mode 100644 index 0000000000..a25dfcc7de --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/sit/find_seat.mcfunction @@ -0,0 +1,19 @@ +# get interacting player to sit at this furniture block +# @s = furniture's interacted interaction entity +# at @s +# run from interact/process + +# check if a seat already exists, if so do not allow sitting +execute as @e[type=item_display,tag=gm4_furniture.seat,dx=0,dy=0,dz=0] run function gm4_furniture:interact/sit/check +execute if entity @e[type=item_display,tag=gm4_furniture.seat,dx=0,dy=0,dz=0] run return 0 + +# spawn a seat for the player to sit on +ride @p[tag=gm4_furniture_target] dismount +execute store result storage gm4_furniture:temp sit.height int 1 run scoreboard players get @s gm4_furniture_sit_height +function gm4_furniture:interact/sit/spawn_seat with storage gm4_furniture:temp sit + +# mark interaction as resolved +scoreboard players set $interaction_processed gm4_furniture_data 1 + +# cleanup +data remove storage gm4_furniture:temp sit diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/sit/init_seat.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/sit/init_seat.mcfunction new file mode 100644 index 0000000000..67503580af --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/sit/init_seat.mcfunction @@ -0,0 +1,7 @@ +# init seat with data and make player ride it +# @s = furniture's seat item_display entity +# at @s +# run from interact/sit/spawn_seat + +data merge entity @s {Tags:["gm4_furniture","gm4_furniture.seat","smithed.entity","smithed.strict"],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]}} +ride @p[tag=gm4_furniture_target] mount @s diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/sit/spawn_seat.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/sit/spawn_seat.mcfunction new file mode 100644 index 0000000000..c1f80f0159 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/sit/spawn_seat.mcfunction @@ -0,0 +1,7 @@ +# spawn the seat in the correct place +# @s = furniture's seat item_display entity +# at @s +# run from interact/sit/find_seat + +# the item_display is offset from the ground to dictate sit height +$execute positioned ~.5 ~.$(height) ~.5 summon item_display run function gm4_furniture:interact/sit/init_seat diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/check.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/check.mcfunction new file mode 100644 index 0000000000..b3cc27cc81 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/check.mcfunction @@ -0,0 +1,7 @@ +# check if the furniture should waterlog or water-unlog +# @s = furniture's interacted interaction entity +# at @s +# run from interact/process + +execute if block ~ ~ ~ #gm4_furniture:furniture_blocks[waterlogged=true] if entity @p[tag=gm4_furniture_target,predicate=gm4_furniture:holding_empty_bucket] run function gm4_furniture:interact/waterlog/unlog +execute if score $interaction_processed gm4_furniture_data matches 0 if block ~ ~ ~ #gm4_furniture:furniture_blocks[waterlogged=false] if entity @p[tag=gm4_furniture_target,predicate=gm4_furniture:holding_water_bucket] run function gm4_furniture:interact/waterlog/log diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/log.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/log.mcfunction new file mode 100644 index 0000000000..647f7052f5 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/log.mcfunction @@ -0,0 +1,28 @@ +# waterlog this part of the furniture +# @s = furniture's interacted interaction entity +# at @s +# run from interact/waterlog/check + +item replace entity @p[tag=gm4_furniture_target,gamemode=!creative] weapon.mainhand with bucket + +scoreboard players set $waterlog_completed gm4_furniture_data 0 +execute store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=0,waterlogged=true] replace light[level=0] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ barrier[waterlogged=true] replace barrier +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=15,waterlogged=true] replace light[level=15] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=14,waterlogged=true] replace light[level=14] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=13,waterlogged=true] replace light[level=13] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=12,waterlogged=true] replace light[level=12] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=11,waterlogged=true] replace light[level=11] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=10,waterlogged=true] replace light[level=10] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=9,waterlogged=true] replace light[level=9] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=8,waterlogged=true] replace light[level=8] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=7,waterlogged=true] replace light[level=7] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=6,waterlogged=true] replace light[level=6] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=5,waterlogged=true] replace light[level=5] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=4,waterlogged=true] replace light[level=4] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=3,waterlogged=true] replace light[level=3] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=2,waterlogged=true] replace light[level=2] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=1,waterlogged=true] replace light[level=1] + +playsound item.bucket.empty player @a[distance=..16] ~ ~ ~ 1 1 +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/unlog.mcfunction b/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/unlog.mcfunction new file mode 100644 index 0000000000..64b0f25b3d --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/interact/waterlog/unlog.mcfunction @@ -0,0 +1,28 @@ +# water-unlog this part of the furniture +# @s = furniture's interacted interaction entity +# at @s +# run from interact/waterlog/check + +item replace entity @p[tag=gm4_furniture_target,gamemode=!creative] weapon.mainhand with water_bucket + +scoreboard players set $waterlog_completed gm4_furniture_data 0 +execute store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=0,waterlogged=false] replace light[level=0,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ barrier[waterlogged=false] replace barrier[waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=15,waterlogged=false] replace light[level=15,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=14,waterlogged=false] replace light[level=14,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=13,waterlogged=false] replace light[level=13,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=12,waterlogged=false] replace light[level=12,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=11,waterlogged=false] replace light[level=11,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=10,waterlogged=false] replace light[level=10,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=9,waterlogged=false] replace light[level=9,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=8,waterlogged=false] replace light[level=8,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=7,waterlogged=false] replace light[level=7,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=6,waterlogged=false] replace light[level=6,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=5,waterlogged=false] replace light[level=5,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=4,waterlogged=false] replace light[level=4,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=3,waterlogged=false] replace light[level=3,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=2,waterlogged=false] replace light[level=2,waterlogged=true] +execute if score $waterlog_completed gm4_furniture_data matches 0 store success score $waterlog_completed gm4_furniture_data run fill ~ ~ ~ ~ ~ ~ light[level=1,waterlogged=false] replace light[level=1,waterlogged=true] + +playsound item.bucket.fill player @a[distance=..16] ~ ~ ~ 1 1 +scoreboard players set $interaction_processed gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/main.mcfunction b/gm4_furniture/data/gm4_furniture/functions/main.mcfunction new file mode 100644 index 0000000000..0014f1e3b5 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/main.mcfunction @@ -0,0 +1,8 @@ +schedule function gm4_furniture:main 8t + +# check horses, remove paintbrushes that have been equipped +execute as @e[type=horse,nbt={ArmorItems:[{tag:{gm4_furniture:"paintbrush"}}]}] at @s run function gm4_furniture:technical/paintbrush/remove_from_horse + +# check furniture placements +execute as @e[type=interaction,tag=gm4_furniture.on_wall] at @s if block ^ ^0.5 ^-1 #gm4:replaceable run function gm4_furniture:break/lost_connection +execute as @e[type=interaction,tag=gm4_furniture.on_ceiling] at @s if block ^ ^1.5 ^ #gm4:replaceable run function gm4_furniture:break/lost_connection diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_diagonal_placement.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_diagonal_placement.mcfunction new file mode 100644 index 0000000000..6d055ce5ce --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_diagonal_placement.mcfunction @@ -0,0 +1,26 @@ +# checks for placement of furniture that is allowed to be placed diagonally +# @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 any in place/furniture/ + +scoreboard players set $diag_found gm4_furniture_data 0 +execute if block ~ ~ ~ player_head[rotation=1] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [-157.5F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=2] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [-135F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=3] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [-112.5F,0F] + +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=5] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [-67.5F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=6] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [-45F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=7] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [-22.5F,0F] + +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=9] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [22.5F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=10] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [45F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=11] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [67.5F,0F] + +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=13] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [112.5F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=14] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [135F,0F] +execute if score $diag_found gm4_furniture_data matches 0 if block ~ ~ ~ player_head[rotation=15] store success score $diag_found gm4_furniture_data run data modify storage gm4_furniture:data Rotation set value [157.5F,0F] + +# if a diagonal rotation was found make sure rotation will be set, and limit length / height to 1 +execute if score $diag_found gm4_furniture_data matches 1 run scoreboard players set $rotation gm4_furniture_data 5 +execute if score $diag_found gm4_furniture_data matches 1 run scoreboard players set $length gm4_furniture_data 1 +execute if score $diag_found gm4_furniture_data matches 1 run scoreboard players set $depth gm4_furniture_data 1 diff --git a/gm4_furniture/data/gm4_furniture/functions/place/check_layer.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/check_layer.mcfunction new file mode 100644 index 0000000000..9a49ee6582 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_layer.mcfunction @@ -0,0 +1,68 @@ +# replaces any furniture player heads with their corresponding furniture +# @s = player that just placed a furniture player head +# at @s rotated positioned ^-4 ^X ^-1, X = layer number - 4 +# run from place/place_furniture + +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^ ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^1 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^2 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^3 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^4 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^5 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^6 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^7 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^8 ^ ^ if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place + +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^ ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^1 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^2 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^3 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^4 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^5 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^6 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^7 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^8 ^ ^1 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place + +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^ ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^1 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^2 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^3 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^4 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^5 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^6 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^7 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^8 ^ ^2 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place + +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^ ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^1 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^2 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^3 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^4 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^5 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^6 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^7 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^8 ^ ^3 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place + +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^ ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^1 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^2 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^3 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^4 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^5 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^6 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^7 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^8 ^ ^4 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place + +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^ ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^1 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^2 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^3 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^4 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^5 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^6 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^7 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place +execute if score $player_head_count gm4_furniture_data matches 1.. positioned ^8 ^ ^5 if block ~ ~ ~ #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} run function gm4_furniture:place/prep_place + + +scoreboard players add $layer_count gm4_furniture_data 1 +execute if score $player_head_count gm4_furniture_data matches 1.. if score $layer_count gm4_furniture_data matches ..10 positioned ~ ~1 ~ run function gm4_furniture:place/check_layer 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 new file mode 100644 index 0000000000..1bf10cf2cb --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_loop.mcfunction @@ -0,0 +1,15 @@ +# check if furniture fits here +# @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, positioned ^ ^ ^x +# run from place/check_size/depth_prep +# run from here + +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"]} + +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 $wall_only gm4_furniture_data matches 0 if score $depth_done gm4_furniture_data < $depth gm4_furniture_data positioned ^ ^ ^-1 run function gm4_furniture:place/check_size/depth_loop +execute if score $wall_only gm4_furniture_data matches 1 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 new file mode 100644 index 0000000000..e4fc2ba2ae --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_offset.mcfunction @@ -0,0 +1,10 @@ +# check if furniture fits here +# @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, positioned ^ ^ ^x +# run from place/check_size/depth_prep +# run from here + +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","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 new file mode 100644 index 0000000000..b226ea3360 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/depth_prep.mcfunction @@ -0,0 +1,11 @@ +# check if furniture fits here +# @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, or at any placed marker +# run from any in place/furniture/ + +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.. if score $wall_only gm4_furniture_data matches 0 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.. if score $wall_only gm4_furniture_data matches 0 run scoreboard players remove $depth gm4_furniture_data 1 +scoreboard players remove $depth gm4_furniture_data 1 +execute if score $wall_only gm4_furniture_data matches 0 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 +execute if score $wall_only gm4_furniture_data matches 1 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 new file mode 100644 index 0000000000..e10445d0e3 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_loop.mcfunction @@ -0,0 +1,15 @@ +# check if furniture fits here +# @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, positioned ^ ^x ^ +# run from place/check_size/height_prep +# run from here + +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"]} + +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 $ceiling_only gm4_furniture_data matches 0 if score $height_done gm4_furniture_data < $height gm4_furniture_data positioned ^ ^1 ^ run function gm4_furniture:place/check_size/height_loop +execute if score $ceiling_only gm4_furniture_data matches 1 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 new file mode 100644 index 0000000000..dfa23474b1 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_offset.mcfunction @@ -0,0 +1,10 @@ +# check if furniture fits here +# @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, positioned ^ ^x ^ +# run from place/check_size/height_prep +# run from here + +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","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 new file mode 100644 index 0000000000..c32229bea4 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/height_prep.mcfunction @@ -0,0 +1,12 @@ +# check if furniture fits here +# @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, or at any placed marker +# 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 if score $ceiling_only gm4_furniture_data matches 0 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 if score $ceiling_only gm4_furniture_data matches 0 run scoreboard players remove $height gm4_furniture_data 1 +scoreboard players remove $height gm4_furniture_data 1 +execute if score $ceiling_only gm4_furniture_data matches 0 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 +execute if score $ceiling_only gm4_furniture_data matches 1 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 new file mode 100644 index 0000000000..a795f21f7d --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_loop.mcfunction @@ -0,0 +1,13 @@ +# check if furniture fits here +# @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, positioned ^x ^ ^ +# run from place/check_size/length_prep +# run from here + +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"]} + +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 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 new file mode 100644 index 0000000000..88193d1a8a --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_offset.mcfunction @@ -0,0 +1,11 @@ +# check if furniture fits here +# @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, positioned ^x ^ ^ +# run from place/check_size/length_prep +# run from here + +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","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 new file mode 100644 index 0000000000..3743a392ab --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/check_size/length_prep.mcfunction @@ -0,0 +1,8 @@ +# check if furniture fits here +# @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 any in place/furniture/ + +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 diff --git a/gm4_furniture/data/gm4_furniture/functions/place/count_heads/east.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/east.mcfunction new file mode 100644 index 0000000000..2425a603fa --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/east.mcfunction @@ -0,0 +1,27 @@ +# counts the number of players heads +# @s = player that just placed a furniture player head +# at @s +# run from place/place_furniture + +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~-4 ~-4 ~4 ~-4 ~4 ~-1 ~-4 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~-3 ~-4 ~4 ~-3 ~4 ~-1 ~-3 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~-2 ~-4 ~4 ~-2 ~4 ~-1 ~-2 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~-1 ~-4 ~4 ~-1 ~4 ~-1 ~-1 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~ ~-4 ~4 ~ ~4 ~-1 ~ ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~1 ~-4 ~4 ~1 ~4 ~-1 ~1 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~2 ~-4 ~4 ~2 ~4 ~-1 ~2 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~3 ~-4 ~4 ~3 ~4 ~-1 ~3 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~4 ~-4 ~4 ~4 ~4 ~-1 ~4 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~5 ~-4 ~4 ~5 ~4 ~-1 ~5 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-1 ~6 ~-4 ~4 ~6 ~4 ~-1 ~6 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/place/count_heads/north.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/north.mcfunction new file mode 100644 index 0000000000..7803ff3c6a --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/north.mcfunction @@ -0,0 +1,27 @@ +# counts the number of players heads +# @s = player that just placed a furniture player head +# at @s +# run from place/place_furniture + +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-4 ~-4 ~4 ~-4 ~1 ~-4 ~-4 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-3 ~-4 ~4 ~-3 ~1 ~-4 ~-3 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-2 ~-4 ~4 ~-2 ~1 ~-4 ~-2 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-1 ~-4 ~4 ~-1 ~1 ~-4 ~-1 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~ ~-4 ~4 ~ ~1 ~-4 ~ ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~1 ~-4 ~4 ~1 ~1 ~-4 ~1 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~2 ~-4 ~4 ~2 ~1 ~-4 ~2 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~3 ~-4 ~4 ~3 ~1 ~-4 ~3 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~4 ~-4 ~4 ~4 ~1 ~-4 ~4 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~5 ~-4 ~4 ~5 ~1 ~-4 ~5 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~6 ~-4 ~4 ~6 ~1 ~-4 ~6 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/place/count_heads/south.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/south.mcfunction new file mode 100644 index 0000000000..079d88568c --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/south.mcfunction @@ -0,0 +1,27 @@ +# counts the number of players heads +# @s = player that just placed a furniture player head +# at @s +# run from place/place_furniture + +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-4 ~-1 ~4 ~-4 ~4 ~-4 ~-4 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-3 ~-1 ~4 ~-3 ~4 ~-4 ~-3 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-2 ~-1 ~4 ~-2 ~4 ~-4 ~-2 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-1 ~-1 ~4 ~-1 ~4 ~-4 ~-1 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~ ~-1 ~4 ~ ~4 ~-4 ~ ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~1 ~-1 ~4 ~1 ~4 ~-4 ~1 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~2 ~-1 ~4 ~2 ~4 ~-4 ~2 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~3 ~-1 ~4 ~3 ~4 ~-4 ~3 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~4 ~-1 ~4 ~4 ~4 ~-4 ~4 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~5 ~-1 ~4 ~5 ~4 ~-4 ~5 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~6 ~-1 ~4 ~6 ~4 ~-4 ~6 ~-1 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/place/count_heads/west.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/west.mcfunction new file mode 100644 index 0000000000..4cb670ccfc --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/count_heads/west.mcfunction @@ -0,0 +1,27 @@ +# counts the number of players heads +# @s = player that just placed a furniture player head +# at @s +# run from place/place_furniture + +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-4 ~-4 ~1 ~-4 ~4 ~-4 ~-4 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-3 ~-4 ~1 ~-3 ~4 ~-4 ~-3 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-2 ~-4 ~1 ~-2 ~4 ~-4 ~-2 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~-1 ~-4 ~1 ~-1 ~4 ~-4 ~-1 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~ ~-4 ~1 ~ ~4 ~-4 ~ ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~1 ~-4 ~1 ~1 ~4 ~-4 ~1 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~2 ~-4 ~1 ~2 ~4 ~-4 ~2 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~3 ~-4 ~1 ~3 ~4 ~-4 ~3 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~4 ~-4 ~1 ~4 ~4 ~-4 ~4 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~5 ~-4 ~1 ~5 ~4 ~-4 ~5 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data +execute store result score $player_head_add gm4_furniture_data run clone ~-4 ~6 ~-4 ~1 ~6 ~4 ~-4 ~6 ~-4 filtered #gm4_furniture:player_heads{SkullOwner:{Properties:{textures:[{Signature:"gm4_furniture"}]}}} force +scoreboard players operation $player_head_count gm4_furniture_data += $player_head_add gm4_furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/place/furniture/furniture_station.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/furniture/furniture_station.mcfunction new file mode 100644 index 0000000000..91c01ab3de --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/furniture/furniture_station.mcfunction @@ -0,0 +1,48 @@ +# try to place the furniture_station +# @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 + +# first perform checks to see if furniture fits where it was placed +scoreboard players set $valid_placement gm4_furniture_data 1 +execute unless block ~ ~1 ~ #gm4:replaceable run scoreboard players set $valid_placement gm4_furniture_data 0 +execute positioned ~ ~1 ~ align y if entity @e[type=interaction,tag=gm4_furniture,tag=!gm4_new_furniture,distance=..0.1] run scoreboard players set $valid_placement gm4_furniture_data 0 + +execute if score $placement_blocked gm4_furniture_data matches 1 run return 0 + +# if placement is not valid cancel placement +execute if score $valid_placement gm4_furniture_data matches 0 run loot spawn ~ ~ ~ loot gm4_furniture:items/furniture_station +execute if score $valid_placement gm4_furniture_data matches 0 run setblock ~ ~ ~ air +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:{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"],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"],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"],height:1f,width:0.5f,response:1b} +summon item_display ~ ~-0.4999 ~ {Tags:["gm4_furniture","gm4_furniture.furniture_station","gm4_furniture.tool","gm4_furniture.tool_main","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.furniture_station_tool"',item:{id:"command_block",Count:1,tag:{CustomModelData:3420201}},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.6f,0f],scale:[1f,1f,1f]}} +summon item_display ~ ~-0.4999 ~ {Tags:["gm4_furniture","gm4_furniture.furniture_station","gm4_furniture.tool","gm4_furniture.tool_next","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.furniture_station_tool"',item:{id:"command_block",Count:1,tag:{CustomModelData:3420201}},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0.28125f,-0.45312f,0.5f],scale:[1f,1f,1f]}} +summon item_display ~ ~-0.4999 ~ {Tags:["gm4_furniture","gm4_furniture.furniture_station","gm4_furniture.tool","gm4_furniture.tool_prev","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'"gm4_furniture_display.furniture_station_tool"',item:{id:"command_block",Count:1,tag:{CustomModelData:3420201}},item_display:head,Rotation:[0.0f,0.0f],transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[-0.28125f,-0.45312f,0.5f],scale:[1f,1f,1f]}} +data modify entity @e[type=item_display,tag=gm4_new_furniture,tag=gm4_furniture.tool_main,limit=1,distance=..2] item.tag.CustomModelData set from storage gm4_furniture:data furniture_station[0].cmd +data modify entity @e[type=item_display,tag=gm4_new_furniture,tag=gm4_furniture.tool_next,limit=1,distance=..2] item.tag.CustomModelData set from storage gm4_furniture:data furniture_station[1].cmd +data modify entity @e[type=item_display,tag=gm4_new_furniture,tag=gm4_furniture.tool_prev,limit=1,distance=..2] item.tag.CustomModelData set from storage gm4_furniture:data furniture_station[-1].cmd +setblock ~ ~ ~ barrier + +# spawn villager and set ids +summon villager ~ ~1000 ~ {VillagerData:{level:99},Invulnerable:1b,Team:"gm4_furniture_nocol",Tags:["gm4_furniture","gm4_furniture.furniture_station","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'{"translate":"gm4.second","fallback":"%1$s","with":[{"translate":"container.gm4.furniture_station","fallback":"Furniture Station"},[{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:offscreen"},{"translate":"gui.gm4.furniture_station","fallback":"","font":"gm4:container_gui","color":"white"},{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:furniture","color":"#404040"}]]}',NoAI:1b,Silent:1b,active_effects:[{id:"minecraft:invisibility",duration:-1,show_particles:0b},{id:"minecraft:resistance",amplifier:9,duration:-1,show_particles:0b}]} +tp @e[type=villager,tag=gm4_new_furniture,limit=1] ~ ~-0.4999 ~ +scoreboard players set @e[type=villager,tag=gm4_new_furniture,limit=1] gm4_furniture_index 0 +execute as @e[type=villager,tag=gm4_new_furniture,limit=1] at @s run function gm4_furniture:technical/furniture_station/build_trades/prep +execute unless block ~ ~1 ~ water[level=0] run setblock ~ ~1 ~ light[level=0] +execute if block ~ ~1 ~ water[level=0] run setblock ~ ~1 ~ light[level=0,waterlogged=true] +execute store result score @e[type=interaction,tag=gm4_new_furniture] gm4_furniture_id run scoreboard players add $next_id gm4_furniture_id 1 +execute store result score @e[type=villager,tag=gm4_new_furniture] gm4_furniture_id run scoreboard players get $next_id gm4_furniture_id + +# rotate furniture_station 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 + +# mark block as placed +playsound minecraft:block.barrel.close block @a[distance=..6] ~ ~ ~ 1 1.6 +tag @e[distance=..2] remove gm4_new_furniture diff --git a/gm4_furniture/data/gm4_furniture/functions/place/place_furniture.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/place_furniture.mcfunction new file mode 100644 index 0000000000..012925e844 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/place_furniture.mcfunction @@ -0,0 +1,37 @@ +# finds the player head that was placed by the player +# @s = player that just placed a furniture player head +# at @s +advancement revoke @s only gm4_furniture:place_furniture +# run from place/place_furniture_water + +# get item data +execute store success score $mainhand gm4_furniture_data run data modify storage gm4_furniture:temp furniture_data set from entity @s SelectedItem.tag.gm4_furniture +execute if score $mainhand gm4_furniture_data matches 0 run data modify storage gm4_furniture:temp furniture_data set from entity @s Inventory[{Slot:-106b}].tag.gm4_furniture + +# get rotation of player +# key: direction of player +# 1: north, 2: east, 3: south, 4: west +execute store result score $y_rotation gm4_furniture_data run data get entity @s Rotation[0] +scoreboard players set $rotation gm4_furniture_data 0 + +execute if score $y_rotation gm4_furniture_data matches 45..135 run scoreboard players set $rotation gm4_furniture_data 4 +execute if score $rotation gm4_furniture_data matches 0 if score $y_rotation gm4_furniture_data matches -45..45 run scoreboard players set $rotation gm4_furniture_data 3 +execute if score $rotation gm4_furniture_data matches 0 if score $y_rotation gm4_furniture_data matches -135..-45 run scoreboard players set $rotation gm4_furniture_data 2 +execute if score $rotation gm4_furniture_data matches 0 run scoreboard players set $rotation gm4_furniture_data 1 + +# find player heads in the specific region +scoreboard players set $player_head_count gm4_furniture_data 0 +execute if score $rotation gm4_furniture_data matches 1 run function gm4_furniture:place/count_heads/north +execute if score $rotation gm4_furniture_data matches 2 run function gm4_furniture:place/count_heads/east +execute if score $rotation gm4_furniture_data matches 3 run function gm4_furniture:place/count_heads/south +execute if score $rotation gm4_furniture_data matches 4 run function gm4_furniture:place/count_heads/west + +# replace player heads with the corresponding block +scoreboard players set $layer_count gm4_furniture_data 0 +execute if score $player_head_count gm4_furniture_data matches 1.. if score $rotation gm4_furniture_data matches 1 align xyz positioned ~0.5 ~0.5 ~0.5 rotated 180 0 positioned ^-4 ^-4 ^-1 run function gm4_furniture:place/check_layer +execute if score $player_head_count gm4_furniture_data matches 1.. if score $rotation gm4_furniture_data matches 2 align xyz positioned ~0.5 ~0.5 ~0.5 rotated -90 0 positioned ^-4 ^-4 ^-1 run function gm4_furniture:place/check_layer +execute if score $player_head_count gm4_furniture_data matches 1.. if score $rotation gm4_furniture_data matches 3 align xyz positioned ~0.5 ~0.5 ~0.5 rotated 0 0 positioned ^-4 ^-4 ^-1 run function gm4_furniture:place/check_layer +execute if score $player_head_count gm4_furniture_data matches 1.. if score $rotation gm4_furniture_data matches 4 align xyz positioned ~0.5 ~0.5 ~0.5 rotated 90 0 positioned ^-4 ^-4 ^-1 run function gm4_furniture:place/check_layer + +# cleanup +data remove storage gm4_furniture:temp furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/place/prep_place.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/prep_place.mcfunction new file mode 100644 index 0000000000..36e3dbe476 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/prep_place.mcfunction @@ -0,0 +1,16 @@ +# prepares the storage and scores for furniture placement +# @s = player that just placed a furniture player head +# at the center of the furniture player head that was placed +# run from place/check_layer + +# override rotation if furniture was placed against a wall (opposite of wall facing) +# 1: north, 2: east, 3: south, 4: west +execute store success score $wall_placement gm4_furniture_data if block ~ ~ ~ player_wall_head +execute if score $wall_placement gm4_furniture_data matches 1 run scoreboard players set $rotation gm4_furniture_data 3 +execute if score $wall_placement gm4_furniture_data matches 1 if block ~ ~ ~ player_wall_head[facing=east] run scoreboard players set $rotation gm4_furniture_data 4 +execute if score $wall_placement gm4_furniture_data matches 1 if block ~ ~ ~ player_wall_head[facing=south] run scoreboard players set $rotation gm4_furniture_data 1 +execute if score $wall_placement gm4_furniture_data matches 1 if block ~ ~ ~ player_wall_head[facing=west] run scoreboard players set $rotation gm4_furniture_data 2 + +scoreboard players remove $player_head_count gm4_furniture_data 1 + +function gm4_furniture:place/resolve_id with storage gm4_furniture:temp furniture_data diff --git a/gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction b/gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction new file mode 100644 index 0000000000..d45636f329 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction @@ -0,0 +1,10 @@ +# 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 with storage gm4_furniture:temp furniture_data +# $(furniture_id) = furniture's 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) diff --git a/gm4_furniture/data/gm4_furniture/functions/slow_clock.mcfunction b/gm4_furniture/data/gm4_furniture/functions/slow_clock.mcfunction new file mode 100644 index 0000000000..83e46fdedd --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/slow_clock.mcfunction @@ -0,0 +1,12 @@ +schedule function gm4_furniture:slow_clock 10s + +# check seats to see if they are empty +execute as @e[type=item_display,tag=gm4_furniture.seat] run function gm4_furniture:interact/sit/check + +# process furniture stations +execute as @e[type=villager,tag=gm4_furniture.furniture_station] at @s run function gm4_furniture:technical/furniture_station/activation/process + +# TEMP: update wandering trader +execute as @e[type=wandering_trader,tag=gm4_furniture.furniture_station] at @s run function gm4_furniture:update/update_villager +# TEMP: update sittable furniture +execute as @e[type=interaction,tag=gm4_furniture.sittable] run function gm4_furniture:update/update_seat diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/process.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/process.mcfunction new file mode 100644 index 0000000000..8f68655c3e --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/process.mcfunction @@ -0,0 +1,10 @@ +# process active furniture stations +# @s = furniture station villager +# at @s +# run from slow_clock + +# reapply invisibility in case it was lost +effect give @s invisibility infinite 0 true + +# check if there are still players close to actually trade +execute unless entity @a[distance=..12,gamemode=!spectator] run function gm4_furniture:technical/furniture_station/activation/turn_inactive diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/turn_active.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/turn_active.mcfunction new file mode 100644 index 0000000000..bbc97d6190 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/turn_active.mcfunction @@ -0,0 +1,20 @@ +# turn furniture station on if no player interacted with it +# @s = furniture reactivation interaction entity +# at @s +# run from technical/furniture_station/activation/process +# run frin interact/furniture_station/swap_tool + +# turn tool upright +execute align xyz run data merge entity @e[type=item_display,tag=gm4_furniture.tool_main,dx=0,dy=0,dz=0,limit=1] {interpolation_duration:5,start_interpolation:-1,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[0f,0f,0f,1f],translation:[0f,0.6f,0f],scale:[1f,1f,1f]}} + +# spawn villager and set ids +summon villager ~ ~1000 ~ {VillagerData:{level:99},Invulnerable:1b,Team:"gm4_furniture_nocol",Tags:["gm4_furniture","gm4_furniture.furniture_station","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'{"translate":"gm4.second","fallback":"%1$s","with":[{"translate":"container.gm4.furniture_station","fallback":"Furniture Station"},[{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:offscreen"},{"translate":"gui.gm4.furniture_station","fallback":"","font":"gm4:container_gui","color":"white"},{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:furniture","color":"#404040"}]]}',NoAI:1b,Silent:1b,active_effects:[{id:"minecraft:invisibility",duration:-1,show_particles:0b},{id:"minecraft:resistance",amplifier:9,duration:-1,show_particles:0b}]} +execute align xyz run tp @e[type=villager,tag=gm4_new_furniture,limit=1] ~.5 ~0.0001 ~.5 +scoreboard players operation @e[type=villager,tag=gm4_new_furniture,limit=1,distance=..4] gm4_furniture_id = @s gm4_furniture_id +scoreboard players operation @e[type=villager,tag=gm4_new_furniture,limit=1,distance=..4] gm4_furniture_index = @s gm4_furniture_index +execute as @e[type=villager,tag=gm4_new_furniture,limit=1,distance=..4] at @s run function gm4_furniture:technical/furniture_station/build_trades/prep +tag @e[type=villager,tag=gm4_new_furniture,limit=1,distance=..4] remove gm4_new_furniture + +# mark interaction as complete and remove interaction entity +scoreboard players set $interaction_processed gm4_furniture_data 1 +kill @s diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/turn_inactive.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/turn_inactive.mcfunction new file mode 100644 index 0000000000..20f4c587bf --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/activation/turn_inactive.mcfunction @@ -0,0 +1,17 @@ +# turn furniture station off if no player is nearby +# @s = furniture station villager +# at @s +# run from technical/furniture_station/activation/process + +# lay down tool +execute align xyz run data merge entity @e[type=item_display,tag=gm4_furniture.tool_main,dx=0,dy=0,dz=0,limit=1] {interpolation_duration:5,start_interpolation:-1,transformation:{left_rotation:[0f,0f,0f,1f],right_rotation:[-1f,0f,0f,1f],translation:[0f,1.125f,0.9375f],scale:[0.5f,0.5f,0.5f]}} + +# spawn interaction to turn furniture back on again, has villager data +execute positioned ~ ~1 ~ align xyz run summon interaction ~.5 ~-0.0001 ~.5 {Tags:["gm4_furniture","gm4_furniture.interaction","gm4_furniture.furniture_station","gm4_furniture.reactivate","smithed.entity","smithed.strict","gm4_new_furniture"],height:1.0002f,width:1.0002f,response:1b} +scoreboard players operation @e[type=interaction,tag=gm4_new_furniture,distance=..4,limit=1] gm4_furniture_id = @s gm4_furniture_id +scoreboard players operation @e[type=interaction,tag=gm4_new_furniture,distance=..4,limit=1] gm4_furniture_index = @s gm4_furniture_index +tag @e[type=interaction,tag=gm4_new_furniture,distance=..4] remove gm4_new_furniture + +# remove villager +tp @s ~ ~-10000 ~ +kill @s diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/build_trade.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/build_trade.mcfunction new file mode 100644 index 0000000000..1fa8f45db2 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/build_trade.mcfunction @@ -0,0 +1,24 @@ +# build a trade from trade_data +# @s = furniture station villager +# at @s +# run from technical/furniture_station/build_trades/prep +# run from here + +data modify storage gm4_furniture:temp new_trade set value {rewardExp:0b,maxUses:2147483647,uses:0,xp:0,buy:{id:"minecraft:barrier",Count:1b},buyB:{id:"minecraft:barrier",Count:1b},sell:{id:"minecraft:barrier",Count:1b}} +data modify storage gm4_furniture:temp new_trade.buy.id set from storage gm4_furniture:temp trade_data[0].cost[0].id +data modify storage gm4_furniture:temp new_trade.buy.Count set from storage gm4_furniture:temp trade_data[0].cost[0].Count + +execute store result score $second_trade_count gm4_furniture_data run data get storage gm4_furniture:temp trade_data[0].cost[1].Count +execute unless score $second_trade_count gm4_furniture_data matches 1.. run data remove storage gm4_furniture:temp new_trade.buyB +execute if score $second_trade_count gm4_furniture_data matches 1.. run data modify storage gm4_furniture:temp new_trade.buyB.id set from storage gm4_furniture:temp trade_data[0].cost[1].id +execute if score $second_trade_count gm4_furniture_data matches 1.. run data modify storage gm4_furniture:temp new_trade.buyB.Count set from storage gm4_furniture:temp trade_data[0].cost[1].Count + +function gm4_furniture:technical/furniture_station/build_trades/resolve_trade with storage gm4_furniture:temp trade_data[0].result +data modify storage gm4_furniture:temp new_trade.sell set from block 29999998 1 7134 Items[{Slot:0b}] +data modify storage gm4_furniture:temp new_trade.sell.Count set from storage gm4_furniture:temp trade_data[0].result.Count + +data modify storage gm4_furniture:temp trades append from storage gm4_furniture:temp new_trade +data remove storage gm4_furniture:temp new_trade + +data remove storage gm4_furniture:temp trade_data[0] +execute if data storage gm4_furniture:temp trade_data[0] run function gm4_furniture:technical/furniture_station/build_trades/build_trade diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/get_trade_data.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/get_trade_data.mcfunction new file mode 100644 index 0000000000..fc8425a0e7 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/get_trade_data.mcfunction @@ -0,0 +1,10 @@ +# loop through trade data to get the proper index in the frot +# @s = furniture station villager +# at @s +# run from technical/furniture_station/build_trades/prep +# run from here + +data modify storage gm4_furniture:temp trade_data append from storage gm4_furniture:temp trade_data[0] +data remove storage gm4_furniture:temp trade_data[0] +scoreboard players remove $trade_index gm4_furniture_data 1 +execute if score $trade_index gm4_furniture_data matches 1.. run function gm4_furniture:technical/furniture_station/build_trades/get_trade_data diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/prep.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/prep.mcfunction new file mode 100644 index 0000000000..37bfd8f390 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/prep.mcfunction @@ -0,0 +1,39 @@ +# change the trades of this furniture station +# @s = furniture station villager +# at @s +# run from interact/furniture_station/swap_tool +# run from place/furniture/furniture_station +# run from technical/furniture_station/activation/turn_active +# run from technical/furniture_station/lightning/revive_villager + +# clamp index to min/max +execute if score @s gm4_furniture_index matches ..-1 run scoreboard players operation @s gm4_furniture_index = $max_index gm4_furniture_index +execute if score @s gm4_furniture_index > $max_index gm4_furniture_index run scoreboard players set @s gm4_furniture_index 0 + +# get the trade data that should be displayed in the first index +scoreboard players operation $trade_index gm4_furniture_data = @s gm4_furniture_index +data modify storage gm4_furniture:temp trade_data set from storage gm4_furniture:data furniture_station +execute if score $trade_index gm4_furniture_data matches 1.. run function gm4_furniture:technical/furniture_station/build_trades/get_trade_data + +# change the displayed tools cmd +execute align xyz run data modify entity @e[type=item_display,tag=gm4_furniture.tool_main,dx=0,dy=0,dz=0,limit=1] item.tag.CustomModelData set from storage gm4_furniture:temp trade_data[0].cmd +execute align xyz run data modify entity @e[type=item_display,tag=gm4_furniture.tool_next,dx=0,dy=0,dz=0,limit=1] item.tag.CustomModelData set from storage gm4_furniture:temp trade_data[1].cmd +execute align xyz run data modify entity @e[type=item_display,tag=gm4_furniture.tool_prev,dx=0,dy=0,dz=0,limit=1] item.tag.CustomModelData set from storage gm4_furniture:temp trade_data[-1].cmd + +# build the trades from trade_data +data modify storage gm4_furniture:temp trade_data set from storage gm4_furniture:temp trade_data[0].trades +data modify storage gm4_furniture:temp trades set value [] +function gm4_furniture:technical/furniture_station/build_trades/build_trade + +# change the trades +data modify entity @s Offers.Recipes set from storage gm4_furniture:temp trades + +# sounds +playsound ui.stonecutter.take_result block @a[distance=..16] ~ ~ ~ 1 0.45 + +# cleanup +data remove storage gm4_furniture:temp trades +data remove storage gm4_furniture:temp trade_data + +# store index for interaction entity +scoreboard players operation $store_index gm4_furniture_data = @s gm4_furniture_index diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/resolve_trade.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/resolve_trade.mcfunction new file mode 100644 index 0000000000..71332d1ff1 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/build_trades/resolve_trade.mcfunction @@ -0,0 +1,7 @@ +# put furniture item in forceloaded shulker box to read its data +# @s = furniture station villager +# at @s +# run from technical/furniture_station/build_trades/build_trade with storage gm4_furniture:temp trade_data[0] +# $(furniture_id) = furniture's id + +$loot replace block 29999998 1 7134 container.0 loot gm4_furniture:furniture/$(furniture_id) diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/detect.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/detect.mcfunction new file mode 100644 index 0000000000..e42a9ef524 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/detect.mcfunction @@ -0,0 +1,6 @@ +# Target NoAI witch after lightning strike near player +# @s = player +# at @s +advancement revoke @s only gm4_furniture:lightning + +execute as @e[type=witch,nbt={NoAI:1b}] unless data entity @s Tags at @s if block ~ ~ ~ barrier run function gm4_furniture:technical/furniture_station/lightning/revive_villager diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/get_scores.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/get_scores.mcfunction new file mode 100644 index 0000000000..a66f87c030 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/get_scores.mcfunction @@ -0,0 +1,7 @@ +# get scores to restore villager +# @s = furniture main interaction entity +# at @s +# runs from lightning/revive_villager + +scoreboard players operation $restore_id gm4_furniture_id = @s gm4_furniture_id +scoreboard players operation $restore_index gm4_furniture_data = @s gm4_furniture_index diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/revive_villager.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/revive_villager.mcfunction new file mode 100644 index 0000000000..de6d8fbb1f --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/furniture_station/lightning/revive_villager.mcfunction @@ -0,0 +1,18 @@ +# Replace witch with villager +# @s = witch that replaced the villager +# at @s +# runs from lightning/detect + +# grab id and index for the new villager +execute align xyz as @e[type=interaction,tag=gm4_furniture.furniture_station,tag=gm4_furniture.main,dx=0,dy=0,dz=0] run function gm4_furniture:technical/furniture_station/lightning/get_scores + +# spawn villager and set ids +summon villager ~ ~1000 ~ {VillagerData:{level:99},Invulnerable:1b,Team:"gm4_furniture_nocol",Tags:["gm4_furniture","gm4_furniture.furniture_station","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'{"translate":"gm4.second","fallback":"%1$s","with":[{"translate":"container.gm4.furniture_station","fallback":"Furniture Station"},[{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:offscreen"},{"translate":"gui.gm4.furniture_station","fallback":"","font":"gm4:container_gui","color":"white"},{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:furniture","color":"#404040"}]]}',NoAI:1b,Silent:1b,active_effects:[{id:"minecraft:invisibility",duration:-1,show_particles:0b},{id:"minecraft:resistance",amplifier:9,duration:-1,show_particles:0b}]} +tp @e[type=villager,tag=gm4_new_furniture,limit=1] ~ ~ ~ +scoreboard players operation @e[type=villager,tag=gm4_new_furniture,limit=1] gm4_furniture_index = $restore_index gm4_furniture_data +execute as @e[type=villager,tag=gm4_new_furniture,limit=1] at @s run function gm4_furniture:technical/furniture_station/build_trades/prep +execute store result score @e[type=villager,tag=gm4_new_furniture] gm4_furniture_id run scoreboard players get $restore_id gm4_furniture_id + +# kill witch +tp @s ~ -10000 ~ +kill @s 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 new file mode 100644 index 0000000000..a479ed1b05 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/remove_from_horse.mcfunction @@ -0,0 +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 +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 new file mode 100644 index 0000000000..98f055b7ae --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/paintbrush/used_on_horse.mcfunction @@ -0,0 +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"} run function gm4_furniture:technical/paintbrush/return_from_horse +tag @s remove gm4_furniture_target diff --git a/gm4_furniture/data/gm4_furniture/functions/technical/relog.mcfunction b/gm4_furniture/data/gm4_furniture/functions/technical/relog.mcfunction new file mode 100644 index 0000000000..78883c8dbd --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/technical/relog.mcfunction @@ -0,0 +1,10 @@ +# dismount other players sitting on this furniture +# @s = player relogging +# at @s +advancement revoke @s only gm4_furniture:relog + +tag @s add gm4_furniture_target +scoreboard players set $on_seat gm4_furniture_data 0 +execute on vehicle if entity @s[tag=gm4_furniture.seat] run scoreboard players set $on_seat gm4_furniture_data 1 +execute if score $on_seat gm4_furniture_data matches 1 align xyz as @a[dx=0,dy=0,dz=0,gamemode=!spectator,tag=!gm4_furniture_target] run ride @s dismount +tag @s remove gm4_furniture_target diff --git a/gm4_furniture/data/gm4_furniture/functions/update/update_seat.mcfunction b/gm4_furniture/data/gm4_furniture/functions/update/update_seat.mcfunction new file mode 100644 index 0000000000..692f545823 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/update/update_seat.mcfunction @@ -0,0 +1,5 @@ +# temp +# run from slow_clock + +tag @s remove gm4_furniture.sittable +scoreboard players set @s gm4_furniture_sit_height 50 diff --git a/gm4_furniture/data/gm4_furniture/functions/update/update_villager.mcfunction b/gm4_furniture/data/gm4_furniture/functions/update/update_villager.mcfunction new file mode 100644 index 0000000000..01624c36d2 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/functions/update/update_villager.mcfunction @@ -0,0 +1,18 @@ +# temp +# run from slow_clock + +# grab id +scoreboard players operation $furniture_id gm4_furniture_id = @s gm4_furniture_id + +# spawn villager and set ids +summon villager ~ ~1000 ~ {VillagerData:{level:99},Invulnerable:1b,Team:"gm4_furniture_nocol",Tags:["gm4_furniture","gm4_furniture.furniture_station","smithed.entity","smithed.strict","gm4_new_furniture"],CustomName:'{"translate":"gm4.second","fallback":"%1$s","with":[{"translate":"container.gm4.furniture_station","fallback":"Furniture Station"},[{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:offscreen"},{"translate":"gui.gm4.furniture_station","fallback":"","font":"gm4:container_gui","color":"white"},{"text":" ","font":"gm4:half_invert"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:half_invert"},{"translate":"gui.gm4.furniture_station.offset","font":"gm4:container_gui"},{"translate":"container.gm4.furniture_station","fallback":"Furniture Station","font":"gm4:furniture","color":"#404040"}]]}',NoAI:1b,Silent:1b,active_effects:[{id:"minecraft:invisibility",duration:-1,show_particles:0b},{id:"minecraft:resistance",amplifier:9,duration:-1,show_particles:0b}]} +execute align xyz positioned ~.5 ~.5 ~.5 run tp @e[type=villager,tag=gm4_new_furniture,limit=1] ~ ~-0.4999 ~ +scoreboard players set @e[type=villager,tag=gm4_new_furniture,limit=1] gm4_furniture_index 0 +execute as @e[type=villager,tag=gm4_new_furniture,limit=1] at @s run function gm4_furniture:technical/furniture_station/build_trades/prep +execute store result score @e[type=villager,tag=gm4_new_furniture] gm4_furniture_id run scoreboard players get $furniture_id gm4_furniture_id + +tag @e[type=villager,tag=gm4_new_furniture] remove gm4_new_furniture + +# remove wandering trader +tp @s ~ ~-10000 ~ +kill @s diff --git a/gm4_furniture/data/gm4_furniture/item_modifiers/get_color.json b/gm4_furniture/data/gm4_furniture/item_modifiers/get_color.json new file mode 100644 index 0000000000..d0ba3a4d5d --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/item_modifiers/get_color.json @@ -0,0 +1,16 @@ +[ + { + "function": "minecraft:copy_nbt", + "source": { + "type": "minecraft:storage", + "source": "gm4_furniture:temp" + }, + "ops": [ + { + "source": "color", + "target": "display.color", + "op": "replace" + } + ] + } +] diff --git a/gm4_furniture/data/gm4_furniture/loot_tables/crafting/furniture_station.json b/gm4_furniture/data/gm4_furniture/loot_tables/crafting/furniture_station.json new file mode 100644 index 0000000000..3c954a0edf --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/loot_tables/crafting/furniture_station.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:generic", + "pools": [ + { + "rolls": 8, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:air" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:loot_table", + "name": "gm4_furniture:items/furniture_station", + "functions": [ + { + "function": "minecraft:set_count", + "count": 1 + } + ] + } + ] + } + ] +} diff --git a/gm4_furniture/data/gm4_furniture/loot_tables/crafting/paintbrush.json b/gm4_furniture/data/gm4_furniture/loot_tables/crafting/paintbrush.json new file mode 100644 index 0000000000..d57b97a53c --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/loot_tables/crafting/paintbrush.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:generic", + "pools": [ + { + "rolls": 8, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:air" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:loot_table", + "name": "gm4_furniture:items/paintbrush", + "functions": [ + { + "function": "minecraft:set_count", + "count": 1 + } + ] + } + ] + } + ] +} diff --git a/gm4_furniture/data/gm4_furniture/loot_tables/furniture/base.json b/gm4_furniture/data/gm4_furniture/loot_tables/furniture/base.json new file mode 100644 index 0000000000..7c610f0cee --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/loot_tables/furniture/base.json @@ -0,0 +1,20 @@ +{ + "type": "block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "minecraft:player_head", + "functions": [ + { + "function": "set_nbt", + "tag": "{SkullOwner:{Id:[I;-308545246,403555340,412409013,-705374452],Properties:{textures:[{Signature:\"gm4_furniture\",Value:\"ewogICJ0aW1lc3RhbXAiIDogMTY5Mjg3NTg0Njc2OCwKICAicHJvZmlsZUlkIiA6ICJhNWZlYWViNDdhYjA0ZDZiYTk2ZjMyOGJjMDQ3MDZjMyIsCiAgInByb2ZpbGVOYW1lIiA6ICJYeW5kcmEyIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzMzMDU1YjMzMGVmZTY0ZTQxMmQxZDc4MTE5MTM5YzRkMTA3YjZlMDdkNmUyMGU5MTVkYWE5MjFlYTgzMDgwMiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9\"}]}}}" + } + ] + } + ] + } + ] +} diff --git a/gm4_furniture/data/gm4_furniture/loot_tables/furniture/furniture_station.json b/gm4_furniture/data/gm4_furniture/loot_tables/furniture/furniture_station.json new file mode 100644 index 0000000000..49a7ead502 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/loot_tables/furniture/furniture_station.json @@ -0,0 +1,13 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:loot_table", + "name": "gm4_furniture:items/furniture_station" + } + ] + } + ] +} diff --git a/gm4_furniture/data/gm4_furniture/loot_tables/items/furniture_station.json b/gm4_furniture/data/gm4_furniture/loot_tables/items/furniture_station.json new file mode 100644 index 0000000000..bac25597c2 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/loot_tables/items/furniture_station.json @@ -0,0 +1,29 @@ +{ + "type": "block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "minecraft:player_head", + "functions": [ + { + "function": "set_nbt", + "tag": "{CustomModelData:3420150,gm4_furniture:{furniture_id:\"furniture_station\"},SkullOwner:{Id:[I;-308545246,403555340,412409013,-705374452],Name:\"furniture_station\",Properties:{textures:[{Signature:\"gm4_furniture\",Value:\"ewogICJ0aW1lc3RhbXAiIDogMTY5Mjg3NTg0Njc2OCwKICAicHJvZmlsZUlkIiA6ICJhNWZlYWViNDdhYjA0ZDZiYTk2ZjMyOGJjMDQ3MDZjMyIsCiAgInByb2ZpbGVOYW1lIiA6ICJYeW5kcmEyIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzMzMDU1YjMzMGVmZTY0ZTQxMmQxZDc4MTE5MTM5YzRkMTA3YjZlMDdkNmUyMGU5MTVkYWE5MjFlYTgzMDgwMiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9\"}]}}}" + }, + { + "function": "minecraft:set_name", + "name": { + "translate": "item.gm4_furniture.furniture_station", + "fallback": "Furniture Station", + "color": "white", + "italic": false + } + } + ] + } + ] + } + ] +} diff --git a/gm4_furniture/data/gm4_furniture/loot_tables/items/paintbrush.json b/gm4_furniture/data/gm4_furniture/loot_tables/items/paintbrush.json new file mode 100644 index 0000000000..ed382532a4 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/loot_tables/items/paintbrush.json @@ -0,0 +1,28 @@ +{ + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:leather_horse_armor", + "functions": [ + { + "function": "minecraft:set_nbt", + "tag": "{CustomModelData:3420151,gm4_furniture:paintbrush}" + }, + { + "function": "minecraft:set_name", + "name": { + "translate": "item.gm4_furniture.paintbrush", + "fallback": "Paintbrush", + "color": "white", + "italic": false + } + } + ] + } + ] + } + ] +} 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/predicates/chance/animal_statue_sound.json b/gm4_furniture/data/gm4_furniture/predicates/chance/animal_statue_sound.json new file mode 100644 index 0000000000..a32336e2f6 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/predicates/chance/animal_statue_sound.json @@ -0,0 +1,4 @@ +{ + "condition": "minecraft:random_chance", + "chance": 0.02 +} diff --git a/gm4_furniture/data/gm4_furniture/predicates/holding_bucket.json b/gm4_furniture/data/gm4_furniture/predicates/holding_bucket.json new file mode 100644 index 0000000000..9ca538a0bd --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/predicates/holding_bucket.json @@ -0,0 +1,14 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "items": [ + "minecraft:bucket", + "minecraft:water_bucket" + ] + } + } + } +} diff --git a/gm4_furniture/data/gm4_furniture/predicates/holding_empty_bucket.json b/gm4_furniture/data/gm4_furniture/predicates/holding_empty_bucket.json new file mode 100644 index 0000000000..eb467d159a --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/predicates/holding_empty_bucket.json @@ -0,0 +1,13 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "items": [ + "minecraft:bucket" + ] + } + } + } +} diff --git a/gm4_furniture/data/gm4_furniture/predicates/holding_paintbrush.json b/gm4_furniture/data/gm4_furniture/predicates/holding_paintbrush.json new file mode 100644 index 0000000000..9d64e37052 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/predicates/holding_paintbrush.json @@ -0,0 +1,14 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "items": [ + "minecraft:leather_horse_armor" + ], + "nbt": "{gm4_furniture:paintbrush}" + } + } + } +} diff --git a/gm4_furniture/data/gm4_furniture/predicates/holding_water_bucket.json b/gm4_furniture/data/gm4_furniture/predicates/holding_water_bucket.json new file mode 100644 index 0000000000..0cbf67e9a0 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/predicates/holding_water_bucket.json @@ -0,0 +1,13 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "items": [ + "minecraft:water_bucket" + ] + } + } + } +} diff --git a/gm4_furniture/data/gm4_furniture/predicates/is_sneaking.json b/gm4_furniture/data/gm4_furniture/predicates/is_sneaking.json new file mode 100644 index 0000000000..3c8a7e1e95 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/predicates/is_sneaking.json @@ -0,0 +1,9 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "flags": { + "is_sneaking": true + } + } +} 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/tags/blocks/player_heads.json b/gm4_furniture/data/gm4_furniture/tags/blocks/player_heads.json new file mode 100644 index 0000000000..389c902b9d --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/tags/blocks/player_heads.json @@ -0,0 +1,6 @@ +{ + "values": [ + "minecraft:player_head", + "minecraft:player_wall_head" + ] +} diff --git a/gm4_furniture/data/gm4_furniture/templates/functions/crafting_template.mcfunction b/gm4_furniture/data/gm4_furniture/templates/functions/crafting_template.mcfunction new file mode 100644 index 0000000000..771c3539a3 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/templates/functions/crafting_template.mcfunction @@ -0,0 +1,12 @@ +# create storage to hold the trade data for furniture items in furniture station +# @s = unspecified +# at unspecified +# run from init +# this function was generated by generate.py + +{{ trades_init }} + +{{ trades_list }} + +{{ trades_append }} +data remove storage gm4_furniture:temp new_trades diff --git a/gm4_furniture/data/gm4_furniture/templates/functions/furniture_place_template.mcfunction b/gm4_furniture/data/gm4_furniture/templates/functions/furniture_place_template.mcfunction new file mode 100644 index 0000000000..9eab22add6 --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/templates/functions/furniture_place_template.mcfunction @@ -0,0 +1,85 @@ +# try to place the furniture +# @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 + +# set variables +scoreboard players set $dyable gm4_furniture_data {{ dyable }} +scoreboard players set $table gm4_furniture_data {{ table }} +scoreboard players set $custom_interaction gm4_furniture_data {{ custom_interaction }} +scoreboard players set $length gm4_furniture_data {{ length }} +scoreboard players set $depth gm4_furniture_data {{ depth }} +scoreboard players set $height gm4_furniture_data {{ height }} +scoreboard players set $diagonal_placement_allowed gm4_furniture_data {{ allow_diagonal_placement }} + +# check for diagonal placement +execute if score $diagonal_placement_allowed gm4_furniture_data matches 1 if block ~ ~ ~ player_head run function gm4_furniture:place/check_diagonal_placement +# store rotation in storage if a non-standard rotation was used +execute if score $rotation gm4_furniture_data matches 1 run data modify storage gm4_furniture:data Rotation set value [0.0f,0.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 + +# ceiling only furniture must be placed on a ceiling +scoreboard players set $ceiling_only gm4_furniture_data {{ ceiling_only }} +execute if score $ceiling_only gm4_furniture_data matches 1 if block ~ ~1 ~ #gm4:replaceable run scoreboard players set $valid_placement gm4_furniture_data 0 + +# wall placed furniture is not allowed to have depth, if any size is bigger than 1 check if there is space +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 $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] + +# if placement is not valid cancel placement +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 + +# spawn the furniture +summon item_display ~ ~-0.4999 ~ {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"],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,distance=..8] add gm4_furniture.on_wall +execute if score $ceiling_only gm4_furniture_data matches 1 run tag @e[type=interaction,tag=gm4_new_furniture,distance=..8] add gm4_furniture.on_ceiling + +# 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"],height:1.0002f,width:1.0002f,response:1b} +execute at @e[type=marker,tag=gm4_furniture.marked_block] run setblock ~ ~ ~ {{ block_id }} + +# add custom interaction tags +execute if score $custom_interaction gm4_furniture_data matches 1 run tag @e[type=interaction,tag=gm4_new_furniture,distance=..8] add gm4_furniture.custom_interaction + +# if furniture is a table reduce interaction height +execute if score $table gm4_furniture_data matches 1 as @e[type=interaction,tag=gm4_new_furniture,distance=..8] run data modify entity @s height set value 1f + +# if furniture is dyable set to basic white +execute if score $dyable gm4_furniture_data matches 1 run data modify entity @e[type=item_display,distance=..2,tag=gm4_new_furniture,limit=1,sort=nearest] item.tag.display.color set from storage gm4_furniture:temp furniture_data.color +execute if score $dyable gm4_furniture_data matches 1 run tag @e[type=interaction,tag=gm4_new_furniture,distance=..8] add gm4_furniture.dyable + +# if furniture is sittable spawn sitting item_displays at appropiate locations and add tag +scoreboard players set @e[type=interaction,tag=gm4_new_furniture,distance=..8] gm4_furniture_sit_height {{ sittable }} + +# 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 and set id +playsound minecraft:block.barrel.close block @a[distance=..6] ~ ~ ~ 1 1.6 +execute store result score @e[tag=gm4_new_furniture,distance=..8] gm4_furniture_id run scoreboard players add $next_id gm4_furniture_id 1 +tag @e[tag=gm4_new_furniture,distance=..8] remove gm4_new_furniture + +# cleanup +kill @e[type=marker,tag=gm4_furniture.marked_block] diff --git a/gm4_furniture/data/gm4_furniture/templates/loot_tables/furniture_item_template.json b/gm4_furniture/data/gm4_furniture/templates/loot_tables/furniture_item_template.json new file mode 100644 index 0000000000..7021f7db7c --- /dev/null +++ b/gm4_furniture/data/gm4_furniture/templates/loot_tables/furniture_item_template.json @@ -0,0 +1,125 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:loot_table", + "name": "gm4_furniture:furniture/base", + "functions": [ + { + "function": "minecraft:set_nbt", + "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.{{ category }}.{{ technical_id }}", + "fallback": "{{ display_name }}", + "color": "white", + "italic": false + } + ] + }, + { + "function": "minecraft:set_lore", + "entity": "this", + "lore": [ + [ + { + "translate": "item.gm4_furniture.paintbrush.color_lore", + "fallback": "Color: #", + "color": "gray", + "italic": false + }, + { + "nbt": "color_hex.red_1", + "storage": "gm4_furniture:temp" + }, + { + "nbt": "color_hex.red_2", + "storage": "gm4_furniture:temp" + }, + { + "nbt": "color_hex.green_1", + "storage": "gm4_furniture:temp" + }, + { + "nbt": "color_hex.green_2", + "storage": "gm4_furniture:temp" + }, + { + "nbt": "color_hex.blue_1", + "storage": "gm4_furniture:temp" + }, + { + "nbt": "color_hex.blue_2", + "storage": "gm4_furniture:temp" + } + ] + ], + "conditions": [ + { + "condition": "minecraft:value_check", + "value": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$furniture_color" + }, + "score": "gm4_furniture_data" + }, + "range": { + "min": 1 + } + } + ] + }, + { + "function": "minecraft:set_lore", + "entity": "this", + "lore": [ + [ + { + "translate": "item.gm4_furniture.paintbrush.color_lore", + "fallback": "Color: #", + "color": "gray", + "italic": false + }, + { + "text": "F9FFFE" + } + ] + ], + "conditions": [ + { + "condition": "minecraft:random_chance", + "chance": {{ dyable }} + }, + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:value_check", + "value": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$furniture_color" + }, + "score": "gm4_furniture_data" + }, + "range": { + "min": 1 + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/gm4_furniture/generate.py b/gm4_furniture/generate.py new file mode 100644 index 0000000000..0b4cba268a --- /dev/null +++ b/gm4_furniture/generate.py @@ -0,0 +1,122 @@ +from beet import Context, subproject +from pathlib import Path +from gm4.utils import CSV + +def beet_default(ctx: Context): + + trades_init = [] + trades_list = [] + trades_append = [] + + furniture_sets = {} + + for path in sorted(Path('gm4_furniture/raw_data/furniture_set').glob('*.csv')): + furniture_sets[path.stem] = CSV.from_file(path) + + tool_cmds = CSV.from_file(Path('gm4_furniture/raw_data/tool_cmds.csv')) + + # loop through the different sheets, each sheet hold a different 'set_name' + # of furniture which need to be sorted in the furniture_station storage + for set_name,furniture_set in furniture_sets.items(): + + # read trade data from this sheet, this creates the villager trades used + # inside the furniture station + tool_cmd = tool_cmds.find_row(set_name , 0)['tool_cmd'] + + # call generate_trade_data to build the commands + new_trades_init,new_trades_list,new_trades_append = generate_trade_data(furniture_set, tool_cmd, set_name) + # append the trade data to the total list + trades_init.append(new_trades_init) + trades_list.append(new_trades_list) + trades_append.append(new_trades_append) + + # read furniture data from this sheet, and then create the placement function + # and loot table for each furniture + generate_furniture_data(ctx, furniture_set, set_name) + + + # build the trade data commands + trades_init = '\n'.join(trades_init) + trades_list = '\n'.join(trades_list) + trades_append = '\n'.join(trades_append) + # build the trade data function from crafting_template + subproject_config = { + "data_pack": { + "load": [ + { + f"data/gm4_furniture/functions/generate_trades.mcfunction": "data/gm4_furniture/templates/functions/crafting_template.mcfunction", + } + ], + "render": { + "functions": "*" + } + }, + "meta": { + "trades_init": trades_init, + "trades_list": trades_list, + "trades_append": trades_append, + } + } + + ctx.require(subproject(subproject_config)) + + + +def generate_trade_data(furniture_set, tool_cmd, set_name): + + # create a command to make an empty storage called new_trades that holds the set_name name and tool cmd + new_trades_init = "data modify storage gm4_furniture:temp new_trades." + set_name + " set value {cmd:" + tool_cmd + ",trades:[]}" + + # iterate over the rows in the spreadsheet and add the trade data for each furniture to the storage + new_trades_list = [] + for row in furniture_set: + new_trades_list.append("data modify storage gm4_furniture:temp new_trades." + set_name + ".trades append value {cost:[{id:" + row['craft_item_1_id'] + ",Count:" + row['craft_item_1_count'] + "b},{id:" + row['craft_item_2_id'] + ",Count:" + row['craft_item_2_count'] + "b}],result:{furniture_id:\"" + set_name + "/" + row['technical_id'] + "\",Count:" + row['craft_result_count'] + "}}") + new_trades_list = '\n'.join(new_trades_list) + + # add command to append the main furniture_station storage with the newly created new_trades + new_trades_append = "data modify storage gm4_furniture:data furniture_station append from storage gm4_furniture:temp new_trades." + set_name + + # return the created commands + return(new_trades_init,new_trades_list,new_trades_append) + + + +def generate_furniture_data(ctx, furniture_set, set_name): + + # create furniture loot tables and placement functions for every furniture in this category + for row in furniture_set: + # build placement function and loot table for furniture piece + subproject_config = { + "data_pack": { + "load": [ + { + f"data/gm4_furniture/loot_tables/furniture/{set_name}/{row['technical_id']}.json": "data/gm4_furniture/templates/loot_tables/furniture_item_template.json", + f"data/gm4_furniture/functions/place/furniture/{set_name}/{row['technical_id']}.mcfunction": "data/gm4_furniture/templates/functions/furniture_place_template.mcfunction", + } + ], + "render": { + "loot_tables": "*", + "functions": "*" + } + }, + "meta": { + "category": set_name, + "technical_id": row['technical_id'], + "display_name": row['display_name'], + "cmd": row['cmd'], + "block_id": row['block_id'], + "sittable": row['sittable'], + "wall_only": str(int(row['wall_only'] == 'TRUE')), + "ceiling_only": str(int(row['ceiling_only'] == 'TRUE')), + "dyable": str(int(row['dyable'] == 'TRUE')), + "length": row['length'], + "depth": row['depth'], + "height": row['height'], + "table": str(int(row['table'] == 'TRUE')), + "scale": row['scale'], + "allow_diagonal_placement": str(int(row['diag'] == 'TRUE')), + "custom_interaction": str(int(row['custom'] == 'TRUE')) + } + } + + ctx.require(subproject(subproject_config)) diff --git a/gm4_furniture/raw_data/furniture_set/cloth_set.csv b/gm4_furniture/raw_data/furniture_set/cloth_set.csv new file mode 100644 index 0000000000..fd3dd4cb0a --- /dev/null +++ b/gm4_furniture/raw_data/furniture_set/cloth_set.csv @@ -0,0 +1,3 @@ +craft_item_1_id,craft_item_1_count,craft_item_2_id,craft_item_2_count,craft_result_count,technical_id,display_name,cmd,block_id,length,depth,height,sittable,dyable,wall_only,ceiling_only,table,scale,diag,custom +candle,1,paper,4,1,paper_lantern_1,Paper Lantern,3420280,light[level=15],1,1,1,0,TRUE,FALSE,TRUE,FALSE,1,FALSE,FALSE +stick,1,white_wool,6,1,horizontal_flag_1,Long Flag,3420281,light[level=0],1,1,1,0,TRUE,FALSE,FALSE,FALSE,1,TRUE,FALSE diff --git a/gm4_furniture/raw_data/furniture_set/metal_set.csv b/gm4_furniture/raw_data/furniture_set/metal_set.csv new file mode 100644 index 0000000000..6665c7b86b --- /dev/null +++ b/gm4_furniture/raw_data/furniture_set/metal_set.csv @@ -0,0 +1,4 @@ +craft_item_1_id,craft_item_1_count,craft_item_2_id,craft_item_2_count,craft_result_count,technical_id,display_name,cmd,block_id,length,depth,height,sittable,dyable,wall_only,ceiling_only,table,scale,diag,custom +iron_ingot,3,candle,3,1,iron_3_candle_holder_1,Iron Candelabra,3420240,light[level=13],1,1,1,0,TRUE,FALSE,FALSE,FALSE,1,FALSE,FALSE +gold_ingot,3,candle,3,1,gold_3_candle_holder_1,Golden Candelabra,3420250,light[level=13],1,1,1,0,TRUE,FALSE,FALSE,FALSE,1,FALSE,FALSE +gold_ingot,8,air,0,1,gold_skull_1,Golden Skull,3420251,light[level=0],1,1,1,0,FALSE,FALSE,FALSE,FALSE,1,TRUE,FALSE diff --git a/gm4_furniture/raw_data/furniture_set/stone_set.csv b/gm4_furniture/raw_data/furniture_set/stone_set.csv new file mode 100644 index 0000000000..3bfad787fd --- /dev/null +++ b/gm4_furniture/raw_data/furniture_set/stone_set.csv @@ -0,0 +1,6 @@ +craft_item_1_id,craft_item_1_count,craft_item_2_id,craft_item_2_count,craft_result_count,technical_id,display_name,cmd,block_id,length,depth,height,sittable,dyable,wall_only,ceiling_only,table,scale,diag,custom +stone_bricks,8,tadpole_bucket,1,1,statues_frog,Stone Frog Statue,3420230,barrier,1,1,1,0,FALSE,FALSE,FALSE,FALSE,1,FALSE,TRUE +stone_bricks,8,bee_nest,1,1,statues_bee,Stone Bee Statue,3420231,barrier,1,1,1,0,FALSE,FALSE,FALSE,FALSE,1,FALSE,TRUE +stone_bricks,8,pufferfish_bucket,1,1,statues_pufferfish,Stone Pufferfish Statue,3420232,barrier,1,1,1,0,FALSE,FALSE,FALSE,FALSE,1,FALSE,TRUE +stone_bricks,8,axolotl_bucket,1,1,statues_axolotl,Stone Axolotl Statue,3420233,barrier,1,1,1,0,FALSE,FALSE,FALSE,FALSE,1,FALSE,TRUE +stone_bricks,8,jukebox,1,1,statues_allay,Stone Allay Statue,3420234,barrier,1,1,1,0,FALSE,FALSE,FALSE,FALSE,1,FALSE,TRUE diff --git a/gm4_furniture/raw_data/furniture_set/wood_set.csv b/gm4_furniture/raw_data/furniture_set/wood_set.csv new file mode 100644 index 0000000000..9483744d28 --- /dev/null +++ b/gm4_furniture/raw_data/furniture_set/wood_set.csv @@ -0,0 +1,13 @@ +craft_item_1_id,craft_item_1_count,craft_item_2_id,craft_item_2_count,craft_result_count,technical_id,display_name,cmd,block_id,length,depth,height,sittable,dyable,wall_only,ceiling_only,table,scale,diag,custom +oak_planks,4,air,0,1,plain_1x1_table_1,Small Oak Table,3420200,barrier,1,1,1,0,FALSE,FALSE,FALSE,TRUE,1,FALSE,FALSE +oak_planks,16,air,0,1,plain_2x2_table_1,Large Oak Table,3420201,barrier,2,2,1,0,FALSE,FALSE,FALSE,TRUE,1,FALSE,FALSE +oak_planks,12,air,0,1,plain_bench_1,Oak Bench,3420202,barrier,3,1,1,50,FALSE,FALSE,FALSE,FALSE,1,FALSE,FALSE +oak_planks,4,air,0,1,plain_chair_1,Oak Chair,3420203,barrier,1,1,1,50,FALSE,FALSE,FALSE,FALSE,1,FALSE,FALSE +oak_planks,4,air,0,1,plain_stool_1,Oak Stool,3420204,barrier,1,1,1,50,FALSE,FALSE,FALSE,FALSE,1,FALSE,FALSE +oak_planks,1,candle,1,1,plain_light_1,Oak Candle Holder,3420205,light[level=15],1,1,1,0,TRUE,FALSE,FALSE,FALSE,1,FALSE,FALSE +dark_oak_planks,4,white_wool,1,1,fancy_1x1_table_1,Small Dark Oak Table,3420210,barrier,1,1,1,0,TRUE,FALSE,FALSE,TRUE,1,FALSE,FALSE +dark_oak_planks,16,white_wool,4,1,fancy_2x2_table_1,Large Dark Oak Table,3420211,barrier,2,2,1,0,TRUE,FALSE,FALSE,TRUE,1,FALSE,FALSE +dark_oak_planks,12,white_wool,3,1,fancy_bench_1,Dark Oak Bench,3420212,barrier,3,1,1,50,TRUE,FALSE,FALSE,FALSE,1,FALSE,FALSE +dark_oak_planks,4,white_wool,1,1,fancy_chair_1,Dark Oak Chair,3420213,barrier,1,1,1,50,TRUE,FALSE,FALSE,FALSE,1,FALSE,FALSE +dark_oak_planks,4,white_wool,1,1,fancy_stool_1,Dark Oak Stool,3420214,barrier,1,1,1,50,TRUE,FALSE,FALSE,FALSE,1,FALSE,FALSE +dark_oak_planks,1,candle,1,1,fancy_light_1,Dark Oak Lamp Shade,3420215,light[level=12],1,1,1,0,TRUE,FALSE,FALSE,FALSE,1,FALSE,FALSE diff --git a/gm4_furniture/raw_data/tool_cmds.csv b/gm4_furniture/raw_data/tool_cmds.csv new file mode 100644 index 0000000000..df79aef436 --- /dev/null +++ b/gm4_furniture/raw_data/tool_cmds.csv @@ -0,0 +1,5 @@ +set_name,tool_cmd +wood_set,3420200 +stone_set,3420201 +cloth_set,3420204 +metal_set,3420202