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 all 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 @@ -10,5 +10,6 @@ scoreboard players add $ladder_broken gm4_rol_data 1
playsound minecraft:block.scaffolding.fall ambient @a[distance=..15] ~ ~ ~ 1 .5

# break ladder and drop item
setblock ~ ~ ~ air
fill ~ ~ ~ ~ ~ ~ air replace ladder[waterlogged=false]
fill ~ ~ ~ ~ ~ ~ water replace ladder[waterlogged=true]
loot spawn ~ ~ ~ loot minecraft:blocks/ladder
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ scoreboard players set $loop gm4_rol_data 0
execute anchored eyes run function gm4_rope_ladders:mechanics/break_floating_ladders/scan_column/loop

# teleport all ladder items to top
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 1 if block ~ ~2 ~-1 #gm4_rope_ladders:valid_replace run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~ ~2 ~-1
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 2 if block ~ ~2 ~1 #gm4_rope_ladders:valid_replace run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~ ~2 ~1
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 3 if block ~-1 ~2 ~ #gm4_rope_ladders:valid_replace run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~-1 ~2 ~
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 4 if block ~1 ~2 ~ #gm4_rope_ladders:valid_replace run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~1 ~2 ~
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 1 if block ~ ~2 ~-1 #gm4:replaceable run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~ ~2 ~-1
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 2 if block ~ ~2 ~1 #gm4:replaceable run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~ ~2 ~1
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 3 if block ~-1 ~2 ~ #gm4:replaceable run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~-1 ~2 ~
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 4 if block ~1 ~2 ~ #gm4:replaceable run tp @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] ~1 ~2 ~
execute if score $rope_drop_mode gm4_rol_data matches 1 if score $rope_drop_direction gm4_rol_data matches 1..4 as @e[type=item,distance=..64,nbt={Item:{id:"minecraft:ladder"},Age:0s}] run data modify entity @s Motion set value []
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 @@ -12,6 +12,10 @@ execute if entity @s[gamemode=!creative] run item modify entity @s weapon.mainha
# 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

# 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 @@ -4,7 +4,7 @@
# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/init

# detect if ladder placement is valid
execute if block ~ ~ ~ #gm4_rope_ladders:valid_replace run function gm4_rope_ladders:mechanics/ladder_placement/scan_column/found
execute if block ~ ~ ~ #gm4:replaceable run function gm4_rope_ladders:mechanics/ladder_placement/scan_column/found

# loop
scoreboard players add $loop gm4_rol_data 1
Expand Down
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 @@ -4,9 +4,9 @@
# run from function: gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/init

# detect if player sees ladder
execute if block ~ ~ ~ ladder align xyz positioned ~.5 ~ ~.5 if block ~ ~-1 ~ #gm4_rope_ladders:valid_replace run function gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found
execute if block ~ ~ ~ ladder align xyz positioned ~.5 ~ ~.5 if block ~ ~-1 ~ #gm4:replaceable run function gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found
execute if block ~ ~ ~ ladder align xyz positioned ~.5 ~ ~.5 unless block ~ ~1 ~ ladder run function gm4_rope_ladders:mechanics/right_click_detection/detect_ladder_raycast/found

# 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
Expand Up @@ -6,4 +6,4 @@
scoreboard players reset @s gm4_rol_break_ladder

# execute as the broken ladder item
execute if entity @s[gamemode=!creative,gamemode=!spectator] as @e[type=item,distance=..7,limit=1,nbt={Item:{id:"minecraft:ladder"},Age:0s},sort=nearest] at @s if block ~ ~ ~ #gm4_rope_ladders:valid_replace if block ~ ~-1 ~ ladder align xyz positioned ~.5 ~-1 ~.5 run function gm4_rope_ladders:mechanics/break_floating_ladders/scan_column/init
execute if entity @s[gamemode=!creative,gamemode=!spectator] as @e[type=item,distance=..7,limit=1,nbt={Item:{id:"minecraft:ladder"},Age:0s},sort=nearest] at @s if block ~ ~ ~ #gm4:replaceable if block ~ ~-1 ~ ladder align xyz positioned ~.5 ~-1 ~.5 run function gm4_rope_ladders:mechanics/break_floating_ladders/scan_column/init
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"values": [
"#gm4:air",
"water",
"#gm4:replaceable",
"minecraft:ladder"
]
}

This file was deleted.

Loading