xokz 的粒子效果
此数据包纯粹是一个库,不包含任何具有 ticking(持续运行)功能的逻辑。它仅供其他数据包调用和/或修改使用。
它为数据包制作者和地图制作者提供了多种实用的效果。
运行 /function xze:demo/laser 或 /function xze:demo/ball 查看演示!
效果目录
闪电
函数:
xze:fx/lightning/spawn_with {...} | 生成一道闪电形状的粒子束
particle: String | 用于绘制闪电的粒子类型
- 必须在起始点执行,并作为移动目标实体执行
- 若要定位到特定位置,请在该处生成一个标记实体(marker),并改为以该实体为参照执行
示例:
execute positioned ~ ~1 ~ as @p run function xze:fx/lightning/spawn_with {particle:"minecraft:electric_spark"}
TPS 影响:低
螺旋
函数:
xze:fx/spiral/spawn_with {...} | 在原点与目标实体之间绘制柱状螺旋线
particle: String | 用于绘制螺旋线的粒子类型
radius: Number | 螺旋线的半径,单位为方块
period: Number | 螺旋线完成一整圈旋转所需的距离,单位为方块
angle: Number | 螺旋线的起始旋转角度,单位为弧度。如果不确定,请使用 0
- 必须在原点执行,并作为移动目标实体执行
- 若要定位到特定位置,请在该处生成一个标记实体(marker),并改为以该实体为参照执行
示例:
execute positioned ~ ~1 ~ as @p run function xze:fx/spiral/spawn_with {particle:"minecraft:electric_spark",radius:0.8,period:2,angle:0}
注意事项:
- 将游戏内规则
max_command_sequence_length 设置为更大的数值(如 1000000),否则螺旋线可能会被截断
TPS 影响:中等
圆形
函数:
function xze:fx/circle/spawn_with {...} | 在与当前上下文方向垂直的平面上绘制圆形
particle: String | 用于绘制圆形的粒子类型
radius: Number | 圆形的半径,单位为方块
示例:
/execute anchored eyes positioned ^ ^ ^5 run function xze:fx/circle/spawn_with {particle:"minecraft:end_rod",radius:2.5}
TPS 影响:无
球体
函数:
xze:fx/sphere/spawn_with {...} | 绘制一个球体
particle: String | 用于绘制球体的粒子类型
radius: Number | 球体的半径,单位为方块
示例:
/execute anchored eyes positioned ^ ^ ^8 run function xze:fx/sphere/spawn_with {particle:"minecraft:end_rod",radius:4}
TPS 影响:极低
- 极大的球体(半径 >= 16)可能会产生数毫秒的影响,因为它们会执行大量的粒子命令
直线
函数:
xze:fx/line/spawn_with {...} | 在当前上下文位置与上下文实体之间绘制直线
particle: String | 用于绘制直线的粒子类型
- 必须在原点执行,并作为移动目标实体执行
- 若要定位到特定位置,请在该处生成一个标记实体(marker),并改为以该实体为参照执行
示例:
execute positioned ~ ~1 ~ as @p run function xze:fx/line/spawn_with {particle:"minecraft:electric_spark"}
TPS 影响:极低
移动方块边缘轮廓
函数:
function xze:fx/block_edges_moving/spawn_with {...} | 生成沿方块边缘短暂移动的粒子
particle: String | 生成的粒子类型
示例:
/execute anchored eyes positioned ^ ^ ^4 run function xze:fx/block_edges_moving/spawn_with {particle:"minecraft:end_rod"}
注意事项:
TPS 影响:无
方块角点
函数:
function xze:fx/block_verticies/spawn_with {...} | 在方块的 8 个角点上绘制粒子
particle: String | 生成的粒子类型
示例:
/execute anchored eyes positioned ^ ^ ^4 run function xze:fx/block_verticies/spawn_with {particle:"minecraft:end_rod"}
注意事项:
TPS 影响:无
标记实体
许多效果同时使用一个原点坐标和一个实体,以提高性能和简化实现。
虽然这在绘制点和目标之间的效果时非常方便,但当所需的目标位置不是实体,或者特指实体的脚部时,就会变得困难。
因此,这里提供了一组辅助函数来生成和删除标记。
该标记具有固定的 UUID,使其选择速度极快,并且无需使用 @e 或 @n。
标记的 UUID:91b50803-54c7-44b9-8a3d-6384cfa2939d
例如,要在坐标 0 10 0 和 20 10 20 之间绘制一道闪电,可以使用如下函数:
execute positioned 20 10 20 run function xze:marker/spawn
execute positioned 0 10 0 as 91b50803-54c7-44b9-8a3d-6384cfa2939d run function xze:fx/lightning/spawn_with {particle:"minecraft:electric_spark"}
function xze:marker/delete
关键在于,必须确保此标记不会被卸载。因此,一旦不再需要它,应立即将其删除。
函数
xze:marker/spawn | 在上下文位置生成标记。如果标记已经存在,则将其传送至该位置
xze:marker/delete | 通过 /kill 命令删除标记
xze:marker/tp | 将标记传送到上下文位置
技巧与提示
移动效果
每个效果都接受一个 particle 参数。该参数通常采用简单的粒子名称形式,如 "minecraft:flame"。
然而,宏本身实际上只是内部 /particle 命令的参数,这意味着可以在每个效果(移动方块轮廓效果除外)的字段中提供额外的参数。例如,可以像这样创建一个扩展的球体:
/execute at @s anchored eyes positioned ^ ^ ^10 run function xze:fx/sphere/spawn_with {particle:"minecraft:end_rod ~ ~ ~ ^ ^ ^100000 0.000002 0 force",radius:4}
- 速度由 Speed 参数控制,即
0.000002。非常微小的变化都会产生显著差异。
- 方向由 Delta 参数的最后一个值控制,即
^100000。将此值设为负数(^-100000)将使球体收缩而非扩张。
单tick粒子
有时您可能希望在效果中使用某种粒子,但给定的粒子在之后持续存在的时间过长。
例如,生成 minecraft:flame 闪电会导致闪电形状持续几秒钟。
为了解决这个问题,可以调整 particle 字段中的 Delta、Speed 和 Count 参数,使粒子在一 tick 后消失。
例如:
/execute positioned ~ ~1 ~ as @p run function xze:fx/lightning/spawn_with {particle:"minecraft:flame ~ ~ ~ ^ ^ ^10000 10000 0"}
- 这通过将粒子移动得极快来实现,使其在下个 tick 时消失。
遵循 Smithed Datapack Conventions
本项目未在任何方面使用生成式 AI。
xokz's Particle Effects
This datapack is purely a library, and contains no ticking function. It exists only to be called by other datapacks, and/or to be modified.
It provides several useful effects for datapackers and mapmakers.
Run /function xze:demo/laser or /function xze:demo/ball for a demo!
Effect Catalog
Lightning
Functions:
xze:fx/lightning/spawn_with {...} | Spawns a lightning-shaped bolt of particles
particle: String | Particle the lightning is drawn with
- Must be run at the starting point, and as the entity to move towards
- To target a location instead, spawn a marker there and run as that
Examples:
execute positioned ~ ~1 ~ as @p run function xze:fx/lightning/spawn_with {particle:"minecraft:electric_spark"}
- Put this in a repeating command block and see what happens
TPS Impact: Low
Spiral
Functions:
xze:fx/spiral/spawn_with {...} | Draws a columnal spiral between the origin point and target entity
particle: String | Particle the spiral is drawn with
radius: Number | Radius of the spiral, in blocks
period: Number | Distance required for the spiral to complete a full rotation, in blocks
angle: Number | The starting rotation angle of the spiral, in radians. If unsure, use 0
- Must be run at the origin point, and as the entity to move towards
- To target a location instead, spawn a marker there and run as that
Examples:
execute positioned ~ ~1 ~ as @p run function xze:fx/spiral/spawn_with {particle:"minecraft:electric_spark",radius:0.8,period:2,angle:0}
- Put this in a repeating command block
Notes:
- Increase the gamerule
max_command_sequence_length to a larger number like 1000000, otherwise the spiral may get cut off
TPS Impact: Medium
- Depends how long the spiral is and how frequently it is being spawned
Circle
Functions:
function xze:fx/circle/spawn_with {...} | Draws a circle perpendicular to the context direction
particle: String | Particle the circle is drawn with
radius: Number | Radius of the circle, in blocks
Examples:
/execute anchored eyes positioned ^ ^ ^5 run function xze:fx/circle/spawn_with {particle:"minecraft:end_rod",radius:2.5}
TPS Impact: None
Sphere
Functions:
xze:fx/sphere/spawn_with {...} | Draws a sphere
particle: String | Particle the sphere is drawn with
radius: Number | Radius of the sphere, in blocks
Examples:
/execute anchored eyes positioned ^ ^ ^8 run function xze:fx/sphere/spawn_with {particle:"minecraft:end_rod",radius:4}
TPS Impact: Very Low
- Very large spheres (radius >=16) may have a multi ms impact, as they run many particle commands
Line
Functions:
xze:fx/line/spawn_with {...} | Draws a line between the context position and the context entity
particle: String | Particle the line is drawn with
- Must be run at the origin point, and as the entity to move towards
- To target a location instead, spawn a marker there and run as that
Examples:
execute positioned ~ ~1 ~ as @p run function xze:fx/line/spawn_with {particle:"minecraft:electric_spark"}
- Put this in a repeating command block
TPS Impact: Very Low
Moving Block Edge Outline
Functions:
function xze:fx/block_edges_moving/spawn_with {...} | Spawns particles that briefly move along the edge of a block
particle: String | Particles that are spawned
Examples:
/execute anchored eyes positioned ^ ^ ^4 run function xze:fx/block_edges_moving/spawn_with {particle:"minecraft:end_rod"}
Notes:
- Automatically snaps to the block grid, no need to manually align
TPS Impact: None
Block Corners
Functions:
function xze:fx/block_verticies/spawn_with {...} | Draws a particle on the 8 corners of a block
particle: String | Particles that are spawned
Examples:
/execute anchored eyes positioned ^ ^ ^4 run function xze:fx/block_verticies/spawn_with {particle:"minecraft:end_rod"}
Notes:
- Automatically snaps to the block grid
TPS Impact: None
The Marker
Several effects use both an origin point an an entity for performance and ease of implementation.
While this can be very convenient for drawing an effect bewteen a point and a target, it can be
difficult when the desired destination is not an entity, or specifically not the feet of an entity.
For this reason there is a set of helper functions that spawns and removes a marker.
This marker has a fixed UUID, making it extremely fast to select, and removes the need for an @e or @n.
The Marker's UUID: 91b50803-54c7-44b9-8a3d-6384cfa2939d
For example, To draw a lightning bolt between positions 0 10 0 and 20 10 20, a function like this could be used:
execute positioned 20 10 20 run function xze:marker/spawn
execute positioned 0 10 0 as 91b50803-54c7-44b9-8a3d-6384cfa2939d run function xze:fx/lightning/spawn_with {particle:"minecraft:electric_spark"}
function xze:marker/delete
Critically, it is important that this marker does not get unloaded. Thus, it should be deleted as soon as it is no longer needed.
Functions
xze:marker/spawn | Spawns the marker at the context location. If the marker is already spawned, teleports it there instead
xze:marker/delete | Deletes the marker via /kill
xze:marker/tp | Teleports the marker to the context location
Tips and Tricks
Moving Effects
Every effect takes in a particle argument. This argument typically takes the form of a simple particle name, like "minecraft:flame".
However, the macro itself is just the arguments for the /particle command internally, which means that additional
arguments can be provided in the field in every effect (except for the moving block outline effect). For example, this can be used
to create an expanding sphere, like so:
/execute at @s anchored eyes positioned ^ ^ ^10 run function xze:fx/sphere/spawn_with {particle:"minecraft:end_rod ~ ~ ~ ^ ^ ^100000 0.000002 0 force",radius:4}
- The speed is controlled by the Speed argument, the
0.000002. Very small changes can make big differences.
- The direction is controlled by the last value in the Delta argument, the
^100000. Making this value negative (^-100000) will
cause the sphere to contract instead.
1-Tick Particles
Sometimes it may be desired to use a certain particle in an effect, but the given particle persists for too long afterwards.
For example, spawning a minecraft:flame lightning bolt would result in the lightning shape lasting for several seconds.
To remedy this, the Delta, Speed, and Count arguments in the particle field can be adjusted to make the particle disappear after a tick.
For example:
/execute positioned ~ ~1 ~ as @p run function xze:fx/lightning/spawn_with {particle:"minecraft:flame ~ ~ ~ ^ ^ ^10000 10000 0"}
- Put this in a repeating command block
- This works by making the particle move so fast that they disappear the next tick.
Follows the Smithed Datapack Conventions
No generative AI was used in this project in any capacity.
评论 0
登录后参与评分
还没有评论,来抢沙发吧