Skip to content

Commit

Permalink
fix EVERYTHING
Browse files Browse the repository at this point in the history
  • Loading branch information
TheThanathor committed Aug 30, 2023
1 parent a22c161 commit 3d61925
Show file tree
Hide file tree
Showing 36 changed files with 252 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"criteria": {
"requirement": {
"hit_furniture": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"player": [
Expand Down Expand Up @@ -31,6 +31,11 @@
}
}
},
"requirements": [
[
"hit_furniture"
]
],
"rewards": {
"function": "gm4_furniture:break/detect_hit"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"criteria": {
"requirement": {
"hit_furniture_station": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"player": [
Expand Down Expand Up @@ -31,6 +31,11 @@
}
}
},
"requirements": [
[
"hit_furniture_station"
]
],
"rewards": {
"function": "gm4_furniture:interact/furniture_station/hit"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"criteria": {
"requirement": {
"interact_with_furniture": {
"trigger": "minecraft:player_interacted_with_entity",
"conditions": {
"player": [],
Expand All @@ -17,6 +17,11 @@
}
}
},
"requirements": [
[
"interact_with_furniture"
]
],
"rewards": {
"function": "gm4_furniture:interact/detect"
}
Expand Down
27 changes: 16 additions & 11 deletions gm4_furniture/data/gm4_furniture/advancements/place_furniture.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
"placed_furniture": {
"trigger": "minecraft:placed_block",
"conditions": {
"location": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:player_head"
],
"nbt": "{SkullOwner:{Properties:{textures:[{Signature:\"gm4_furniture\"}]}}}"
}
}
],
"player": [
{
"condition": "minecraft:value_check",
Expand All @@ -39,10 +28,26 @@
},
"range": 0
}
],
"location": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:player_head"
],
"nbt": "{SkullOwner:{Properties:{textures:[{Signature:\"gm4_furniture\"}]}}}"
}
}
]
}
}
},
"requirements": [
[
"placed_furniture"
]
],
"rewards": {
"function": "gm4_furniture:place/place_furniture"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"criteria": {
"requirement": {
"used_paintbrush": {
"trigger": "minecraft:player_interacted_with_entity",
"conditions": {
"player": [],
Expand All @@ -22,6 +22,11 @@
}
}
},
"requirements": [
[
"used_paintbrush"
]
],
"rewards": {
"function": "gm4_furniture:technical/paintbrush/used_on_horse"
}
Expand Down
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
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
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)
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
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
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
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 ~
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
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
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
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

This file was deleted.

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
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ execute if score $placement_blocked gm4_furniture_data matches 0 align y if enti
execute if score $placement_blocked gm4_furniture_data matches 1 run return 0
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]}

scoreboard players remove $depth gm4_furniture_data 1
execute if score $depth gm4_furniture_data matches 1.. positioned ^ ^ ^1 run function gm4_furniture:place/check_size/depth_loop
scoreboard players add $depth_done gm4_furniture_data 1
execute if score $depth_done gm4_furniture_data = $depth gm4_furniture_data run scoreboard players reset $depth_done gm4_furniture_data
execute if score $depth_done gm4_furniture_data < $depth gm4_furniture_data positioned ^ ^ ^-1 run function gm4_furniture:place/check_size/depth_loop
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
execute unless block ~ ~ ~ #gm4:replaceable run scoreboard players set $placement_blocked gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 0 align y if entity @e[type=interaction,tag=gm4_furniture,tag=!gm4_new_furniture,distance=..0.1] run scoreboard players set $placement_blocked gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 1 run return 0
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]}
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block","gm4_furniture.depth_marker"]}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# at the center of the placed block rotated along axis to face towards player or away from the wall, or at any placed marker
# run from any in place/furniture/

execute if score $depth gm4_furniture_data matches 3.. at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^-1 run function gm4_furniture:place/check_size/depth_offset
execute as @e[type=marker,tag=gm4_furniture.marked_block] run data modify entity @s Rotation set from storage gm4_furniture:data Rotation
execute if score $depth gm4_furniture_data matches 3.. at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^1 run function gm4_furniture:place/check_size/depth_offset
execute if score $depth gm4_furniture_data matches 3.. run scoreboard players remove $depth gm4_furniture_data 1
scoreboard players remove $depth gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^1 run function gm4_furniture:place/check_size/depth_loop
execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block,tag=!gm4_furniture.depth_marker] positioned ^ ^ ^-1 run function gm4_furniture:place/check_size/depth_loop
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ execute if score $placement_blocked gm4_furniture_data matches 0 align y if enti
execute if score $placement_blocked gm4_furniture_data matches 1 run return 0
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]}

