Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rope Ladders Update #881

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type": "minecraft:villager",
"type": "minecraft:interaction",
"nbt": "{Tags:[\"gm4_rol_rcd_ladder\"]}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ execute if block ~ ~ ~ ladder align xyz positioned ~.5 ~ ~.5 run function gm4_ro

# loop
scoreboard players add $ray gm4_rol_data 1
execute if score $ray gm4_rol_data matches 0..4 unless score $ladder_found gm4_rol_data matches 1 positioned ^ ^ ^1 run function gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/ray
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ execute if entity @s[gamemode=!creative] run item modify entity @s weapon.mainha
advancement grant @s only gm4:rope_ladders

# place ladder
execute unless block ~ ~ ~ water run clone ~ ~1 ~ ~ ~1 ~ ~ ~ ~
execute if block ~ ~ ~ water run function gm4_rope_ladders:mechanics/ladder_placement/place_water_ladder
execute unless block ~ ~ ~ #gm4:water run clone ~ ~1 ~ ~ ~1 ~ ~ ~ ~
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically this means that if the ladder above is waterlogged it will incorrectly copy a waterlogged ladder. However the only method I found to do this is by replacing light blocks (as they are replaceable but stop water flow), so it's not a big deal.

execute if block ~ ~ ~ #gm4:water run function gm4_rope_ladders:mechanics/ladder_placement/place_water_ladder
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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.45 unless entity @e[type=villager,tag=gm4_rol_rcd_ladder,distance=..0.1] run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd
execute if block ~ ~ ~ ladder[facing=north] positioned ~ ~ ~0.45 unless entity @e[type=villager,tag=gm4_rol_rcd_ladder,distance=..0.1] run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd
execute if block ~ ~ ~ ladder[facing=west] positioned ~0.45 ~ ~ unless entity @e[type=villager,tag=gm4_rol_rcd_ladder,distance=..0.1] run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd
execute if block ~ ~ ~ ladder[facing=east] positioned ~-0.45 ~ ~ unless entity @e[type=villager,tag=gm4_rol_rcd_ladder,distance=..0.1] 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 ~ 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ execute if block ~ ~ ~ ladder align xyz positioned ~.5 ~ ~.5 unless block ~ ~1 ~

# loop
scoreboard players add $ray gm4_rol_data 1
execute if score $ray gm4_rol_data matches 0..5 unless score $found_ladder gm4_rol_data matches 1 positioned ^ ^ ^.5 run function gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/ray
execute if score $ray gm4_rol_data matches 0..30 unless score $found_ladder gm4_rol_data matches 1 positioned ^ ^ ^.1 run function gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/ray
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
# run from function: gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found

# visuals
particle wax_on ~ ~0.25 ~ 0 0 0 .01 3
particle wax_on ~ ~0.50 ~ 0 0 0 .01 3
particle wax_on ~ ~0.75 ~ 0 0 0 .01 3
particle wax_on ~ ~0.2 ~ 0 0 0 .01 3
particle wax_on ~ ~0.5 ~ 0 0 0 .01 3
particle wax_on ~ ~0.8 ~ 0 0 0 .01 3
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# loops as long as a "right click detection" villager exists
# loops as long as a "right click detection" interaction exists
# run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/spawn_rcd

# reset scoreboard
scoreboard players remove $rcd_found gm4_rol_data 1

# execute as rcd
execute as @e[type=villager,tag=gm4_rol_rcd_ladder,tag=gm4_rol_rcd] at @s store success score $rcd_found gm4_rol_data run function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/process
execute as @e[type=interaction,tag=gm4_rol_rcd_ladder,tag=gm4_rol_rcd] at @s store success score $rcd_found gm4_rol_data 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,9 +1,9 @@
# processes the "right click detection" villager so that it is despawned when unneeded
# processes the "right click detection" interaction so that it is despawned when unneeded
# run from function: gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop

# kill rcd if uneeded
execute unless entity @a[tag=gm4_rol_holding_ladder,distance=..5] run tp @s ~ -1000 ~
execute unless entity @a[tag=gm4_rol_holding_ladder,distance=..5] run tp @s ~ -1000 ~
execute unless block ~ ~ ~ ladder run tp @s ~ -1000 ~
execute if block ~ ~-1 ~ ladder unless block ~ ~1 ~ #gm4:air run tp @s ~ -1000 ~
execute if entity @e[type=villager,tag=gm4_rol_rcd_ladder,distance=0.1..10] run tp @s ~ -1000 ~
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 ~ #gm4: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
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# spawns a baby villager that handles right click detection
# spawns a baby 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

# spawn rcd
summon villager ~ ~100 ~ {NoGravity:1b,Silent:1b,Invulnerable:1b,NoAI:1b,Age:-2147483648,Tags:["gm4_rol_rcd","gm4_rol_rcd_ladder","smithed.entity","smithed.strict"],ActiveEffects:[{Id:14,Amplifier:0b,Duration:999999,ShowParticles:0b}],Offers:{}}
execute positioned ~ ~100 ~ run tp @e[type=villager,tag=gm4_rol_rcd_ladder,dx=0] ~ ~-100 ~
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"]}

# start loop
function gm4_rope_ladders:mechanics/right_click_detection/rcd_manager/loop
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
tag @s remove gm4_rol_holding_ladder

# check if player is holding rope ladder
execute if predicate gm4_rope_ladders:holding_ladder run function gm4_rope_ladders:player/holding_ladder
execute if entity @s[gamemode=!adventure] if predicate gm4_rope_ladders:holding_ladder run function gm4_rope_ladders:player/holding_ladder
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"values": [
"#gm4:air",
"water",
"#gm4_rope_ladders:valid_replace",
"minecraft:ladder"
]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file isn't used anywhere and could be removed

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"values": [
"#gm4:air",
"water"
"#gm4:replaceable"
]
}