minerace/data/emk/functions/kart/update.mcfunction

87 lines
8.7 KiB
Mcfunction

scoreboard players operation #tmp emk-id = @s emk-id
execute as @e if score @s emk-id = #tmp emk-id run tag @s add emk-sel
execute if score @s emk-timer matches 1 run function emk:kart/box_item
execute if score @s emk-timer matches 76 run playsound minecraft:entity.experience_orb.pickup ambient @p[tag=emk-sel] ~ ~ ~ 1 .5
execute if score @s emk-timer matches 61 run playsound minecraft:entity.experience_orb.pickup ambient @p[tag=emk-sel] ~ ~ ~ 1 .529732
execute if score @s emk-timer matches 46 run playsound minecraft:entity.experience_orb.pickup ambient @p[tag=emk-sel] ~ ~ ~ 1 .561231
execute if score @s emk-timer matches 31 run playsound minecraft:entity.experience_orb.pickup ambient @p[tag=emk-sel] ~ ~ ~ 1 .594604
execute if score @s emk-timer matches 16 run playsound minecraft:entity.experience_orb.pickup ambient @p[tag=emk-sel] ~ ~ ~ 1 .629961
#1 1.122462 1.259921 1.414214 1.498307
execute if score @s emk-timer matches 1.. run scoreboard players remove @s emk-timer 1
# expensive nbt cmp:
#,nbt={RootVehicle:{Entity:{Tags:["emk-seat"]}}},distance=...5
#below should not be needed?
execute store result score #tmp emk-rot run data get entity @p[tag=emk-sel] Rotation[0] 100
scoreboard players add #tmp emk-rot 36000
scoreboard players operation #tmp emk-rot %= #360 emk-rot
scoreboard players operation #tmp emk-speed = @s emk-rot
scoreboard players operation #tmp emk-speed -= #tmp emk-rot
scoreboard players add #tmp emk-speed 36000
scoreboard players operation #tmp emk-speed %= #360 emk-rot
scoreboard players operation #tmp emk-handling = @s emk-handling
execute if score @s emk-star matches 1.. run scoreboard players add #tmp emk-handling 25
execute if score #tmp emk-speed matches ..17999 if score #tmp emk-speed > #tmp emk-handling run scoreboard players operation @s[scores={emk-stun=0}] emk-rot -= @s emk-handling
scoreboard players set #tmp emk-handling 36000
scoreboard players operation #tmp emk-handling -= @s emk-handling
execute if score @s emk-star matches 1.. run scoreboard players remove #tmp emk-handling 25
execute if score #tmp emk-speed matches 18000.. if score #tmp emk-speed < #tmp emk-handling run scoreboard players operation @s[scores={emk-stun=0}] emk-rot += @s emk-handling
execute store result entity @s Rotation[0] float 0.01 run scoreboard players get @s emk-rot
# change this line somehow? ^ see below, but also if move changes rotation
execute unless score #tmp emk-speed < #tmp emk-handling unless score #tmp emk-speed > @s emk-handling store result entity @s Rotation[0] float 0.01 run scoreboard players get #tmp emk-rot
scoreboard players operation #tmp emk-maxspeed = @s emk-offroad
execute unless block ~.5 ~-0.001 ~.5 #emk:offroad unless block ~-.5 ~-0.001 ~.5 #emk:offroad unless block ~.5 ~-0.001 ~-.5 #emk:offroad unless block ~-.5 ~-0.001 ~-.5 #emk:offroad run scoreboard players operation #tmp emk-maxspeed = @s emk-maxspeed
execute if score @s emk-star matches 1.. run scoreboard players add #tmp emk-maxspeed 250
execute if block ~.5 ~-0.001 ~.5 #emk:transparent if block ~-.5 ~-0.001 ~.5 #emk:transparent if block ~.5 ~-0.001 ~-.5 #emk:transparent if block ~-.5 ~-0.001 ~-.5 #emk:transparent run scoreboard players set #tmp emk-maxspeed 0
execute if score #tmp emk-maxspeed = @s emk-offroad run scoreboard players remove @s emk-speed 60
execute if entity @p[tag=emk-sel,nbt={SelectedItemSlot:0}] if score @s emk-speed < #tmp emk-maxspeed run scoreboard players operation @s[scores={emk-stun=0}] emk-speed += @s emk-accel
execute if score #tmp emk-maxspeed matches 1.. if entity @p[tag=emk-sel,nbt={SelectedItemSlot:1}] run scoreboard players operation @s emk-speed -= @s emk-brakes
scoreboard players set @s[scores={emk-speed=..0}] emk-speed 0
scoreboard players operation @s emk-distance += @s emk-speed
#hacky:
scoreboard players add @s[scores={emk-itemboost=1..},tag=emk-onground] emk-distance 80
#execute if score @s emk-distance matches 1000.. at @s run function emk:kart/move
function emk:kart/checks
#execute positioned ^ ^ ^.1 run function emk:kart/move
execute if score @s emk-distance matches 1000.. positioned ^ ^ ^.1 run function emk:kart/move
execute store result entity @s Rotation[0] float 0.01 run scoreboard players get @s emk-rot
scoreboard players remove @s[scores={emk-speed=0..}] emk-speed 10
scoreboard players set @s[scores={emk-speed=..0}] emk-speed 0
scoreboard players operation @s[tag=!emk-onground] emk-ymov -= @s emk-weight
scoreboard players operation @s emk-distancey += @s emk-ymov
scoreboard players remove @s[scores={emk-stun=1..}] emk-stun 1
scoreboard players remove @s[scores={emk-star=1..}] emk-star 1
scoreboard players remove @s[scores={emk-itemboost=1..}] emk-itemboost 1
#move up if using: scoreboard players add @s[scores={emk-itemboost=1..},tag=emk-onground] emk-speed 40
execute if score @s emk-distancey matches 1000.. at @s run function emk:kart/moveyu
execute if score @s emk-distancey matches ..-1000 at @s run function emk:kart/moveyd
execute unless score @s emk-stun matches 1.. if entity @p[tag=emk-sel,scores={emk-use=1..}] run function emk:kart/use_item
execute if score @s emk-item matches 1.. run replaceitem entity @p[tag=emk-sel] weapon.offhand minecraft:splash_potion{CustomPotionColor:16777215,display:{Name:'""'}}
execute if score @s emk-item matches -1 run replaceitem entity @p[tag=emk-sel] weapon.offhand minecraft:air
execute if score @s emk-item matches -1 run replaceitem entity @p[tag=emk-sel] container.2 minecraft:air
execute if score @s emk-item matches -1 run playsound minecraft:entity.item.break ambient @p[tag=emk-sel]
scoreboard players set @s[scores={emk-item=-1}] emk-item 0
execute if score @s emk-star matches 1.. run playsound minecraft:entity.experience_orb.pickup ambient @a ~ ~.4 ~ .8 1.1
#tellraw @p[tag=emk-sel,tag=!emk-help-drive] [{"text":"<Minerace Help>","color":"#ffcc66"},{"text":" Welcome to your first race in Minerace! Sit in the kart and press ","color":"white","extra":[{"keybind":"key.hotbar.1"},{"text":" or select slot 1 to accelerate. Use "},{"keybind":"key.hotbar.2"},{"text":" or select slot 2 to brake."}]}]
#tag @p[tag=emk-sel] add emk-help-drive
# execute if score @s emk-item matches 1.. run tellraw @p[tag=emk-sel,tag=!emk-help-item] [{"text":"<Minerace Help>","color":"#ffcc66"},{"text":" You have an item! Use ","color":"white","extra":[{"keybind":"key.use"},{"text":" to activate the item."}]}]
# execute if score @s emk-item matches 1.. run tag @p[tag=emk-sel] add emk-help-item
# execute if score @s emk-item matches 1..3 run tellraw @p[tag=emk-sel,tag=!emk-help-gold] [{"text":"<Minerace Help>","color":"#ffcc66"},{"text":" You have gold! When activated, you will drive a little faster.","color":"white"}]
# execute if score @s emk-item matches 1..3 run tag @p[tag=emk-sel] add emk-help-gold
# execute if score @s emk-item matches 4..6 run tellraw @p[tag=emk-sel,tag=!emk-help-slime] [{"text":"<Minerace Help>","color":"#ffcc66"},{"text":" You have a slime! When activated, a slime will be placed behind your kart. When a kart hits the slime, it will stop for a while, so avoid driving into them.","color":"white"}]
# execute if score @s emk-item matches 4..6 run tag @p[tag=emk-sel] add emk-help-slime
# execute if score @s emk-item matches 7 run tellraw @p[tag=emk-sel,tag=!emk-help-turtle] [{"text":"<Minerace Help>","color":"#ffcc66"},{"text":" You have a turtle! When activated, a turtle will be thrown in front of you. When a kart hits the turtle, the kart will stop for a while, so avoid driving into them. Turtles can kill slimes.","color":"white"}]
# execute if score @s emk-item matches 7 run tag @p[tag=emk-sel] add emk-help-turtle
# execute if score @s emk-stun matches 9 run tellraw @p[tag=emk-sel,tag=!emk-help-stun] [{"text":"<Minerace Help>","color":"#ffcc66"},{"text":" Oops! You got stunned! Try to avoid slimes and turtles.","color":"white"}]
# execute if score @s emk-stun matches 9 run tag @p[tag=emk-sel] add emk-help-stun
scoreboard players operation @p[tag=emk-sel] emk-place = @s emk-place
tp @a[tag=emk-sel,distance=5..,gamemode=adventure] ~ ~ ~
execute as @e[tag=emk-seat,tag=emk-sel] run function emk:seat/update
#Perfect place to update other entities of the kart like missiles, foxes etc due to having all entities with the same emk-id selected 5613054
#execute as @e[tag=emk-missile] if score @s emk-id = #tmp emk-id at @s run function emk:missile/update
execute as @e[tag=emk-missile,tag=emk-sel] at @s run function emk:missile/update
execute if score @s emk-star matches 1.. run particle minecraft:end_rod ~ ~.4 ~ 0 0 0 .005 4
#execute if score @s emk-itemboost matches 1.. run particle minecraft:flame ~ ~.4 ~ 0 0 0 .005 1
execute if score @s emk-itemboost matches 1.. run particle minecraft:flame ^.45 ^.05 ^-.45 0 0 0 .005 1
execute if score @s emk-itemboost matches 1.. run particle minecraft:flame ^-.45 ^.05 ^-.45 0 0 0 .005 1
#kill @s[y=-10,dy=10]
tag @e remove emk-sel