scoreboard players remove $height gm4_furniture_data 1
execute if score $height gm4_furniture_data matches 1.. positioned ^ ^ ^1 run function gm4_furniture:place/check_size/height_loop
scoreboard players add $height_done gm4_furniture_data 1
execute if score $height_done gm4_furniture_data = $height gm4_furniture_data run scoreboard players reset $height_done gm4_furniture_data
execute if score $height_done gm4_furniture_data < $height gm4_furniture_data positioned ^ ^1 ^ run function gm4_furniture:place/check_size/height_loop
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
execute unless block ~ ~ ~ #gm4:replaceable run scoreboard players set $placement_blocked gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 0 align y if entity @e[type=interaction,tag=gm4_furniture,tag=!gm4_new_furniture,distance=..0.1] run scoreboard players set $placement_blocked gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 1 run return 0
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]}
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block","gm4_furniture.height_marker"]}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# run from any in place/furniture/

# height is only offset down if this is a wall placed furniture (painting)
execute as @e[type=marker,tag=gm4_furniture.marked_block] run data modify entity @s Rotation set from storage gm4_furniture:data Rotation
execute if score $height gm4_furniture_data matches 3.. if score $wall_only gm4_furniture_data matches 1 at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^-1 ^ run function gm4_furniture:place/check_size/height_offset
execute if score $height gm4_furniture_data matches 3.. if score $wall_only gm4_furniture_data matches 1 run scoreboard players remove $height gm4_furniture_data 1
scoreboard players remove $height gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block] positioned ^ ^ ^1 run function gm4_furniture:place/check_size/height_loop
execute if score $placement_blocked gm4_furniture_data matches 0 at @e[type=marker,tag=gm4_furniture.marked_block,tag=!gm4_furniture.height_marker] positioned ^ ^1 ^ run function gm4_furniture:place/check_size/height_loop
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ execute if score $placement_blocked gm4_furniture_data matches 1 run return 0
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]}

scoreboard players remove $length gm4_furniture_data 1
execute if score $length gm4_furniture_data matches 1.. positioned ^-1 ^ ^ run function gm4_furniture:place/check_size/length_loop
execute if score $length gm4_furniture_data matches 1.. positioned ^1 ^ ^ run function gm4_furniture:place/check_size/length_loop
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
execute unless block ~ ~ ~ #gm4:replaceable run scoreboard players set $placement_blocked gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 0 align y if entity @e[type=interaction,tag=gm4_furniture,tag=!gm4_new_furniture,distance=..0.1] run scoreboard players set $placement_blocked gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 1 run return 0
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block"]}
summon marker ~ ~ ~ {Tags:["gm4_furniture","gm4_furniture.marked_block","gm4_furniture.length_marker"]}
scoreboard players remove $length gm4_furniture_data 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# at the center of the placed block rotated along axis to face towards player or away from the wall
# run from any in place/furniture/

execute if score $length gm4_furniture_data matches 3.. positioned ^1 ^ ^ run function gm4_furniture:place/check_size/length_offset
execute if score $length gm4_furniture_data matches 3.. positioned ^-1 ^ ^ run function gm4_furniture:place/check_size/length_offset
scoreboard players remove $length gm4_furniture_data 1
execute if score $placement_blocked gm4_furniture_data matches 0 positioned ^-1 ^ ^ run function gm4_furniture:place/check_size/length_loop
execute if score $placement_blocked gm4_furniture_data matches 0 positioned ^1 ^ ^ run function gm4_furniture:place/check_size/length_loop
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# run the function belonging to the placed furniture
# @s = player that just placed a furniture player head
# at the center of the furniture player head that was placed
# run from place/prep_place
# $(function) = function path (gm4_furniture:place/furniture/<technical_id>)

$execute if score $rotation gm4_furniture_data matches 1 rotated 0 0 run function $(function)
$execute if score $rotation gm4_furniture_data matches 2 rotated 90 0 run function $(function)
Expand Down
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
Loading

0 comments on commit 3d61925

Please sign in to comment.