这是为服务器 legitimoose.com 使用的库。许多功能在其他地方可能无法正常工作(尤其是运动相关的功能)!
这个库主要是为我自己使用而设计的,但如果有人想在自己的项目中使用它,它也是可用的 :)
这个库旨在尽可能易于使用。它侧重于我经常使用的功能,例如射线检测和运动操控。请注意,易用性和通用性是以优化为代价的——其中许多部分(特别是射线检测功能)可以通过专用函数更高效地完成。
功能
add_motion
将实体的运动设置为其当前运动加上输入向量。接受相对坐标(适用于传送命令的任何内容都适用此方法)作为“vector”。示例:
function serious_lib:motion/add_motion {"vector":"^ ^ ^1"}
这会在执行该命令的实体面向的方向上增加其运动的值 1。
set_motion
将实体的运动设置为输入向量,而不保留当前的运动。除此之外,工作方式与 add_motion 相同。
relative_tp 和 relative_tp_data
这两个功能都会从起始位置 (start_pos) 到结束位置 (end_pos) 传送玩家,同时保持它们相对于每个点的位置。relative_tp 将两个字段都作为宏来处理(并且意义不大),但 relative_tp_data 通过数据存储来获取它们,从而允许动态的起点和终点。
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
这将使所有在 10 格范围内的实体传送,使得执行该命令的实体位于坐标 0, 0, 0,而其他实体则保持它们与该实体的相对位置。
raycasts
这些设计优先考虑易用性而非优化,因此可能会非常低效。它们的工作原理是在碰撞时召唤带有特定标签的区域效果云:“entity”表示实体碰撞,“block”表示方块碰撞,以及在任何情况下都存在的“end”标签,用于标记射线检测结束的位置(即使没有命中任何东西)。
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
这将从执行该命令的实体的眼睛处投射一条 50 格的射线,对第一个碰撞到的实体造成伤害,并在与方块碰撞时生成爆炸粒子。
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.
评论 0
登录后参与评分
还没有评论,来抢沙发吧