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

New mountaineering module #789

Merged
merged 94 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
f19bf28
Added skis and some test functionality
AdequateUsername Aug 8, 2022
421078a
Fixed a typo in _pack.mcmeta
AdequateUsername Aug 8, 2022
48bd046
Fixed a few typos and renamed _pack.mcmeta
AdequateUsername Aug 9, 2022
764abea
Crafting now works
AdequateUsername Aug 9, 2022
ae8e893
Speed boost now (blindly) applied
AdequateUsername Aug 9, 2022
c107fcf
Added (possibly) functionality to give speed
AdequateUsername Aug 9, 2022
4933a31
Gives speed when wearing skis and on snowy block,
AdequateUsername Aug 9, 2022
7062170
Added poles
AdequateUsername Sep 2, 2022
3e45f75
Renamed "Item" (to store NBT) to ski_item and
AdequateUsername Sep 2, 2022
e9a81f1
Added jump boost effects for poles, and removed
AdequateUsername Sep 2, 2022
0e04ff8
Added crampons
AdequateUsername Sep 2, 2022
73c30b1
Given jump boost functionality to crampons
AdequateUsername Sep 2, 2022
b584f79
Response to initial feedback
AdequateUsername Sep 3, 2022
542e7ca
Fixed formatting, attempted adding 'snow detection
AdequateUsername Sep 21, 2022
380a2ef
Working snow detection system (now includes
AdequateUsername Sep 21, 2022
e8ce191
Smarter fall detection system implemented
AdequateUsername Sep 25, 2022
6c6907b
Speed boost applied for travelling downhill using
AdequateUsername Oct 1, 2022
53ffbda
Further speed added for faster descent
AdequateUsername Oct 4, 2022
40b870c
Adjusted recipes and changed poles to be a stick
AdequateUsername Oct 4, 2022
6ef71df
When holding poles, a lower v_y is needed to
AdequateUsername Oct 7, 2022
b40a750
Crampons add slowness, and give a tag when facing
AdequateUsername Oct 23, 2022
00ebfae
Crampons now allow for vertical scaling of walls
AdequateUsername Oct 30, 2022
b611bb5
Shulkers now killed without particles
AdequateUsername Nov 1, 2022
36563a3
General clean-up, and need empty hands to climb
AdequateUsername Nov 1, 2022
002b5b9
Changed advancement name to 'craft skis'
AdequateUsername Nov 5, 2022
309f1bb
Particles added when skiing
AdequateUsername Nov 12, 2022
1be1e09
Player can now look around when climbing, and
AdequateUsername Nov 12, 2022
03a5800
Using poles reduces fall damage
AdequateUsername Nov 12, 2022
f04f70e
Added advancement for reaching maximum speed boost
AdequateUsername Nov 12, 2022
8507683
Some recipe tweaks (but I don't think this is
AdequateUsername Nov 12, 2022
49e2e1b
Shulkers now summoned in a more precise way
AdequateUsername Nov 12, 2022
2019c4a
Simplified shulker killing mechanism
AdequateUsername Nov 12, 2022
50a5699
Changed context for kill_shulkers
AdequateUsername Nov 12, 2022
a7b015a
Removed all "execute run" before function calls
AdequateUsername Nov 12, 2022
59d7497
Crampon removal commands only called once when
AdequateUsername Nov 12, 2022
595d47b
New function to initiate crampon effects
AdequateUsername Nov 12, 2022
e3ef0c4
Check for whether a player stands in front of a
AdequateUsername Nov 12, 2022
15e322d
Further implementation of block tag for check of
AdequateUsername Nov 12, 2022
6a4193b
Moved function calls in main to a new player_main
AdequateUsername Nov 12, 2022
2b42c54
Removed some unnecessary predicate calls
AdequateUsername Nov 12, 2022
e8cdd88
General cleanup
AdequateUsername Nov 12, 2022
1c8a009
Fixed some incorrect headers
AdequateUsername Nov 12, 2022
1c7bd36
Should now use latest custom crafting system
AdequateUsername Nov 19, 2022
a1f8389
Changed poles recipe and advancement names
AdequateUsername Nov 27, 2022
0be60f4
Simplified climbing mechanism
AdequateUsername Nov 27, 2022
0f4bffc
Simplified poles system
AdequateUsername Nov 27, 2022
f820af1
Moved poles to fast_main (renamed from
AdequateUsername Nov 27, 2022
f494fd6
Climbing shulker damage system moved to slow clock
AdequateUsername Nov 27, 2022
c65dbbe
Slowness is now an attribute of crampons
AdequateUsername Nov 27, 2022
5c07787
Changed jump boost conditions with poles:
AdequateUsername Nov 27, 2022
494fd44
Slowness effects called directly from
AdequateUsername Nov 27, 2022
4b64ffb
Expanded range of climbable blocks, and general
AdequateUsername Nov 27, 2022
bf16f80
Ordered climbable_blocks and removed settings.json
AdequateUsername Nov 28, 2022
8851947
Simplified player_main, updated custom crafting loading to
AdequateUsername Nov 28, 2022
931bb34
Moved crampon tag-adding and -removing to main
AdequateUsername Nov 28, 2022
f1379dd
Added a submain function for the fast clock
AdequateUsername Nov 28, 2022
93689db
Moved kill_shulkers into damage_shulkers
AdequateUsername Nov 28, 2022
6733105
Reduced if score subcommands in
AdequateUsername Nov 28, 2022
157a5e6
Reduced score-checking subcommands in
AdequateUsername Nov 28, 2022
fbc035f
Updated contributors.json with my own name
AdequateUsername Nov 28, 2022
7f2a3f7
Updated pack.png, removed pack.svg
AdequateUsername Nov 28, 2022
ada0eb1
Added snowy_blocks block tag and
AdequateUsername Nov 28, 2022
8a92d4c
Removed HideFlags:64 from items
AdequateUsername Nov 28, 2022
5e249de
Summon shulkers high up, then tp down to
AdequateUsername Nov 28, 2022
a68c091
Moved damage_shulkers call to main from
AdequateUsername Nov 30, 2022
53b12c5
Another attempt at teleporting shulkers down
AdequateUsername Nov 30, 2022
e1ea32f
Moved at @s to fast_main from player_fast_main
AdequateUsername Nov 30, 2022
54c1840
Added blank links field to contributors and put
AdequateUsername Nov 30, 2022
6277867
Renamed poles to ski poles
AdequateUsername Nov 30, 2022
9dfd170
Set shulker peek 1t after teleporting to avoid
AdequateUsername Nov 30, 2022
1e2d4d1
minor optimisation to reset_shulker_peek
AdequateUsername Nov 30, 2022
9dd8e59
Empty commit to run workflow
misode Jan 2, 2023
27f1731
Shulkers will no longer spawn in air, and
AdequateUsername Jan 12, 2023
c1f4af2
Merge branch 'master' of https://github.com/AdequateUsername/GM4_Data…
AdequateUsername Jan 12, 2023
aea413c
Crampons provide correct armour
AdequateUsername Jan 12, 2023
6f2b6bc
Easier to maintain speed on flat, but
AdequateUsername Jan 12, 2023
c37aa04
Downhill ski speed effects removed if the player
AdequateUsername Jan 21, 2023
572dd79
Replacing pack.mcmeta with beet.yaml
AdequateUsername May 13, 2023
37ca418
Merge branch 'Gamemode4Dev:master' into master
AdequateUsername May 13, 2023
7dfd450
Merge branch 'master' of https://github.com/Gamemode4Dev/GM4_Datapacks
AdequateUsername Aug 13, 2023
6bc48de
Updated beet.yaml to 1.4.0 standard
AdequateUsername Aug 13, 2023
c63c6d2
Revert .vscode/settings.json to how it was
AdequateUsername Aug 14, 2023
0f30b64
Update translations, remove particles
AdequateUsername Aug 14, 2023
8e99c32
A few more formatting tweaks
AdequateUsername Aug 14, 2023
454a803
Made it easier to climb walls of odd-valued height
AdequateUsername Aug 14, 2023
1ec8fc4
Stop add_climbing_effects from running twice when
AdequateUsername Aug 16, 2023
2596765
Velocity updated whenever poles or skis equipped
AdequateUsername Aug 16, 2023
c41a6f1
Add a new tag to track the shulker peek setting
AdequateUsername Aug 16, 2023
c39f915
Rename 'Ski Poles' to 'Ski Pole'. Note the item is
AdequateUsername Aug 16, 2023
11a4001
Ski pole unstackable, and a scoreboard-based way
AdequateUsername Aug 17, 2023
ecdbf1c
Can only craft one ski pole at a time
AdequateUsername Aug 17, 2023
6003eb0
Add Experimental Module Note
Bloo-dev Aug 21, 2023
32955ff
Add a README
AdequateUsername Aug 22, 2023
f7ab140
Merge branch 'Gamemode4Dev:master' into master
AdequateUsername Sep 3, 2023
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
4 changes: 4 additions & 0 deletions contributors.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"name": "Energyxxer",
"links": ["https://youtube.com/user/Energyxxer"]
},
{
"name":"foodiebonus",
"links":[]
},
{
"name": "Fyid",
"links": ["https://twitter.com/FyidRants"]
Expand Down
28 changes: 28 additions & 0 deletions gm4_mountaineering/beet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
id: gm4_mountaineering
name: Mountaineering
version: 1.0.X

data_pack:
load: .

pipeline:
- gm4.plugins.extend.module
- gm4.plugins.include.lib_custom_crafters

meta:
gm4:
versioning:
required:
- lib_custom_crafters: 3.0.0
schedule_loops:
- main
- fast_main
website:
description: A mezze of mountaineering means! Glide down slopes and scale cliffs.
recommended: []
notes: []
video: null
wiki: null
credits:
Creator:
- foodiebonus
24 changes: 24 additions & 0 deletions gm4_mountaineering/data/gm4/advancements/root.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"display": {
"icon": {
"item": "command_block",
"nbt": "{CustomModelData:3420001}"
},
"title": {
"translate": "advancement.gm4.root.title",
"fallback": "Gamemode 4"
},
"description": {
"translate": "advancement.gm4.root.description",
"fallback": "Semi-funny blurb about GM4",
"color": "gray"
},
"background": "textures/block/light_blue_concrete_powder.png",
"announce_to_chat": false
},
"criteria": {
"automatic": {
"trigger": "minecraft:tick"
}
}
}
33 changes: 33 additions & 0 deletions gm4_mountaineering/data/gm4/advancements/ski.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"display": {
"icon": {
"item": "iron_boots",
"nbt": "{CustomModelData:3420001}"
},
"title": {
"translate": "advancement.gm4.mountaineering.title",
"fallback": "Piste de Résistance"
},
"description": {
"translate": "advancement.gm4.mountaineering.description",
"fallback": "Get yourself a pair of skis",
"color": "gray"
}
},
"parent": "gm4:custom_crafters",
"criteria": {
"mountaineering": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": [
"minecraft:iron_boots"
],
"nbt": "{gm4_mountaineering:{item:\"skis\"}}"
}
]
}
}
}
}
23 changes: 23 additions & 0 deletions gm4_mountaineering/data/gm4/advancements/ski_fast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"display": {
"icon": {
"item": "diamond_boots",
"nbt": "{CustomModelData:3420001}"
},
"title": {
"translate": "advancement.gm4.mountaineering.title",
"fallback": "Ski ya Later!"
},
"description": {
"translate": "advancement.gm4.mountaineering.description",
"fallback": "Reach the highest speed boost while skiing",
"color": "gray"
}
},
"parent": "gm4:ski",
"criteria": {
"requirement": {
"trigger": "minecraft:impossible"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"gm4_mountaineering:check_recipes"
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Checks for recipes then runs the relevant function to create mountaineering gear

execute if score $crafted gm4_crafting matches 0 store success score $crafted gm4_crafting if score $slot_count gm4_crafting matches 7 if score $stack_size gm4_crafting matches ..1 if data storage gm4_custom_crafters:temp/crafter {Items:[{Slot:0b,id:"minecraft:iron_ingot"},{Slot:2b,id:"minecraft:iron_ingot"},{Slot:3b,id:"minecraft:iron_ingot"},{Slot:4b,id:"minecraft:iron_boots"},{Slot:5b,id:"minecraft:iron_ingot"},{Slot:6b,id:"minecraft:iron_ingot"},{Slot:8b,id:"minecraft:iron_ingot"}]} unless data storage gm4_custom_crafters:temp/crafter Items[3].tag.gm4_mountaineering run function gm4_mountaineering:new_skis
execute if score $crafted gm4_crafting matches 0 store success score $crafted gm4_crafting if score $slot_count gm4_crafting matches 3 if score $stack_size gm4_crafting matches ..64 if data storage gm4_custom_crafters:temp/crafter {Items:[{Slot:0b,id:"minecraft:tripwire_hook"},{Slot:3b,id:"minecraft:stick"},{Slot:6b,id:"minecraft:stick"}]} run loot replace block ~ ~ ~ container.0 loot gm4_mountaineering:crafting/poles
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved
execute if score $crafted gm4_crafting matches 0 store success score $crafted gm4_crafting if score $slot_count gm4_crafting matches 4 if score $stack_size gm4_crafting matches ..1 if data storage gm4_custom_crafters:temp/crafter {Items:[{Slot:1b,id:"minecraft:chainmail_boots"},{Slot:3b,id:"minecraft:iron_nugget"},{Slot:4b,id:"minecraft:iron_nugget"},{Slot:5b,id:"minecraft:iron_nugget"}]} unless data storage gm4_custom_crafters:temp/crafter Items[0].tag.gm4_mountaineering run function gm4_mountaineering:new_crampons
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# add the climbing tag, and spawn shulkers (which die after a brief time) to allow the player to climb a vertical wall
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved
# @s = player wearing crampons, with using_crampons tag, and facing a climbable block
# at @s
# run from player_fast_main

# provide jump boost
effect give @s jump_boost 1 1 true

# summon shulker in front and below player, but 1000 blocks up, facing towards them
execute if entity @s[y_rotation=135..-135] positioned ~ ~-1.5 ~-1 align xyz unless entity @e[type=shulker, tag=gm4_mountaineering_climb_assist, dx=0.5, dz=0.5, dy=1] unless block ~0.5 ~1 ~0.5 minecraft:air run summon minecraft:shulker ~0.5 ~1000 ~0.5 {Color:7,AttachFace:2,Invulnerable:1b,NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Tags:[gm4_mountaineering_climb_assist, gm4_mountaineering_new_shulker, gm4_mountaineering_peek_unset],DeathLootTable:"minecraft:empty",ActiveEffects:[{Id:14,Duration:100000,ShowParticles:0b}]}
execute if entity @s[y_rotation=-135..-45] positioned ~1 ~-1.5 ~ align xyz unless entity @e[type=shulker, tag=gm4_mountaineering_climb_assist, dx=0.5, dz=0.5, dy=1] unless block ~0.5 ~1 ~0.5 minecraft:air run summon minecraft:shulker ~0.5 ~1000 ~0.5 {Color:7,AttachFace:5,Invulnerable:1b,NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Tags:[gm4_mountaineering_climb_assist, gm4_mountaineering_new_shulker, gm4_mountaineering_peek_unset],DeathLootTable:"minecraft:empty",ActiveEffects:[{Id:14,Duration:100000,ShowParticles:0b}]}
execute if entity @s[y_rotation=-45..45] positioned ~ ~-1.5 ~1 align xyz unless entity @e[type=shulker, tag=gm4_mountaineering_climb_assist, dx=0.5, dz=0.5, dy=1] unless block ~0.5 ~1 ~0.5 minecraft:air run summon minecraft:shulker ~0.5 ~1000 ~0.5 {Color:7,AttachFace:3,Invulnerable:1b,NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Tags:[gm4_mountaineering_climb_assist, gm4_mountaineering_new_shulker, gm4_mountaineering_peek_unset],DeathLootTable:"minecraft:empty",ActiveEffects:[{Id:14,Duration:100000,ShowParticles:0b}]}
execute if entity @s[y_rotation=45..135] positioned ~-1 ~-1.5 ~ align xyz unless entity @e[type=shulker, tag=gm4_mountaineering_climb_assist, dx=0.5, dz=0.5, dy=1] unless block ~0.5 ~1 ~0.5 minecraft:air run summon minecraft:shulker ~0.5 ~1000 ~0.5 {Color:7,AttachFace:4,Invulnerable:1b,NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Tags:[gm4_mountaineering_climb_assist, gm4_mountaineering_new_shulker, gm4_mountaineering_peek_unset],DeathLootTable:"minecraft:empty",ActiveEffects:[{Id:14,Duration:100000,ShowParticles:0b}]}

# teleport shulker down 999 blocks to bring them into position (999 to put the shulker one block below feet)
execute positioned ~ ~1000 ~ as @e[type=shulker, tag=gm4_mountaineering_climb_assist, tag=gm4_mountaineering_new_shulker] at @s run teleport @s ~ ~-999 ~
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved
tag @e[type=shulker] remove gm4_mountaineering_new_shulker

# schedule a function to set the peek of the shulker (can't do it in the same tick as teleporting)
schedule function gm4_mountaineering:climbing_effects/reset_shulker_peek 1t
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# increase the score of each climbing shulker, and kill after reaching 6
# @s = shulker with tag gm4_mountaineering_climb_assist
# at @s
# run from main

scoreboard players add @s gm4_mountaineering_climbing_shulker_countdown 1
teleport @s[scores={gm4_mountaineering_climbing_shulker_countdown=6..}] ~ -10000 ~
kill @s[scores={gm4_mountaineering_climbing_shulker_countdown=6..}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# reset the peek values of new shulkers and remove the relevant tag
# @s = player wearing crampons, with using_crampons tag, and facing a climbable block
# at @s
# run from add_climb_effects

execute as @e[type=shulker, tag=gm4_mountaineering_climb_assist, tag=gm4_mountaineering_peek_unset] run data merge entity @s {Peek:10}
tag @e[type=shulker] remove gm4_mountaineering_peek_unset
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Running on a faster clock to enable smoother climbing and for poles fall damage reduction to work

execute as @a[gamemode=!spectator] at @s run function gm4_mountaineering:player_fast_main

schedule function gm4_mountaineering:fast_main 4t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Update the player's velocity scores
# @s = player wearing skis
# at @s
# run from ski_effects/skis_equipped and pole_effects/poles_equipped

# Get current y-position, store as y1
execute store result score @s gm4_mountaineering_y1 run data get entity @s Pos[1]

# Velocity is current position y1 minus previous position y2
scoreboard players operation @s gm4_mountaineering_vy = @s gm4_mountaineering_y1
scoreboard players operation @s gm4_mountaineering_vy -= @s gm4_mountaineering_y2

# Update y2 for use on next run of this function
scoreboard players operation @s gm4_mountaineering_y2 = @s gm4_mountaineering_y1

# Use the same method to get x velocity
execute store result score @s gm4_mountaineering_x1 run data get entity @s Pos[0]
scoreboard players operation @s gm4_mountaineering_vx = @s gm4_mountaineering_x1
scoreboard players operation @s gm4_mountaineering_vx -= @s gm4_mountaineering_x2
scoreboard players operation @s gm4_mountaineering_x2 = @s gm4_mountaineering_x1

# Use the same method to get z velocity
execute store result score @s gm4_mountaineering_z1 run data get entity @s Pos[2]
scoreboard players operation @s gm4_mountaineering_vz = @s gm4_mountaineering_z1
scoreboard players operation @s gm4_mountaineering_vz -= @s gm4_mountaineering_z2
scoreboard players operation @s gm4_mountaineering_z2 = @s gm4_mountaineering_z1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
execute unless score mountaineering gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Mountaineering"}
scoreboard players set mountaineering gm4_modules 1

scoreboard objectives add gm4_mountaineering_y1 dummy
scoreboard objectives add gm4_mountaineering_y2 dummy
scoreboard objectives add gm4_mountaineering_vy dummy
scoreboard objectives add gm4_mountaineering_x1 dummy
scoreboard objectives add gm4_mountaineering_x2 dummy
scoreboard objectives add gm4_mountaineering_vx dummy
scoreboard objectives add gm4_mountaineering_z1 dummy
scoreboard objectives add gm4_mountaineering_z2 dummy
scoreboard objectives add gm4_mountaineering_vz dummy
scoreboard objectives add gm4_mountaineering_ski_downhill dummy
scoreboard objectives add gm4_mountaineering_ski_steep_downhill dummy
scoreboard objectives add gm4_mountaineering_poles_jump_boost dummy
scoreboard objectives add gm4_mountaineering_jump_counter minecraft.custom:minecraft.jump
scoreboard objectives add gm4_mountaineering_climbing_shulker_countdown dummy
scoreboard objectives add gm4_mountaineering_init_climbing_effects dummy

AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved
schedule function gm4_mountaineering:main 1t
schedule function gm4_mountaineering:fast_main 1t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
execute as @a[gamemode=!spectator] at @s run function gm4_mountaineering:player_main
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved

# Initiate crampons when they are first equipped with a tag
tag @a[tag=!gm4_mountaineering_using_crampons,predicate=gm4_mountaineering:wearing_crampons] add gm4_mountaineering_using_crampons

# Clear crampon tag when crampons are removed
tag @a[predicate=!gm4_mountaineering:wearing_crampons,tag=gm4_mountaineering_using_crampons] remove gm4_mountaineering_using_crampons

# Reset the jump counter for use in the poles jump boost cooldown
scoreboard players reset @a gm4_mountaineering_jump_counter

# Apply damage to any climbing shulkers
execute as @e[type=minecraft:shulker,tag=gm4_mountaineering_climb_assist] at @s run function gm4_mountaineering:climbing_effects/damage_shulkers
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved

schedule function gm4_mountaineering:main 16t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Creates new crampons upon correct recipe detection
# @s = custom crafter with correct recipe
# run from check_recipes

# Preserve existing item data for provided chainmail boots
data modify storage gm4_mountaineering:temp crampons_item set from storage gm4_custom_crafters:temp/crafter Items[0]

# Create crampons in custom crafter
loot replace block ~ ~ ~ container.0 loot gm4_mountaineering:crafting/crampons

# Remove temp-stored chainmail boots from stored data
data remove storage gm4_mountaineering:temp crampons_item
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Creates new skis upon correct recipe detection
# @s = custom crafter with correct recipe
# run from check_recipes

# Preserve existing item data for provided iron boots
data modify storage gm4_mountaineering:temp ski_item set from storage gm4_custom_crafters:temp/crafter Items[0]

# Create skis in custom crafter
loot replace block ~ ~ ~ container.0 loot gm4_mountaineering:crafting/skis

# Remove temp-stored iron boots from stored data
data remove storage gm4_mountaineering:temp ski_item
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Submain function to limit `as @a` calls in fast_main
# @s = player not in spectator
# at @s
# run from fast_main

# Adds vertical climbing abilities when wearing crampons and not holding anything
scoreboard players set @s gm4_mountaineering_init_climbing_effects 0
execute if entity @s[gamemode=!spectator,tag=gm4_mountaineering_using_crampons,predicate=gm4_mountaineering:hands_empty] anchored eyes if block ^ ^ ^1 #gm4_mountaineering:climbable_blocks run scoreboard players set @s gm4_mountaineering_init_climbing_effects 1
execute if entity @s[gamemode=!spectator,tag=gm4_mountaineering_using_crampons,predicate=gm4_mountaineering:hands_empty,scores={gm4_mountaineering_init_climbing_effects=0}] anchored eyes if block ^ ^-1 ^1 #gm4_mountaineering:climbable_blocks run scoreboard players set @s gm4_mountaineering_init_climbing_effects 1
execute if entity @s[scores={gm4_mountaineering_init_climbing_effects=1}] run function gm4_mountaineering:climbing_effects/add_climb_effects

# Give resistance before landing to reduce fall damage when holding poles in both hands
execute if entity @s[gamemode=!spectator,predicate=gm4_mountaineering:holding_poles] if block ~ ~-2 ~ minecraft:air run effect give @s resistance 1 1 true
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Submain function to limit `as @a` calls in main
# @s = player not in spectator
# at @s
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved
# run from main

# Run ski-related functions
execute if entity @s[predicate=gm4_mountaineering:wearing_skis] run function gm4_mountaineering:ski_effects/skis_equipped

# Clear ski-related functions when skis are removed
execute if entity @s[predicate=!gm4_mountaineering:wearing_skis,tag=gm4_mountaineering_using_skis] run function gm4_mountaineering:ski_effects/skis_removed

# Adds jump boost effects when holding poles
execute if entity @s[predicate=gm4_mountaineering:holding_poles] run function gm4_mountaineering:pole_effects/poles_equipped
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Give pole-related effects - jump boost on a cooldown and reduced fall damage
# @s = player holding poles
# at @s
# run from player_main

# Records the player's velocities in scoreboards if it wasn't already done (as would be the case if wearing skis)
execute unless entity @s[predicate=gm4_mountaineering:wearing_skis] run function gm4_mountaineering:get_velocity

# Add jump boost effect (1 with skis, 2 without skis, 3 if having an upwards velocity)
effect give @s[scores={gm4_mountaineering_poles_jump_boost=..0,gm4_mountaineering_vy=2..}] jump_boost 1 2 true
AdequateUsername marked this conversation as resolved.
Show resolved Hide resolved
effect give @s[predicate=!gm4_mountaineering:wearing_skis,scores={gm4_mountaineering_poles_jump_boost=..0,gm4_mountaineering_vy=..0}] jump_boost 1 1 true
effect give @s[predicate=gm4_mountaineering:wearing_skis,scores={gm4_mountaineering_poles_jump_boost=..0,gm4_mountaineering_vy=..0}] jump_boost 1 0 true

# Reduce jump cooldown
scoreboard players remove @s[scores={gm4_mountaineering_poles_jump_boost=1..}] gm4_mountaineering_poles_jump_boost 1

# If jump, reset cooldown and jump counter
scoreboard players set @s[scores={gm4_mountaineering_jump_counter=1..}] gm4_mountaineering_poles_jump_boost 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# clear existing tags, check if the player is on a snowy block and wearing skis, add the skiing tag back if yes, and add ski_off_snow tag if not on snowy block
# @s = player wearing skis
# at @s
# run from skis_equipped

# Remove skiing tags and slowness effects unless the player is in the air
execute if entity @s[tag=gm4_mountaineering_ski_slowness] unless block ~ ~-0.1 ~ minecraft:air run function gm4_mountaineering:ski_effects/ski_off_snow_slowness/remove_off_snow_slowness
execute unless block ~ ~-0.1 ~ minecraft:air run tag @s remove gm4_mountaineering_skiing

# Add skiing tag if on snow layer or any other snowy block (contained within the predicate) with skis
execute if block ~ ~ ~ minecraft:snow run tag @s add gm4_mountaineering_skiing
tag @s[predicate=gm4_mountaineering:on_snowy_block] add gm4_mountaineering_skiing

# Add slowness if wearing skis on a non-snowy block
execute if entity @s[tag=!gm4_mountaineering_ski_slowness] unless block ~ ~ ~ minecraft:snow unless predicate gm4_mountaineering:on_snowy_block_or_air run function gm4_mountaineering:ski_effects/ski_off_snow_slowness/add_off_snow_slowness

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Add increased speed when player is on snowy block, wearing skis, and travelling downhill (>=2 blocks descended)
# @s = player without skiing tag and having fallen >=2 blocks
# at @s
# run from skis_equipped

tag @s add gm4_mountaineering_skiing_downhill
scoreboard players set @s gm4_mountaineering_ski_downhill 10
attribute @s minecraft:generic.movement_speed modifier add 42a046eb-1425-4efe-831b-f891d8ede18f "gm4_mountaineering_downhill_speed_boost" 0.175 multiply_base
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Checks that the player still travels downhill (>=1 blocks)
# @s = player with skiing tag and having initially fallen >=2 blocks
# at @s
# run from skis_equipped

# remove a second of speed if the player has not fallen >=1 block, and an additional second if travelling uphill
scoreboard players remove @s[scores={gm4_mountaineering_ski_downhill=1..,gm4_mountaineering_vy=0..}] gm4_mountaineering_ski_downhill 1
scoreboard players remove @s[scores={gm4_mountaineering_ski_downhill=1..,gm4_mountaineering_vy=1..}] gm4_mountaineering_ski_downhill 1
scoreboard players set @s[tag=gm4_mountaineering_skiing,scores={gm4_mountaineering_vy=..-1}] gm4_mountaineering_ski_downhill 10

# set scoreboard to 0 if player is not moving
scoreboard players set @s[scores={gm4_mountaineering_vx=0,gm4_mountaineering_vy=0,gm4_mountaineering_vz=0}] gm4_mountaineering_ski_downhill 0

# Remove speed if no longer travelling downhill or removed skis
execute if entity @s[scores={gm4_mountaineering_ski_downhill=..0}] run function gm4_mountaineering:ski_effects/downhill_ski_speed/remove_downhill_ski_speed
execute if entity @s[tag=!gm4_mountaineering_skiing] run function gm4_mountaineering:ski_effects/downhill_ski_speed/remove_downhill_ski_speed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Remove increased speed when player is no longer on snowy block, wearing skis, and travelling downhill (>=2 blocks descended)
# @s = player with skiing tag and downhill skiing tag but not having recently fallen >= 2 blocks
# at @s
# run from check_downhill_ski_speed

scoreboard players set @s gm4_mountaineering_ski_downhill 0
attribute @s minecraft:generic.movement_speed modifier remove 42a046eb-1425-4efe-831b-f891d8ede18f
tag @s remove gm4_mountaineering_skiing_downhill
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Add some speed when player is on snowy block and wearing skis
# @s = player with skiing tag, without speed skiing tag
# at @s
# run from skis_equipped

attribute @s minecraft:generic.movement_speed modifier add f2781530-676b-401d-b2e3-12de37f9b82a "gm4_mountaineering_flat_speed" 0.3 multiply_base
tag @s add gm4_mountaineering_ski_speed
Loading