-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a22c161
commit 3d61925
Showing
36 changed files
with
252 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
gm4_furniture/data/gm4_furniture/functions/break/destroy.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
# destroy this furniture | ||
# @s = furniture main interaction entity | ||
# at @s | ||
# run from break/process_hit | ||
|
||
# unless breaking player was in creative drop the item | ||
execute if score $creative gm4_furniture_data matches 0 positioned ~-0.4999 ~0.0001 ~-0.4999 as @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] run function gm4_furniture:break/drop_item with entity @s item.tag.data | ||
|
||
# remove any furniture blocks that match the id | ||
execute as @e[type=interaction,tag=gm4_furniture,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id at @s run function gm4_furniture:break/remove_block | ||
|
||
# if the broken furniture was a furniture station run some extra code | ||
execute if entity @s[tag=gm4_furniture.furniture_station] run function gm4_furniture:break/remove_furniture_station | ||
|
||
# destroy sound | ||
playsound minecraft:entity.armor_stand.break block @a[distance=..8] ~ ~ ~ 1 1 |
6 changes: 5 additions & 1 deletion
6
gm4_furniture/data/gm4_furniture/functions/break/detect_hit.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
|
||
# detect hitting a furniture | ||
# @s = player punching furniture | ||
# at @s | ||
advancement revoke @s only gm4_furniture:hit_furniture | ||
|
||
# mark if the player is in creative mode | ||
execute store success score $creative gm4_furniture_data if entity @s[gamemode=creative] | ||
|
||
# locate the hit furniture | ||
execute as @e[type=interaction,tag=gm4_furniture,distance=..8] if data entity @s attack at @s run function gm4_furniture:break/find_main |
5 changes: 5 additions & 0 deletions
5
gm4_furniture/data/gm4_furniture/functions/break/drop_item.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# drop destroyed furniture's item | ||
# @s = furniture item display | ||
# at @s | ||
# run from break/destroy with @s item.tag.data | ||
# $(loot_table) = loot table path for this furniture item | ||
|
||
$loot spawn ~.5 ~.25 ~.5 loot $(loot_table) |
8 changes: 7 additions & 1 deletion
8
gm4_furniture/data/gm4_furniture/functions/break/find_main.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# locate the main/central interaction for the hit furniture | ||
# @s = furniture interaction that was hit | ||
# at @s | ||
# run from break/detect_hit | ||
|
||
execute store result score $hit gm4_furniture_last_hit run time query gametime | ||
# find a main furniture interaction entity matching the hit id | ||
scoreboard players operation $check_id gm4_furniture_id = @s gm4_furniture_id | ||
execute as @e[type=interaction,tag=gm4_furniture.main,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id at @s run function gm4_furniture:break/process_hit | ||
|
||
# cleanup | ||
data remove entity @s attack |
11 changes: 10 additions & 1 deletion
11
gm4_furniture/data/gm4_furniture/functions/break/process_hit.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
# process hit furniture | ||
# @s = furniture main interaction entity | ||
# at @s | ||
# run from break/find_main | ||
|
||
# check how much time has passed since the last hit (or ignore that if the player was in creative) | ||
execute store result score $hit gm4_furniture_last_hit run time query gametime | ||
scoreboard players operation $check_break gm4_furniture_last_hit = $hit gm4_furniture_last_hit | ||
scoreboard players operation $check_break gm4_furniture_last_hit -= @s gm4_furniture_last_hit | ||
execute if score $creative gm4_furniture_data matches 1 run scoreboard players set $check_break gm4_furniture_last_hit 0 | ||
|
||
# if >=4 ticks have passed or player is in creative destroy furniture | ||
execute if score $creative gm4_furniture_data matches 1 run scoreboard players set $check_break gm4_furniture_last_hit 0 | ||
execute if score $check_break gm4_furniture_last_hit matches ..4 run function gm4_furniture:break/destroy | ||
# otherwise store this hit time in furniture's score for the next check | ||
execute unless score $check_break gm4_furniture_last_hit matches ..4 run scoreboard players operation @s gm4_furniture_last_hit = $hit gm4_furniture_last_hit | ||
|
||
# hit sounds | ||
playsound minecraft:entity.armor_stand.hit block @a[distance=..8] ~ ~ ~ 1 1 | ||
playsound minecraft:entity.player.attack.strong block @a[distance=..8] ~ ~ ~ 1 1 |
6 changes: 5 additions & 1 deletion
6
gm4_furniture/data/gm4_furniture/functions/break/remove_block.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# remove this furniture block | ||
# @s = furniture interaction entity | ||
# at @s | ||
# run from break/destroy | ||
|
||
execute positioned ~0.0001 ~0.5001 ~0.0001 run setblock ~ ~ ~ air | ||
execute positioned ~0.0001 ~0.5001 ~0.0001 run fill ~ ~ ~ ~ ~ ~ air replace #gm4_furniture:furniture_blocks | ||
execute positioned ~-0.4999 ~0.0001 ~-0.4999 run kill @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] | ||
kill @s |
4 changes: 4 additions & 0 deletions
4
gm4_furniture/data/gm4_furniture/functions/break/remove_furniture_station.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# remove the flower pot and wandering trader when a furniture station is destroyed | ||
# furniture station interaction entity | ||
# at @s | ||
# run from break/destroy | ||
|
||
setblock ~ ~2 ~ air | ||
execute as @e[type=wandering_trader,tag=gm4_furniture,distance=..4] if score @s gm4_furniture_id = $check_id gm4_furniture_id run tp @s ~ -100000 ~ |
18 changes: 7 additions & 11 deletions
18
gm4_furniture/data/gm4_furniture/functions/interact/detect.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
|
||
# detect interacting (right-click) on furniture | ||
# @s = player interacting with furniture | ||
# at @s | ||
advancement revoke @s only gm4_furniture:interact_with_furniture | ||
|
||
scoreboard players set $interaction_processed gm4_furniture_data 0 | ||
|
||
# check for painting | ||
execute if predicate gm4_furniture:holding_paintbrush run function gm4_furniture:interact/paint/detect | ||
|
||
# check for sitting | ||
execute if score $interaction_processed gm4_furniture_data matches 0 unless predicate gm4_furniture:holding_paintbrush run function gm4_furniture:interact/sit/detect | ||
|
||
# cleanup if nothing else triggered | ||
execute if score $interaction_processed gm4_furniture_data matches 0 as @e[type=interaction,tag=gm4_furniture,distance=..8] if data entity @s interaction run data remove entity @s interaction | ||
# find interaction entity that was interacted with | ||
tag @s add gm4_furniture_target | ||
execute as @e[type=interaction,tag=gm4_furniture,distance=..8] if data entity @s interaction at @s run function gm4_furniture:interact/process | ||
tag @s remove gm4_furniture_target |
9 changes: 7 additions & 2 deletions
9
gm4_furniture/data/gm4_furniture/functions/interact/paint/detect.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# detect interaction on paintable furniture by a player holding a paintbrush | ||
# @s = furniture's interacted interaction entity | ||
# at @s | ||
# run from interact/process | ||
|
||
data modify storage gm4_furniture:temp color set from entity @s SelectedItem.tag.display.color | ||
execute if data storage gm4_furniture:temp color as @e[type=interaction,tag=gm4_furniture.dyable,distance=..8] if data entity @s interaction at @s run function gm4_furniture:interact/paint/process | ||
# store color from paintbrush and process application if there is some | ||
data modify storage gm4_furniture:temp color set from entity @p[tag=gm4_furniture_target] SelectedItem.tag.display.color | ||
execute if data storage gm4_furniture:temp color run function gm4_furniture:interact/paint/process | ||
data remove storage gm4_furniture:temp color |
10 changes: 7 additions & 3 deletions
10
gm4_furniture/data/gm4_furniture/functions/interact/paint/process.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# check if this furniture should be painted | ||
# @s = furniture's interacted interaction entity | ||
# at @s | ||
# run from interact/paint/detect | ||
|
||
scoreboard players set $interaction_processed gm4_furniture_data 1 | ||
|
||
# find this furniture's main interaction entity and try to paint its linked item display | ||
scoreboard players operation $check_id gm4_furniture_id = @s gm4_furniture_id | ||
execute as @e[type=interaction,tag=gm4_furniture.main,distance=..8] if score @s gm4_furniture_id = $check_id gm4_furniture_id at @s positioned ~-0.4999 ~0.0001 ~-0.4999 as @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] store success score $paint_changed gm4_furniture_data run data modify entity @s item.tag.display.color set from storage gm4_furniture:temp color | ||
data remove entity @s interaction | ||
|
||
# if furniture was painted mark interaction as resolved and play paint sound | ||
execute if score $paint_changed gm4_furniture_data matches 1 run playsound item.dye.use player @a[distance=..8] ~ ~ ~ 1 1 | ||
execute if score $paint_changed gm4_furniture_data matches 1 run scoreboard players set $interaction_processed gm4_furniture_data 1 |
19 changes: 19 additions & 0 deletions
19
gm4_furniture/data/gm4_furniture/functions/interact/process.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# process interacting (right-click) on furniture | ||
# @s = furniture's interacted interaction entity | ||
# at @s | ||
# run from itneract/detect | ||
|
||
# first successful interaction will be used, any lower down this list will be ignored | ||
scoreboard players set $interaction_processed gm4_furniture_data 0 | ||
|
||
# check for custom interactions | ||
# TODO | ||
|
||
# check for painting | ||
execute if score $interaction_processed gm4_furniture_data matches 0 if entity @s[tag=gm4_furniture.dyable] if entity @p[tag=gm4_furniture_target,predicate=gm4_furniture:holding_paintbrush] run function gm4_furniture:interact/paint/detect | ||
|
||
# check for sitting | ||
execute if score $interaction_processed gm4_furniture_data matches 0 if entity @s[tag=gm4_furniture.sittable] positioned ~-0.4999 ~0.0001 ~-0.4999 run function gm4_furniture:interact/sit/process | ||
|
||
# cleanup | ||
data remove entity @s interaction |
4 changes: 0 additions & 4 deletions
4
gm4_furniture/data/gm4_furniture/functions/interact/sit/detect.mcfunction
This file was deleted.
Oops, something went wrong.
10 changes: 9 additions & 1 deletion
10
gm4_furniture/data/gm4_furniture/functions/interact/sit/process.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
# get interacting player to sit at this furniture block | ||
# @s = furniture's interacted interaction entity | ||
# at @s | ||
# run from interact/process | ||
|
||
# make player ride the linked item_display (if this is not the main interaction entity item_display will be invisible) | ||
# the item_display is offset from the ground to dictate sit height | ||
ride @p[tag=gm4_furniture_target] dismount | ||
ride @p[tag=gm4_furniture_target] mount @e[type=item_display,tag=gm4_furniture,dx=0,dy=0,dz=0,limit=1] | ||
data remove entity @s interaction | ||
|
||
# mark interaction as resolved | ||
scoreboard players set $interaction_processed gm4_furniture_data 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
gm4_furniture/data/gm4_furniture/functions/place/resolve_id.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...functions/interact/sawmill/hit.mcfunction → ...echnical/furniture_station/hit.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
# when a player punches the top block of a furniture station swap the category | ||
# @s = player hitting the furniture station wandering trader | ||
# at @s | ||
advancement revoke @s only gm4_furniture:hit_furniture_station | ||
|
||
execute as @e[type=wandering_trader,tag=gm4_furniture.furniture_station,distance=..8,nbt={HurtTime:10s}] at @s run say hit |
Oops, something went wrong.