Compatibility
Minecraft: Java Edition
Platforms
Creators
Details
This is a library for use on the server legitimoose.com. Many functions won't work properly anywhere else (specifically the motion ones)! This is a library designed mostly for my own use, but it's available in case anyone wants to use it for their own project :)
This library was designed to be as easy to use as possible. It focuses on functions I use often, such as raycasts and motion manipulation. Please note however that the ease of use and general applicability comes at the cost of optimisation - much of this (especially the raycast functions) could be done much more efficiently by a dedicated function.
The Functions
add_motion
Sets the motion of the entity to their current motion plus the input vector. Takes a relative coordinate (anything that works for a teleport command works here) as "vector". Example:
function serious_lib:motion/add_motion {"vector":"^ ^ ^1"}
This would add 1 to the motion of the executing entity in the direction faced.
set_motion
Sets the motion of the entity to the input vector, without maintaining current motion. Other than that works the same as add_motion.
relative_tp and relative_tp_data
Both teleport the player from a starting position (start_pos) to a finishing position (end_pos), maintaining their relative position to each point. relative_tp takes both fields as macros (and is fairly pointless) but relative_tp_data takes them through data storage, allowing for dynamic start and end points.
data modify serious_lib:motion start_pos set from entity @s Pos
data modify serious_lib:motion end_pos set value [0,0,0]
execute as @e[distance=..10] at @s run function serious_lib:motion/relative_tp_data
This would teleport all entities within 10 blocks so that the executing entity is positioned at 0, 0, 0, and all other entities retain their relative position to them.
raycasts
These are designed for ease of use over optimisation, and are likely horribly inefficient. They work by summoning area effect clouds with specific tags when hitting things: "entity" for an entity collision, "block" for a block collision, and "end" in addition to any other tags for wherever the raycast ends (even if it didn't hit anything.
scoreboard players set @s ray_length 100
execute anchored eyes positioned ^ ^ ^ run function serious_lib:raycast/particle/basic {"particle":"end_rod"}
execute at @n[type=area_effect_cloud,tag=entity] run damage @n[tag=!end]
execute at @n[type=area_effect_cloud,tag=block] run particle explosion
This would cast a 50 block ray from the executing entity's eyes, damaging the first entity it collided with, and creating explosion particles if it collides with a block.



