-
Notifications
You must be signed in to change notification settings - Fork 0
Easing
Available since version 2.0
The movement easing API is used to slowly interpolate any entity between positions and rotations. This can be useful when for example making dynamic animations that are determined by environmental factors of your minecraft world.
To apply an animation you can run the commands below and start the animation immediately. Do note however that there will be scoreboard overflows for very big values. Anything within 3000 should work normally. If you need higher values, consider splitting the animation into different sections and using the callback to call them sequentially
data merge storage theblackswitch:easing {<args>}
function #theblackswitch:<version>/easing/init- duration: The time it takes to complete the whole animation in ticks
- x: The relative distance in blocks to move in X during the length of the animation
- y: The relative distance in blocks to move in Y during the length of the animation
- z: The relative distance in blocks to move in Z during the length of the animation
- yaw: The relative angle in degrees to rotate yaw during the length of the animation
- pitch: The relative angle in degrees to rotate pitch during the length of the animation
- ease: The easing function to use, we currently have: linear|ease_in|ease_out|ease_in_out
- callback: (Optional) A command to run once the animation is finished
Warning
The arguments will be cleared from the storage by the next tick!
This function should run as the target entity you want to animate
Caution
To stop an animation immediately, you can run:
function #theblackswitch:<version>/easing/stopRun this function as the target entity
This door uses block displays and shulkers
open.mcfunction (runs as the door controller entity)
# Create all arguments for the easing animation
data merge storage theblackswitch:easing {duration:40,x:0,y:0,z:0,yaw:0,pitch:0,ease:"ease_in_out"}
# Get the rotation and size of the door to determine the animation direction
execute if predicate example:facing/north store result storage theblackswitch:easing z double 1 run data get entity @s data.door_size 1.05
execute if predicate example:facing/east store result storage theblackswitch:easing x double -1 run data get entity @s data.door_size 1.05
execute if predicate example:facing/south store result storage theblackswitch:easing z double -1 run data get entity @s data.door_size 1.05
execute if predicate example:facing/west store result storage theblackswitch:easing x double 1 run data get entity @s data.door_size 1.05
# Apply the animation to all entities that are part of this door
execute as @e[tag=example.sliding_door,predicate=example:is_correct_door] run function #theblackswitch:v2.0/easing/initcutscene/frame_0.mcfunction
data merge storage theblackswitch:easing {duration:40,x:0,y:4,z:0,yaw:0,pitch:-45,ease:"ease_in_out",callback:"function example:cutscene/frame_1"}
function #theblackswitch:V2.0/easing/initcutscene/frame_1.mcfunction
data merge storage theblackswitch:easing {duration:80,x:3,y:0,z:3,yaw:90,pitch:0,ease:"ease_in",callback:"function example:cutscene/frame_2"}
function #theblackswitch:V2.0/easing/initcutscene/frame_2.mcfunction
data merge storage theblackswitch:easing {duration:40,x:-3,y:0,z:3,yaw:90,pitch:0,ease:"linear",callback:"function example:cutscene/frame_3"}
function #theblackswitch:V2.0/easing/initcutscene/frame_2.mcfunction
data merge storage theblackswitch:easing {duration:80,x:-3,y:0,z:-3,yaw:90,pitch:0,ease:"ease_out",callback:"say cutscene finished!"}
function #theblackswitch:V2.0/easing/initPS: I have no idea how this animation looks btw :P
This feature needs to be enabled using:
function #theblackswitch:v2.0/easing/enable