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 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/advancement/right_click_detection.json b/gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json index d0eac97e25..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 @@ -4,19 +4,25 @@ "trigger": "minecraft:player_interacted_with_entity", "conditions": { "player": [ + { + "condition": "minecraft:reference", + "name": "gm4_rope_ladders:holding_ladder" + }, { "condition": "minecraft:entity_properties", "entity": "this", "predicate": { + "type_specific": { + "type": "minecraft:player", + "gamemode": [ + "survival", + "creative" + ] + }, "nbt": "{Tags:[\"gm4_rol_holding_ladder\"]}" } } ], - "item": { - "items": [ - "minecraft:ladder" - ] - }, "entity": [ { "condition": "minecraft:entity_properties", 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/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 e57be7f2a5..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 "right click detection" villager 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 ace81b54af..0000000000 --- a/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction +++ /dev/null @@ -1,13 +0,0 @@ -# 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 -# 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 e695576acc..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 "right click detection" villager 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..e18890e4e8 --- /dev/null +++ b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/find_ladder.mcfunction @@ -0,0 +1,12 @@ +# @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 +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 + +# 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 de8562f0cb..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 @@ -1,12 +1,16 @@ -# @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 # 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 + # 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 96ee1b42df..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,17 +1,11 @@ # places a ladder when the scan finds a valid location -# @s = player that interacts with a "right click detection" villager 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/found +# 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 if entity @s[gamemode=!creative] run item modify entity @s weapon.mainhand gm4_rope_ladders:minus_one - -# 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 95bc6438cd..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 "right click detection" villager 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 62% 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 eb72132789..cd7eb4f9e8 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 "right click detection" villager 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 and self # 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 -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/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 deleted file mode 100644 index 6265c90106..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 "right click detection" villager 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/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 f2a43a909b..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 baby 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 {Glowing:1b,width:0.2f,height:1.05f,response:1b,Tags:["gm4_rol_rcd","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 ad1f4a9292..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,11 +1,13 @@ -# loops as long as a "right click detection" interaction exists -# run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd +# loops as long as a rcd interaction exists +# @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 # 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/process.mcfunction b/gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction index 01ad2d18a7..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 "right click detection" interaction so that it is despawned when unneeded +# 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/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 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 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/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 - } -] 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" + ] + } + } } } - } + ] } 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."