Skip to content

Commit bd51bef

Browse files
runcowsBPR02
andauthored
Modernize Rope Ladders (#1155)
* Remove unnecessary stuff * Add offhand support * 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 * Modernize code * Fix multiplayer incompatibility with rcd interactions - and a few minor things i missed in a previous commit * I've suffered enough * Interaction doesn't need to check UUID actually * Move gametime query to `find_ladder` - where its actually used... * Add adventure mode fail - rope ladders has been functioning with adventure mode?? * Move adventure check to advancement * Fix Guidebook Translation key having potion_swords ??? * Update Header in gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/loop.mcfunction Co-authored-by: BPR <dev@bpr02.com> * Update gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/rcd_manager/process.mcfunction Co-authored-by: BPR <dev@bpr02.com> * Update gm4_rope_ladders/data/gm4_rope_ladders/function/player/set_id.mcfunction Co-authored-by: BPR <dev@bpr02.com> * Update gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/scan_column.mcfunction Co-authored-by: BPR <dev@bpr02.com> * Remove score initialization for $next * Reorder rcd_manager/process * Adjust `find_ladder` to be more readable - (feedback from Bloo on Lively Lily Pads) * Adjust `right_click_detection` advancement according to review * Condense `detect_ladder_raycast` * Update gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/right_click_detection/detect_ladder_raycast/ray.mcfunction Co-authored-by: BPR <dev@bpr02.com> * Forgot to anchor eyes! --------- Co-authored-by: BPR <dev@bpr02.com>
1 parent 8db7bdc commit bd51bef

28 files changed

+174
-142
lines changed

gm4_rope_ladders/beet.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ meta:
3131
credits:
3232
Creator:
3333
- Modulorium
34+
Updated By:
35+
- runcows
3436
Icon Design:
3537
- BPR
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"criteria": {
3+
"no_score": {
4+
"trigger": "minecraft:location",
5+
"conditions": {
6+
"player": [
7+
{
8+
"condition": "minecraft:inverted",
9+
"term": {
10+
"condition": "minecraft:entity_scores",
11+
"entity": "this",
12+
"scores": {
13+
"gm4_rol_id": {}
14+
}
15+
}
16+
}
17+
]
18+
}
19+
}
20+
},
21+
"rewards": {
22+
"function": "gm4_rope_ladders:player/set_id"
23+
}
24+
}

gm4_rope_ladders/data/gm4_rope_ladders/advancement/right_click_detection.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,37 @@
44
"trigger": "minecraft:player_interacted_with_entity",
55
"conditions": {
66
"player": [
7+
{
8+
"condition": "minecraft:reference",
9+
"name": "gm4_rope_ladders:holding_ladder"
10+
},
711
{
812
"condition": "minecraft:entity_properties",
913
"entity": "this",
1014
"predicate": {
11-
"nbt": "{Tags:[\"gm4_rol_holding_ladder\"]}"
15+
"type_specific": {
16+
"type": "minecraft:player",
17+
"gamemode": [
18+
"survival",
19+
"creative"
20+
]
21+
}
1222
}
1323
}
1424
],
15-
"item": {
16-
"items": [
17-
"minecraft:ladder"
18-
]
19-
},
2025
"entity": [
2126
{
2227
"condition": "minecraft:entity_properties",
2328
"entity": "this",
2429
"predicate": {
25-
"type": "minecraft:interaction",
26-
"nbt": "{Tags:[\"gm4_rol_rcd_ladder\"]}"
30+
"type": "minecraft:interaction"
31+
}
32+
},
33+
{
34+
"condition": "minecraft:entity_scores",
35+
"entity": "this",
36+
"scores": {
37+
"gm4_rol_id": {}
2738
}
2839
}
2940
]

gm4_rope_ladders/data/gm4_rope_ladders/function/init.mcfunction

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
scoreboard objectives add gm4_rol_data dummy
2-
scoreboard objectives add gm4_rol_break_ladder minecraft.mined:minecraft.ladder
3-
4-
51
execute unless score rope_ladders gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Rope Ladders"}
62
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
73
scoreboard players set rope_ladders gm4_modules 1
84

5+
scoreboard objectives add gm4_rol_data dummy
6+
scoreboard objectives add gm4_rol_break_ladder minecraft.mined:minecraft.ladder
7+
scoreboard objectives add gm4_rol_id dummy
8+
9+
910
schedule function gm4_rope_ladders:main 10t
1011
schedule function gm4_rope_ladders:tick 11t
1112

gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/found.mcfunction

Lines changed: 0 additions & 10 deletions
This file was deleted.

gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/init.mcfunction

Lines changed: 0 additions & 13 deletions
This file was deleted.

gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/detect_ladder_raycast/ray.mcfunction

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# @s = interacted rcd
2+
# at player that interacts with a rcd interaction while holding ladder
3+
# run from function: gm4_rope_ladders:mechanics/ladder_placement/interact_right_click_detection
4+
5+
# fail if different gametime
6+
execute store result score $gametime gm4_rol_data run time query gametime
7+
execute store result score $check_gametime gm4_rol_data run data get entity @s interaction.timestamp 1
8+
9+
data remove entity @s interaction
10+
execute unless score $gametime gm4_rol_data = $check_gametime gm4_rol_data run return fail
11+
12+
# continue
13+
execute at @s align xyz positioned ~.5 ~ ~.5 run function gm4_rope_ladders:mechanics/ladder_placement/scan_column
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
# @s = player that interacts with a "right click detection" villager while holding ladder
1+
# @s = player that interacts with a rcd interaction while holding ladder
22
# at @s
33
# run from advancement: gm4_rope_ladders:right_click_detection
44

55
# revoke advancement
66
advancement revoke @s only gm4_rope_ladders:right_click_detection
77

8+
# reset
9+
scoreboard players set $ladder_placed gm4_rol_data 0
10+
scoreboard players set $loop gm4_rol_data 0
11+
812
# find ladder block
9-
function gm4_rope_ladders:mechanics/ladder_placement/detect_ladder_raycast/init
13+
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
1014

11-
# play audio if ladder placed
12-
execute if score $ladder_placed gm4_rol_data matches 1 run playsound minecraft:block.ladder.place ambient @a[distance=..15] ~ ~ ~
15+
# successful place
16+
execute if score $ladder_placed gm4_rol_data matches 1 run function gm4_rope_ladders:mechanics/ladder_placement/successful_place

gm4_rope_ladders/data/gm4_rope_ladders/function/mechanics/ladder_placement/place_ladder.mcfunction

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
# places a ladder when the scan finds a valid location
2-
# @s = player that interacts with a "right click detection" villager while holding ladder
2+
# @s = interacted rcd
33
# at location of valid spot for ladder placement
4-
# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column/found
4+
# run from function: gm4_rope_ladders:mechanics/ladder_placement/scan_column
55

66
# set scorebaord
77
scoreboard players set $ladder_placed gm4_rol_data 1
88

9-
# remove 1 ladder from players hand
10-
execute if entity @s[gamemode=!creative] run item modify entity @s weapon.mainhand gm4_rope_ladders:minus_one
11-
12-
# grant advancement
13-
advancement grant @s only gm4:rope_ladders
14-
159
# break block
1610
execute unless block ~ ~ ~ #gm4:water run setblock ~ ~ ~ air destroy
1711
execute if block ~ ~ ~ #gm4:water run setblock ~ ~ ~ water destroy

0 commit comments

Comments
 (0)