From 5d9854f30a9a9857491bfdd85f07158a3dc44bc4 Mon Sep 17 00:00:00 2001 From: runcows Date: Sun, 7 Sep 2025 08:35:59 +0900 Subject: [PATCH 01/11] Remove unnecessary stuff --- .../right_click_detection/rcd_manager/spawn_rcd.mcfunction | 2 +- .../gm4_rope_ladders/function/player/holding_ladder.mcfunction | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction index f2a43a909b..89073173ee 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction @@ -4,7 +4,7 @@ # run from function: gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found # spawn rcd -summon interaction ~0.0 ~0.0 ~0.0 {Glowing:1b,width:0.2f,height:1.05f,response:1b,Tags:["gm4_rol_rcd","gm4_rol_rcd_ladder","smithed.entity","smithed.strict"]} +summon interaction ~0.0 ~0.0 ~0.0 {width:0.2f,height:1.05f,response:1b,Tags:["gm4_rol_rcd","gm4_rol_rcd_ladder","smithed.entity","smithed.strict"]} # start loop function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/player/holding_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/player/holding_ladder.mcfunction index 47f0f8d451..e27d8e63ec 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/player/holding_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/player/holding_ladder.mcfunction @@ -4,7 +4,6 @@ # tag tag @s add gm4_rol_holding_ladder -tag @s remove gm4_rol_sees_ladder # check for ladder function gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/init From 8a543561628020c5a3b98d9394c18244105989c2 Mon Sep 17 00:00:00 2001 From: runcows Date: Sun, 7 Sep 2025 09:29:59 +0900 Subject: [PATCH 02/11] Add offhand support --- .../advancement/right_click_detection.json | 9 +++-- .../detect_ladder_raycast/found.mcfunction | 2 +- .../detect_ladder_raycast/init.mcfunction | 3 +- .../detect_ladder_raycast/ray.mcfunction | 2 +- .../interact_right_click_detection.mcfunction | 2 +- .../ladder_placement/place_ladder.mcfunction | 8 +++-- .../place_water_ladder.mcfunction | 2 +- .../scan_column/found.mcfunction | 7 ---- .../scan_column/init.mcfunction | 2 +- .../scan_column/loop.mcfunction | 4 +-- .../rcd_manager/loop.mcfunction | 2 +- .../rcd_manager/process.mcfunction | 2 +- .../rcd_manager/spawn_rcd.mcfunction | 2 +- .../predicate/holding_ladder.json | 36 ++++++++++++++----- 14 files changed, 47 insertions(+), 36 deletions(-) delete mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/found.mcfunction diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json b/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json index d0eac97e25..25f0ce14c6 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json +++ b/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json @@ -4,6 +4,10 @@ "trigger": "minecraft:player_interacted_with_entity", "conditions": { "player": [ + { + "condition": "minecraft:reference", + "name": "gm4_rope_ladders:holding_ladder" + }, { "condition": "minecraft:entity_properties", "entity": "this", @@ -12,11 +16,6 @@ } } ], - "item": { - "items": [ - "minecraft:ladder" - ] - }, "entity": [ { "condition": "minecraft:entity_properties", diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction index e57be7f2a5..c171ecacb4 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction @@ -1,5 +1,5 @@ # stops the raycast and gets read to scan downward -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at location of ladder block # run from function: gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/ray diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction index ace81b54af..4c39f4a869 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction @@ -1,5 +1,5 @@ # begins a raycast from the players head that moves forward until it finds a ladder block -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at @s # run from function: gm4_rope_ladders:mechanics/ladder_placement/interact_right_click_detection @@ -10,4 +10,3 @@ scoreboard players set $ladder_found gm4_rol_data 0 # detect if ladder is in front of player scoreboard players set $ray gm4_rol_data 0 execute anchored eyes run function gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/ray - diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction index e695576acc..b5cfd8166c 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction @@ -1,5 +1,5 @@ # raycast from the players head that moves forward until it finds a ladder block -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at @s anchored eyes, moving forward # run from function: gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/init diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction index de8562f0cb..5548f7eca4 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction @@ -1,4 +1,4 @@ -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at @s # run from advancement: gm4_rope_ladders:right_click_detection diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction index 96ee1b42df..e543ff93cc 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction @@ -1,13 +1,15 @@ # places a ladder when the scan finds a valid location -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at location of valid spot for ladder placement -# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/found +# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/loop # set scorebaord scoreboard players set $ladder_placed gm4_rol_data 1 # remove 1 ladder from players hand -execute if entity @s[gamemode=!creative] run item modify entity @s weapon.mainhand gm4_rope_ladders:minus_one +execute store success score $mainhand gm4_rol_data if items entity @s weapon.mainhand ladder +execute if score $mainhand gm4_rol_data matches 1 run item modify entity @s[gamemode=!creative] weapon.mainhand gm4_rope_ladders:minus_one +execute if score $mainhand gm4_rol_data matches 0 run item modify entity @s[gamemode=!creative] weapon.offhand gm4_rope_ladders:minus_one # grant advancement advancement grant @s only gm4:rope_ladders diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction index 95bc6438cd..7bb32b5a01 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction @@ -1,5 +1,5 @@ # places a ladder when the scan finds a valid location (in water) -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at location of valid spot for ladder placement (in water) # run from function: gm4_rope_ladders:mechanics/ladder_placement/place_ladder diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/found.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/found.mcfunction deleted file mode 100644 index d35285158d..0000000000 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/found.mcfunction +++ /dev/null @@ -1,7 +0,0 @@ -# stops the scan once it finds a valid location to place a ladder -# @s = player that interacts with a "right click detection" villager while holding ladder -# at location of valid spot for ladder placement -# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/loop - -# place ladder -function gm4_rope_ladders:mechanics/ladder_placement/place_ladder diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction index 6265c90106..144f35450e 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction @@ -1,5 +1,5 @@ # begins a scan downward until it finds a valid location to place a ladder -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at location of ladder block # run from function: gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/found diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/loop.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/loop.mcfunction index eb72132789..303273cea8 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/loop.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/loop.mcfunction @@ -1,10 +1,10 @@ # scans downward until it finds a valid location to place a ladder -# @s = player that interacts with a "right click detection" villager while holding ladder +# @s = player that interacts with a rcd interaction while holding ladder # at location of ladder block, moving downward # run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/init # detect if ladder placement is valid -execute if block ~ ~ ~ #gm4:replaceable run function gm4_rope_ladders:mechanics/ladder_placement/scan_column/found +execute if block ~ ~ ~ #gm4:replaceable run return run function gm4_rope_ladders:mechanics/ladder_placement/place_ladder # loop scoreboard players add $loop gm4_rol_data 1 diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction index ad1f4a9292..47d3daa306 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction @@ -1,4 +1,4 @@ -# loops as long as a "right click detection" interaction exists +# loops as long as a rcd interaction exists # run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd # reset scoreboard diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction index 01ad2d18a7..a518bc5dba 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction @@ -1,4 +1,4 @@ -# processes the "right click detection" interaction so that it is despawned when unneeded +# processes the rcd interaction so that it is despawned when unneeded # run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop scoreboard players set $rcd_found gm4_rol_data 1 diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction index 89073173ee..1315ea649d 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction @@ -1,4 +1,4 @@ -# spawns a baby interaction that handles right click detection +# spawns a interaction that handles right click detection # @s = player holding ladder # at position of ladder block, align xyz positioned ~.5 ~ ~.5 (varies based on rotation) # run from function: gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/predicate/holding_ladder.json b/gm4_rope_ladders/data/gm4_rope_ladders/predicate/holding_ladder.json index a963f25b99..da401c5d92 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/predicate/holding_ladder.json +++ b/gm4_rope_ladders/data/gm4_rope_ladders/predicate/holding_ladder.json @@ -1,13 +1,31 @@ { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "equipment": { - "mainhand": { - "items": [ - "minecraft:ladder" - ] + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "items": [ + "minecraft:ladder" + ] + } + } + } + }, + { + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "offhand": { + "items": [ + "minecraft:ladder" + ] + } + } } } - } + ] } From 96a3b038b816b418961905ad4efe7020c0872d7b Mon Sep 17 00:00:00 2001 From: runcows Date: Sun, 7 Sep 2025 09:32:13 +0900 Subject: [PATCH 03/11] replace minus one item modifier file with inline definition - this isn't necessary, but I feel like it might be better to have it inline --- .../mechanics/ladder_placement/place_ladder.mcfunction | 4 ++-- .../data/gm4_rope_ladders/item_modifier/minus_one.json | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/item_modifier/minus_one.json diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction index e543ff93cc..433632c74e 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction @@ -8,8 +8,8 @@ scoreboard players set $ladder_placed gm4_rol_data 1 # remove 1 ladder from players hand execute store success score $mainhand gm4_rol_data if items entity @s weapon.mainhand ladder -execute if score $mainhand gm4_rol_data matches 1 run item modify entity @s[gamemode=!creative] weapon.mainhand gm4_rope_ladders:minus_one -execute if score $mainhand gm4_rol_data matches 0 run item modify entity @s[gamemode=!creative] weapon.offhand gm4_rope_ladders:minus_one +execute if score $mainhand gm4_rol_data matches 1 run item modify entity @s[gamemode=!creative] weapon.mainhand {"function": "minecraft:set_count","count": -1,"add": true} +execute if score $mainhand gm4_rol_data matches 0 run item modify entity @s[gamemode=!creative] weapon.offhand {"function": "minecraft:set_count","count": -1,"add": true} # grant advancement advancement grant @s only gm4:rope_ladders diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/item_modifier/minus_one.json b/gm4_rope_ladders/data/gm4_rope_ladders/item_modifier/minus_one.json deleted file mode 100644 index a1f2c2a484..0000000000 --- a/gm4_rope_ladders/data/gm4_rope_ladders/item_modifier/minus_one.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "function": "minecraft:set_count", - "count": -1, - "add": true - } -] From abb3ab309842b7c8487cdd21ae2bb2ac975b8fb1 Mon Sep 17 00:00:00 2001 From: runcows Date: Sun, 7 Sep 2025 13:52:46 +0900 Subject: [PATCH 04/11] Modernize code --- .../detect_ladder_raycast/found.mcfunction | 10 ---------- .../detect_ladder_raycast/init.mcfunction | 12 ------------ .../detect_ladder_raycast/ray.mcfunction | 11 ----------- .../ladder_placement/find_ladder.mcfunction | 14 ++++++++++++++ .../interact_right_click_detection.mcfunction | 13 ++++++++++--- .../ladder_placement/place_ladder.mcfunction | 12 ++---------- .../place_water_ladder.mcfunction | 2 +- .../loop.mcfunction => scan_column.mcfunction} | 6 +++--- .../ladder_placement/scan_column/init.mcfunction | 8 -------- .../ladder_placement/successful_place.mcfunction | 15 +++++++++++++++ .../rcd_manager/loop.mcfunction | 2 +- .../rcd_manager/spawn_rcd.mcfunction | 2 +- 12 files changed, 47 insertions(+), 60 deletions(-) delete mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction delete mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction delete mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction create mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction rename gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/{scan_column/loop.mcfunction => scan_column.mcfunction} (80%) delete mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction create mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/successful_place.mcfunction diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction deleted file mode 100644 index c171ecacb4..0000000000 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction +++ /dev/null @@ -1,10 +0,0 @@ -# stops the raycast and gets read to scan downward -# @s = player that interacts with a rcd interaction while holding ladder -# at location of ladder block -# run from function: gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/ray - -# stop raycast -scoreboard players set $ladder_found gm4_rol_data 1 - -# scan downward to find valid ladder placement -function gm4_rope_ladders:mechanics/ladder_placement/scan_column/init diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction deleted file mode 100644 index 4c39f4a869..0000000000 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction +++ /dev/null @@ -1,12 +0,0 @@ -# begins a raycast from the players head that moves forward until it finds a ladder block -# @s = player that interacts with a rcd interaction while holding ladder -# at @s -# run from function: gm4_rope_ladders:mechanics/ladder_placement/interact_right_click_detection - -# reset scoreboard -scoreboard players set $ladder_placed gm4_rol_data 0 -scoreboard players set $ladder_found gm4_rol_data 0 - -# detect if ladder is in front of player -scoreboard players set $ray gm4_rol_data 0 -execute anchored eyes run function gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/ray diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction deleted file mode 100644 index b5cfd8166c..0000000000 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction +++ /dev/null @@ -1,11 +0,0 @@ -# raycast from the players head that moves forward until it finds a ladder block -# @s = player that interacts with a rcd interaction while holding ladder -# at @s anchored eyes, moving forward -# run from function: gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/init - -# detect if player sees ladder -execute if block ~ ~ ~ ladder align xyz positioned ~.5 ~ ~.5 run function gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/found - -# loop -scoreboard players add $ray gm4_rol_data 1 -execute if score $ray gm4_rol_data matches 0..40 unless score $ladder_found gm4_rol_data matches 1 positioned ^ ^ ^0.1 run function gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/ray diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction new file mode 100644 index 0000000000..ab19383188 --- /dev/null +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction @@ -0,0 +1,14 @@ +# @s = interacted rcd +# at player that interacts with a rcd interaction while holding ladder +# run from function: gm4_rope_ladders:mechanics/ladder_placement/interact_right_click_detection + +# fail if different gametime or different player +execute store result score $check_gametime gm4_rol_data run data get entity @s interaction.timestamp 1 +execute unless score $gametime gm4_rol_data = $check_gametime gm4_rol_data run return run data remove entity @s interaction + +execute store success score $different_UUID gm4_rol_data run data modify storage gm4_rope_ladders:temp UUID set from entity @s interaction.player +execute if score $different_UUID gm4_rol_data matches 1 run return fail + +# clear and continue +data remove entity @s interaction +execute at @s align xyz positioned ~.5 ~ ~.5 run function gm4_rope_ladders:mechanics/ladder_placement/scan_column diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction index 5548f7eca4..fcbc25778d 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction @@ -5,8 +5,15 @@ # revoke advancement advancement revoke @s only gm4_rope_ladders:right_click_detection +# reset +scoreboard players set $ladder_placed gm4_rol_data 0 +scoreboard players set $loop gm4_rol_data 0 +# store gametime and UUID +execute store result score $gametime gm4_rol_data run time query gametime +data modify storage gm4_rope_ladders:temp UUID set from entity @s UUID + # find ladder block -function gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/init +execute as @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..8] if data entity @s interaction run function gm4_rope_ladders:mechanics/ladder_placement/find_ladder -# play audio if ladder placed -execute if score $ladder_placed gm4_rol_data matches 1 run playsound minecraft:block.ladder.place ambient @a[distance=..15] ~ ~ ~ +# successful place +execute if score $ladder_placed gm4_rol_data matches 1 run function gm4_rope_ladders:mechanics/ladder_placement/successful_place diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction index 433632c74e..72f31c71ad 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction @@ -1,19 +1,11 @@ # places a ladder when the scan finds a valid location -# @s = player that interacts with a rcd interaction while holding ladder +# @s = interacted rcd # at location of valid spot for ladder placement -# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/loop +# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column # set scorebaord scoreboard players set $ladder_placed gm4_rol_data 1 -# remove 1 ladder from players hand -execute store success score $mainhand gm4_rol_data if items entity @s weapon.mainhand ladder -execute if score $mainhand gm4_rol_data matches 1 run item modify entity @s[gamemode=!creative] weapon.mainhand {"function": "minecraft:set_count","count": -1,"add": true} -execute if score $mainhand gm4_rol_data matches 0 run item modify entity @s[gamemode=!creative] weapon.offhand {"function": "minecraft:set_count","count": -1,"add": true} - -# grant advancement -advancement grant @s only gm4:rope_ladders - # break block execute unless block ~ ~ ~ #gm4:water run setblock ~ ~ ~ air destroy execute if block ~ ~ ~ #gm4:water run setblock ~ ~ ~ water destroy diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction index 7bb32b5a01..72d2b57427 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_water_ladder.mcfunction @@ -1,5 +1,5 @@ # places a ladder when the scan finds a valid location (in water) -# @s = player that interacts with a rcd interaction while holding ladder +# @s = interacted rcd # at location of valid spot for ladder placement (in water) # run from function: gm4_rope_ladders:mechanics/ladder_placement/place_ladder diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/loop.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction similarity index 80% rename from gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/loop.mcfunction rename to gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction index 303273cea8..e6321f61ad 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/loop.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction @@ -1,11 +1,11 @@ # scans downward until it finds a valid location to place a ladder -# @s = player that interacts with a rcd interaction while holding ladder +# @s = interacted rcd # at location of ladder block, moving downward -# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/init +# run from function: gm4_rope_ladders:mechanics/ladder_placement/find_ladder # detect if ladder placement is valid execute if block ~ ~ ~ #gm4:replaceable run return run function gm4_rope_ladders:mechanics/ladder_placement/place_ladder # loop scoreboard players add $loop gm4_rol_data 1 -execute if score $loop gm4_rol_data matches 0..511 unless score $ladder_placed gm4_rol_data matches 1 if block ~ ~-1 ~ #gm4_rope_ladders:ladder_scan positioned ~ ~-1 ~ run function gm4_rope_ladders:mechanics/ladder_placement/scan_column/loop +execute if score $loop gm4_rol_data matches 0..511 unless score $ladder_placed gm4_rol_data matches 1 if block ~ ~-1 ~ #gm4_rope_ladders:ladder_scan positioned ~ ~-1 ~ run function gm4_rope_ladders:mechanics/ladder_placement/scan_column diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction deleted file mode 100644 index 144f35450e..0000000000 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column/init.mcfunction +++ /dev/null @@ -1,8 +0,0 @@ -# begins a scan downward until it finds a valid location to place a ladder -# @s = player that interacts with a rcd interaction while holding ladder -# at location of ladder block -# run from function: gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/found - -# check for valid ladder placement location -scoreboard players set $loop gm4_rol_data 0 -execute anchored eyes run function gm4_rope_ladders:mechanics/ladder_placement/scan_column/loop diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/successful_place.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/successful_place.mcfunction new file mode 100644 index 0000000000..964ee5c515 --- /dev/null +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/successful_place.mcfunction @@ -0,0 +1,15 @@ +# effects after a sucessful place +# @s = player that interacts with a rcd interaction while holding ladder +# at @s +# run from function: gm4_rope_ladders:mechanics/ladder_placement/interact_right_click_detection + +# sound +playsound minecraft:block.ladder.place ambient @a[distance=..15] ~ ~ ~ + +# remove 1 ladder from players hand +execute store success score $mainhand gm4_rol_data if items entity @s weapon.mainhand ladder +execute if score $mainhand gm4_rol_data matches 1 run item modify entity @s[gamemode=!creative] weapon.mainhand {"function": "minecraft:set_count","count": -1,"add": true} +execute if score $mainhand gm4_rol_data matches 0 run item modify entity @s[gamemode=!creative] weapon.offhand {"function": "minecraft:set_count","count": -1,"add": true} + +# grant advancement +advancement grant @s only gm4:rope_ladders diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction index 47d3daa306..c983601606 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction @@ -5,7 +5,7 @@ scoreboard players remove $rcd_found gm4_rol_data 1 # execute as rcd -execute as @e[type=interaction,tag=gm4_rol_rcd_ladder,tag=gm4_rol_rcd] at @s run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/process +execute as @e[type=interaction,tag=gm4_rol_rcd_ladder] at @s run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/process # loop execute if score $rcd_found gm4_rol_data matches -9.. run schedule function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop 10t diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction index 1315ea649d..f1b3f36593 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction @@ -4,7 +4,7 @@ # run from function: gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found # spawn rcd -summon interaction ~0.0 ~0.0 ~0.0 {width:0.2f,height:1.05f,response:1b,Tags:["gm4_rol_rcd","gm4_rol_rcd_ladder","smithed.entity","smithed.strict"]} +summon interaction ~0.0 ~0.0 ~0.0 {width:0.2f,height:1.05f,response:1b,Tags:["gm4_rol_rcd_ladder","smithed.entity","smithed.strict"]} # start loop function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop From c8d594a0395401956ca143ba928149337165706d Mon Sep 17 00:00:00 2001 From: runcows Date: Sun, 7 Sep 2025 14:18:55 +0900 Subject: [PATCH 05/11] Fix multiplayer incompatibility with rcd interactions - and a few minor things i missed in a previous commit --- .../gm4_rope_ladders/advancement/id_init.json | 24 +++++++++++++++++++ .../gm4_rope_ladders/function/init.mcfunction | 10 ++++---- .../ladder_placement/scan_column.mcfunction | 2 +- .../detect_ladder_raycast/found.mcfunction | 11 +++++---- ...n_rcd.mcfunction => create_rcd.mcfunction} | 9 +++---- .../rcd_manager/loop.mcfunction | 4 +++- .../rcd_manager/process.mcfunction | 16 +++++++++---- .../function/player/set_id.mcfunction | 9 +++++++ 8 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/advancement/id_init.json rename gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/{spawn_rcd.mcfunction => create_rcd.mcfunction} (50%) create mode 100644 gm4_rope_ladders/data/gm4_rope_ladders/function/player/set_id.mcfunction diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/advancement/id_init.json b/gm4_rope_ladders/data/gm4_rope_ladders/advancement/id_init.json new file mode 100644 index 0000000000..95a278dc1b --- /dev/null +++ b/gm4_rope_ladders/data/gm4_rope_ladders/advancement/id_init.json @@ -0,0 +1,24 @@ +{ + "criteria": { + "no_score": { + "trigger": "minecraft:location", + "conditions": { + "player": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:entity_scores", + "entity": "this", + "scores": { + "gm4_rol_id": {} + } + } + } + ] + } + } + }, + "rewards": { + "function": "gm4_rope_ladders:player/set_id" + } +} diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/init.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/init.mcfunction index dbc28a51f5..cb5b27bbe9 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/init.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/init.mcfunction @@ -1,11 +1,13 @@ -scoreboard objectives add gm4_rol_data dummy -scoreboard objectives add gm4_rol_break_ladder minecraft.mined:minecraft.ladder - - execute unless score rope_ladders gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Rope Ladders"} execute unless score rope_ladders gm4_earliest_version < rope_ladders gm4_modules run scoreboard players operation rope_ladders gm4_earliest_version = rope_ladders gm4_modules scoreboard players set rope_ladders gm4_modules 1 +scoreboard objectives add gm4_rol_data dummy +scoreboard objectives add gm4_rol_break_ladder minecraft.mined:minecraft.ladder +scoreboard objectives add gm4_rol_id dummy +execute unless score $next gm4_rol_id matches 0.. run scoreboard players set $next gm4_rol_id 0 + + schedule function gm4_rope_ladders:main 10t schedule function gm4_rope_ladders:tick 11t diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction index e6321f61ad..cd7eb4f9e8 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction @@ -1,7 +1,7 @@ # scans downward until it finds a valid location to place a ladder # @s = interacted rcd # at location of ladder block, moving downward -# run from function: gm4_rope_ladders:mechanics/ladder_placement/find_ladder +# run from function: gm4_rope_ladders:mechanics/ladder_placement/find_ladder and self # detect if ladder placement is valid execute if block ~ ~ ~ #gm4:replaceable run return run function gm4_rope_ladders:mechanics/ladder_placement/place_ladder diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/detect_ladder_raycast/found.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/detect_ladder_raycast/found.mcfunction index d9e82cc0dd..811f97f003 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/detect_ladder_raycast/found.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/detect_ladder_raycast/found.mcfunction @@ -3,8 +3,9 @@ # at position of ladder block, align xyz positioned ~.5 ~ ~.5 # run from function: gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/ray -# set scoreboard +# set scores scoreboard players set $found_ladder gm4_rol_data 1 +scoreboard players operation $player gm4_rol_id = @s gm4_rol_id # visuals execute if block ~ ~ ~ ladder[facing=south] positioned ~ ~ ~-0.35 run function gm4_rope_ladders:mechanics/right_click_detection/display_particles @@ -13,7 +14,7 @@ execute if block ~ ~ ~ ladder[facing=west] positioned ~0.35 ~ ~ run function gm4 execute if block ~ ~ ~ ladder[facing=east] positioned ~-0.35 ~ ~ run function gm4_rope_ladders:mechanics/right_click_detection/display_particles # spawn rcd -execute if block ~ ~ ~ ladder[facing=south] positioned ~ ~ ~-0.39 positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd -execute if block ~ ~ ~ ladder[facing=north] positioned ~ ~ ~0.39 positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd -execute if block ~ ~ ~ ladder[facing=west] positioned ~0.39 ~ ~ positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd -execute if block ~ ~ ~ ladder[facing=east] positioned ~-0.39 ~ ~ positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd +execute if block ~ ~ ~ ladder[facing=south] positioned ~ ~ ~-0.39 positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ summon interaction run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/create_rcd +execute if block ~ ~ ~ ladder[facing=north] positioned ~ ~ ~0.39 positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ summon interaction run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/create_rcd +execute if block ~ ~ ~ ladder[facing=west] positioned ~0.39 ~ ~ positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ summon interaction run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/create_rcd +execute if block ~ ~ ~ ladder[facing=east] positioned ~-0.39 ~ ~ positioned ~ ~-0.05 ~ unless entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..0.1] positioned ~ ~0.05 ~ summon interaction run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/create_rcd diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/create_rcd.mcfunction similarity index 50% rename from gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction rename to gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/create_rcd.mcfunction index f1b3f36593..af73280f97 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/spawn_rcd.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/create_rcd.mcfunction @@ -1,10 +1,11 @@ -# spawns a interaction that handles right click detection -# @s = player holding ladder +# sets up an interaction that handles right click detection +# @s = new interaction # at position of ladder block, align xyz positioned ~.5 ~ ~.5 (varies based on rotation) # run from function: gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found -# spawn rcd -summon interaction ~0.0 ~0.0 ~0.0 {width:0.2f,height:1.05f,response:1b,Tags:["gm4_rol_rcd_ladder","smithed.entity","smithed.strict"]} +# init +data merge entity @s {width:0.2f,height:1.05f,response:1b,Tags:["gm4_rol_rcd_ladder","smithed.entity","smithed.strict"]} +scoreboard players operation @s gm4_rol_id = $player gm4_rol_id # start loop function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction index c983601606..8561dabd42 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction @@ -1,5 +1,7 @@ # loops as long as a rcd interaction exists -# run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd +# @s = unspecified +# at unspecified +# run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd and self # reset scoreboard scoreboard players remove $rcd_found gm4_rol_data 1 diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction index a518bc5dba..6b5d363e1b 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction @@ -1,11 +1,17 @@ # processes the rcd interaction so that it is despawned when unneeded +# @s = gm4_rol_rcd_ladder interaction +# at @s # run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop scoreboard players set $rcd_found gm4_rol_data 1 # kill rcd if uneeded -scoreboard players set $killed_rcd gm4_rol_data 0 -execute if score $killed_rcd gm4_rol_data matches 0 store success score $killed_rcd gm4_rol_data unless entity @a[tag=gm4_rol_holding_ladder,distance=..5] run kill @s -execute if score $killed_rcd gm4_rol_data matches 0 store success score $killed_rcd gm4_rol_data unless block ~ ~ ~ ladder run kill @s -execute if score $killed_rcd gm4_rol_data matches 0 store success score $killed_rcd gm4_rol_data if block ~ ~-1 ~ ladder unless block ~ ~1 ~ #minecraft:air run kill @s -execute if score $killed_rcd gm4_rol_data matches 0 store success score $killed_rcd gm4_rol_data if entity @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=0.1..10] run kill @s +execute unless entity @p[tag=gm4_rol_holding_ladder,distance=..5] run return run kill @s +execute unless block ~ ~ ~ ladder run return run kill @s +execute if block ~ ~-1 ~ ladder unless block ~ ~1 ~ #minecraft:air run return run kill @s + +# kill if multiple interaction with the same id, which therefore belong to the same player +scoreboard players set $duplicate_exists gm4_rol_data 0 +scoreboard players operation $check_id gm4_rol_id = @s gm4_rol_id +execute as @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=0.1..16] if score @s gm4_rol_id = $check_id gm4_rol_id run scoreboard players set $duplicate_exists gm4_rol_data 1 +execute if score $duplicate_exists gm4_rol_data matches 1 run kill @s diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/player/set_id.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/player/set_id.mcfunction new file mode 100644 index 0000000000..b407644bc7 --- /dev/null +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/player/set_id.mcfunction @@ -0,0 +1,9 @@ +# @s = player +# at @s +# run from advancement: gm4_rope_ladders:id_init + +# revoke to handle username changes +advancement revoke @s only gm4_rope_ladders:id_init + +scoreboard players operation @s gm4_rol_id = $next gm4_rol_id +scoreboard players add $next gm4_rol_id 1 From df1d50a84e17232733732fd7597ced90b78b061e Mon Sep 17 00:00:00 2001 From: runcows Date: Sun, 7 Sep 2025 14:21:42 +0900 Subject: [PATCH 06/11] I've suffered enough --- gm4_rope_ladders/beet.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gm4_rope_ladders/beet.yaml b/gm4_rope_ladders/beet.yaml index 63ac79896b..8f96321043 100644 --- a/gm4_rope_ladders/beet.yaml +++ b/gm4_rope_ladders/beet.yaml @@ -31,5 +31,7 @@ meta: credits: Creator: - Modulorium + Updated By: + - runcows Icon Design: - BPR From 0f61516490e246bc24cc15d2d2f93fe90c3c7652 Mon Sep 17 00:00:00 2001 From: runcows Date: Sun, 7 Sep 2025 15:21:24 +0900 Subject: [PATCH 07/11] Interaction doesn't need to check UUID actually --- .../mechanics/ladder_placement/find_ladder.mcfunction | 5 +---- .../interact_right_click_detection.mcfunction | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction index ab19383188..cbd9b8cbf5 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction @@ -2,13 +2,10 @@ # at player that interacts with a rcd interaction while holding ladder # run from function: gm4_rope_ladders:mechanics/ladder_placement/interact_right_click_detection -# fail if different gametime or different player +# fail if different gametime execute store result score $check_gametime gm4_rol_data run data get entity @s interaction.timestamp 1 execute unless score $gametime gm4_rol_data = $check_gametime gm4_rol_data run return run data remove entity @s interaction -execute store success score $different_UUID gm4_rol_data run data modify storage gm4_rope_ladders:temp UUID set from entity @s interaction.player -execute if score $different_UUID gm4_rol_data matches 1 run return fail - # clear and continue data remove entity @s interaction execute at @s align xyz positioned ~.5 ~ ~.5 run function gm4_rope_ladders:mechanics/ladder_placement/scan_column diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction index fcbc25778d..63a25b057f 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction @@ -8,9 +8,8 @@ advancement revoke @s only gm4_rope_ladders:right_click_detection # reset scoreboard players set $ladder_placed gm4_rol_data 0 scoreboard players set $loop gm4_rol_data 0 -# store gametime and UUID +# store gametime execute store result score $gametime gm4_rol_data run time query gametime -data modify storage gm4_rope_ladders:temp UUID set from entity @s UUID # find ladder block execute as @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..8] if data entity @s interaction run function gm4_rope_ladders:mechanics/ladder_placement/find_ladder From af5f317bcbfcfcc35003ae028e175de611138474 Mon Sep 17 00:00:00 2001 From: runcows Date: Mon, 8 Sep 2025 08:48:06 +0900 Subject: [PATCH 08/11] Move gametime query to `find_ladder` - where its actually used... --- .../function/mechanics/ladder_placement/find_ladder.mcfunction | 1 + .../ladder_placement/interact_right_click_detection.mcfunction | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction index cbd9b8cbf5..e18890e4e8 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction @@ -3,6 +3,7 @@ # run from function: gm4_rope_ladders:mechanics/ladder_placement/interact_right_click_detection # fail if different gametime +execute store result score $gametime gm4_rol_data run time query gametime execute store result score $check_gametime gm4_rol_data run data get entity @s interaction.timestamp 1 execute unless score $gametime gm4_rol_data = $check_gametime gm4_rol_data run return run data remove entity @s interaction diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction index 63a25b057f..21f119469e 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction @@ -8,8 +8,6 @@ advancement revoke @s only gm4_rope_ladders:right_click_detection # reset scoreboard players set $ladder_placed gm4_rol_data 0 scoreboard players set $loop gm4_rol_data 0 -# store gametime -execute store result score $gametime gm4_rol_data run time query gametime # find ladder block execute as @e[type=interaction,tag=gm4_rol_rcd_ladder,distance=..8] if data entity @s interaction run function gm4_rope_ladders:mechanics/ladder_placement/find_ladder From 02a6205dd4534de334b6396f8f59d71927d3cd81 Mon Sep 17 00:00:00 2001 From: runcows Date: Mon, 8 Sep 2025 08:48:59 +0900 Subject: [PATCH 09/11] Add adventure mode fail - rope ladders has been functioning with adventure mode?? --- .../ladder_placement/interact_right_click_detection.mcfunction | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction index 21f119469e..12fc4bb108 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction @@ -5,6 +5,9 @@ # revoke advancement advancement revoke @s only gm4_rope_ladders:right_click_detection +# fail if adventure mode +execute if entity @s[gamemode=adventure] run return fail + # reset scoreboard players set $ladder_placed gm4_rol_data 0 scoreboard players set $loop gm4_rol_data 0 From fa5ef0ebf5232eca7bec6424d560a187f0003224 Mon Sep 17 00:00:00 2001 From: runcows Date: Tue, 9 Sep 2025 05:54:30 +0900 Subject: [PATCH 10/11] Move adventure check to advancement --- .../advancement/right_click_detection.json | 7 +++++++ .../interact_right_click_detection.mcfunction | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json b/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json index 25f0ce14c6..3e25788485 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json +++ b/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json @@ -12,6 +12,13 @@ "condition": "minecraft:entity_properties", "entity": "this", "predicate": { + "type_specific": { + "type": "minecraft:player", + "gamemode": [ + "survival", + "creative" + ] + }, "nbt": "{Tags:[\"gm4_rol_holding_ladder\"]}" } } diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction index 12fc4bb108..21f119469e 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/interact_right_click_detection.mcfunction @@ -5,9 +5,6 @@ # revoke advancement advancement revoke @s only gm4_rope_ladders:right_click_detection -# fail if adventure mode -execute if entity @s[gamemode=adventure] run return fail - # reset scoreboard players set $ladder_placed gm4_rol_data 0 scoreboard players set $loop gm4_rol_data 0 From d672266637c3a259077a15784e98854db8bdc5be Mon Sep 17 00:00:00 2001 From: runcows Date: Sat, 4 Oct 2025 19:32:20 +0900 Subject: [PATCH 11/11] Fix Guidebook Translation key having potion_swords ??? --- .../data/gm4_rope_ladders/guidebook/rope_ladders.json | 2 +- gm4_rope_ladders/translations.csv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gm4_rope_ladders/data/gm4_rope_ladders/guidebook/rope_ladders.json b/gm4_rope_ladders/data/gm4_rope_ladders/guidebook/rope_ladders.json index f476652084..8aa723c459 100644 --- a/gm4_rope_ladders/data/gm4_rope_ladders/guidebook/rope_ladders.json +++ b/gm4_rope_ladders/data/gm4_rope_ladders/guidebook/rope_ladders.json @@ -58,7 +58,7 @@ ], [ { - "translate": "text.gm4.guidebook.potion_swords.breaking", + "translate": "text.gm4.guidebook.rope_ladders.breaking", "fallback": "Breaking a ladder at the top of a rope ladder will break all other rope ladders below, causing the items to appear at the top of the ladder that was broken." } ] diff --git a/gm4_rope_ladders/translations.csv b/gm4_rope_ladders/translations.csv index 6a503f8ef9..f336386379 100644 --- a/gm4_rope_ladders/translations.csv +++ b/gm4_rope_ladders/translations.csv @@ -4,4 +4,4 @@ advancement.gm4.rope_ladders.description,Place a Rope Ladder text.gm4.guidebook.module_desc.rope_ladders,Climbing downward has never been easier! text.gm4.guidebook.rope_ladders.description,Ladders can be placed on other ladders to extend the ladder downward. text.gm4.guidebook.rope_ladders.extend_downwards,Looking at a ladder while holding ladders will cause particles to appear. Placing ladders on this particle will extend the ladder downwards.\n\nRope ladders will break if there are no other ladders above them. -text.gm4.guidebook.potion_swords.breaking,"Breaking a ladder at the top of a rope ladder will break all other rope ladders below, causing the items to appear at the top of the ladder that was broken." +text.gm4.guidebook.rope_ladders.breaking,"Breaking a ladder at the top of a rope ladder will break all other rope ladders below, causing the items to appear at the top of the ladder that was broken."