Skip to content
Open
2 changes: 2 additions & 0 deletions gm4_rope_ladders/beet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ meta:
credits:
Creator:
- Modulorium
Updated By:
- runcows
Icon Design:
- BPR
24 changes: 24 additions & 0 deletions gm4_rope_ladders/data/gm4_rope_ladders/advancement/id_init.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions gm4_rope_ladders/data/gm4_rope_ladders/function/init.mcfunction
Original file line number Diff line number Diff line change
@@ -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

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
}
}
]
}
2 changes: 1 addition & 1 deletion gm4_rope_ladders/translations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Loading