Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement

Template:Bedrock Edition Developer Documentation

Information icon
此特性为基岩版独有。

Template:Translation:未知参数。

Ic translate
此条目的(部分)内容需要翻译。

你可以帮助我们来翻译此条目,但请勿使用机器翻译

翻译者从英文条目翻译下文中的内容时感觉其艰涩难懂。

翻译者希望更有能力的用户能够帮助改善本条目的行文,所以请先慎重对待本条目内容。
如果可能,请帮助我们完善此条目的内容。

Brush
该文章需要整理以符合格式指导 讨论

请帮助优化文章格式来让它符合格式指导。

这是适用于基岩版1.12.0颗粒效果文档

版本:1.12.0.28

颗粒效果示例包

https://aka.ms/MCParticlesPack

上方的链接中提供了若干种颗粒效果的示例。这些示例展示了多种独立运作的颗粒效果,它们与游戏本体一同安装,经过了调整来与游戏协同运作。因此,它们并不能作为合格的颗粒效果示例被给出。敬请参考包中的示例以获悉应用颗粒系统的多种方式。

想要在示例颗粒包启用的情况下调用示例颗粒,首先唤起控制台,执行"/particle name x y z"(这里的"name"为颗粒效果的名称,x/y/z为颗粒效果出现的位置)。

例如执行"/particle minecraft:example_smoke_puff 0 5 0"指令会在世界出生点生成一团距世界底部5格高的烟雾;
而"/particle minecraft:example_smoke_puff ~ ~1 ~5"指令则会将烟雾生成在玩家的5格开外。

示例效果
Name Description
minecraft:example_beziercurve 在颗粒效果中展示贝塞尔曲线的运用
minecraft:example_bounce 展示颗粒效果的碰撞检测与弹跳效果
minecraft:example_catmullromcurve 在效果中展示catmull-rom曲线的运用
minecraft:example_colorcurve 在颗粒效果中展示色彩渐变的运用
minecraft:example_colorcurve2 在颗粒效果中展示协同可变间距的色彩渐变的运用
minecraft:example_combocurve 在颗粒效果中展示各类曲线的运用
minecraft:example_directional_sphere Demonstrates the use of directional billboard facing in an effect
minecraft:example_entity_sparkle_box When attached to an entity, this effect creates a sparkle effect in a box around the entity
minecraft:example_entity_sparkle_aabb When attached to an entity, this effect creates a sparkle effect with the rough axis-aligned bounding box around the entity
minecraft:example_expire_on_contact Demonstrates particles disappearing when colliding with the terrain
minecraft:example_flipbook Demonstrates texture uv flipbook technique, of applying successive frames of a texture for visual animation
minecraft:example_highrestitution Demonstrates particle collision with particles gaining energy on each bounce
minecraft:example_linearcurve Demonstrates a piecewise linear curve in an effect
minecraft:example_particle_event_system Demonstrates various particle events executing
minecraft:example_smoke_puff Demonstrates a general smoke puff effect
minecraft:example_spiral Demonstrates a parametric motion spiral effect
minecraft:example_watertest Demonstrates excluding particles from various block types, in this case, particles only survive in water
minecraft:fireworks_events_demo Demonstrates sequencing various particle effects together via events to create a fireworks effect

组件

颗粒效果系统是基于组件的,也就是说颗粒效果系统是由一系列组件组合而成的。要使颗粒效果运作,你需要加入处理某方面效果的组件。例如,颗粒效果生成容器需要定义其寿命规则,因此效果应该有一条或以上处理颗粒生成器(emitter)和颗粒生成颗粒效果的寿命规则。

新组件可以在晚些时候加进来,开发者可把组件合并以获得不同的行为。例如,颗粒可以拥有四处移动的动态(Dynamic)组件以及处理与地形之间的互动的碰撞(Collision)组件。这些组件会告知颗粒系统开发者想让生成器或颗粒做的事情,而不是给出一个颗粒参数列表并不断调整这些参数而获得所需实现的行为。

命名空间

所有颗粒系统都必须在其名称中命名空间化。

在效果标签前应该加上“<string:命名空间名称>:”命名空间。

原版Minecraft使用“minecraft:”前缀。

查看§示例来获取示例名称。

与MoLang的交互

任何可用的字段都能使用MoLang表达式。MoLang表达式是一个字符串,并在MoLang文档中定义。颗粒系统使用一些特殊的MoLang变量以供颗粒MoLang表达式使用。另外,设置自定义MoLang参数的方法有很多,它也用在效果中的MoLang表达式里。

参数
名称 描述
variable.particle_lifetime 颗粒效果持续总时间。
variable.particle_age 颗粒已持续时间。
variable.particle_random_1 一个从0.0到1.0的随机数,在颗粒的持续时间内保持不变。
variable.particle_random_2 另一个从0.0到1.0的随机数,在颗粒的持续时间内保持不变。
variable.particle_random_3 第三个从0.0到1.0的随机数,在颗粒的持续时间内保持不变。
variable.particle_random_4 第四个从0.0到1.0的随机数,在颗粒的持续时间内保持不变。
variable.emitter_lifetime 颗粒生成容器的当前循环持续多长时间。
variable.emitter_age 颗粒生成容器当前循环启动后已持续时间。
variable.emitter_random_1 一个从0.0到1.0的随机数,在颗粒生成容器的当前循环内保持不变。
variable.emitter_random_2 另一个从0.0到1.0的随机数,在颗粒生成容器的当前循环内保持不变。
variable.emitter_random_3 第三个从0.0到1.0的随机数,在颗粒生成容器的当前循环内保持不变。
variable.emitter_random_4 第四个从0.0到1.0的随机数,在颗粒生成容器的当前循环内保持不变。
variable.entity_scale 当效果附加到一个实体时,此值是实体的大小比例

基础结构概览

颗粒效果由基本渲染参数和一系列组件组成。组件的放置顺序没有限制。

概要:
{
  "format_version": "1.10.0",
  "particle_effect": {
    "description": {
      "identifier": <string>, 
      // 例:“minecraft:test_effect”为要引用的颗粒
      "basic_render_parameters": {
          "material": <string> 
          // 颗粒颗粒生成容器使用的材料
          "texture": <string> 
          // 颗粒颗粒生成容器使用的材质
      }
    },
    "curves": {
      // 有关曲线的定义
    },
    "components": 
      // 有关颗粒生成频率的组件

      // 有关颗粒生成时长的组件

      // 有关颗粒生成形状(或通过颗粒颗粒生成位置和方向定义其形状)的组件

      // 颗粒生成容器本地空间(local space)组件

      // 控制颗粒初始状态的组件

      // 控制/引导颗粒行为的组件

      // 影响颗粒渲染方式的组件

      // 影响颗粒效果时长的组件
    }
  }
}

结构详细内容

概要:
{
  // 颗粒效果文件的格式版本. Only particles of a particular set of versions 
  // 和游戏一同启用
  "format_version": "1.10.0",

  "particle_effect": {
    // 颗粒效果的基本参数
    "description": {
      // 例:"minecraft:test_mule", 这是颗粒效果颗粒生成器的名字。
      "identifier": <string>, 

      // 必要的基本参数:material,texture
      // 所有的颗粒效果需要一个材质(material)来渲染,和一个
      // 贴图(texture)来显示。
      "basic_render_parameters": {
          "material": <string>
          "texture": <string>
      },
    },

    "curves": {
	  // 有关曲线(curves)的内容在此文档的其他地方有介绍
    },

    "events": {
      // 有关事件(events)的内容在此文档的其他地方有介绍
    },

    "components: {
        /////////////////////////////////////////////////////////////////////
        // 与颗粒生成器有关的组件
        // 这些组件主要影响颗粒生成器的行为

        // 颗粒生成器初始状态组件会组成一个拥有特殊属性的颗粒生成器

        // 颗粒生成器速率组件控制颗粒生成的时间
        // 这些会在颗粒生成后的每一帧运行,以确定是否需要产生任何颗粒。

        // 颗粒生成器时长组件控制生成颗粒的总时长和生成器的“启用/停用”状态
        // 颗粒生成器只会在启用时生成颗粒

        // 颗粒生成器形状组件控制颗粒应该在哪里被生成
        // 和它的初始形状状态,如颗粒的方向

        // emitter local space components
        // this component specifies whether entity-based emitters 
        // simulate in local or global space

        /////////////////////////////////////////////////////////////////////
        // 与颗粒有关的组件
        // 这些组件主要影响颗粒的行为

        // 颗粒初始状态组件控制颗粒的初始状态,
        // 例如初始速度、方向等等。
        // 这些在粒子被创建时只执行一次

        // 颗粒动量组件控制粒子在被创建后每一帧的变化,
        // 例如它的方向(仅带参数的粒子)、
        // 阻力(drag)/加速度(acceleration)(仅动态的粒子)等等。
        // 这些在每个颗粒的每一帧里执行一次

        // 粒子外观组件控制粒子被渲染的方式 
        // 例如使用哪种贴图轴坐标系(UV coortinates)、
        // 粒子的大小、面朝方向、着色等等。
        // 这些在每个可见颗粒的每一帧里执行一次

        // these components handle when the particle expires
    }
  }
}

曲线

曲线是插值(interpolation values)。输入0到1的数值,输出由曲线决定。曲线的输出结果是一个能被MoLang引用的同名MoLang变量。在每一个颗粒的每一个需要渲染的帧里,曲线将被运算,结果将保存在一个这个曲线的名字的MoLang变量中。
看完下面的例子你将更容易理解上述内容

    "curves": {
      // “molangvar”是在之后的MoLang表达式中将被使用的MoLang变量
      // 例如在此填写"variable.mycurve"会让曲线的结果
      // 在MoLang中表示为"variable.mycurve"。注意所有的变量都要
      // 以"variable"开头。
      "molangvar": {
        // 类型可以是“linear”、“bezier”或"catmull_rom"
        "type": type, 

        // 曲线的控制节点(node)。假设这些节点的间距相等,
        // 例:第一个节点在输入值0上,第二个在0.25上,以此类推。
        "nodes": [<float/molang>, <float/molang>, <float/molang>, <float/molang>],

        // 输入值
        "input": <float/molang>,

        // 输入值会被映射到0到此值的范围内
        "horizontal_range": <float/molang>
      }
    }


事件

事件(events)是可以在.json文件中的任何地方触发的颗粒事件。每一个事件触发一个粒子效果。如果类型是"emitter",this will create an emitter of "effect" type at the event's world position, in a fire-and-forget way. "emitter_bound" works similarly, except if the spawning emitter is bound to an actor/locator, the new emitter will be bound to the same actor/locator. If the type is "particle", then the event will manually emit a particle on an emitter of "effect" type at the event location, creating the emitter if it doesn't already exist (be sure to use "minecraft:emitter_rate_manual" for the spawned emitter effect). "particle_with_velocity" will do the same as "particle" except the new particle will inherit the spawning particle's velocity.

The events themselves consist of an optional node tree and/or an actual event. When "sequence" is specified, that array will execute in order, with every element executing when that event fires. When using "random", one element will be picked from the array based on the weight.

	// 事件块语句:
	"events": {
		"event_name1",
		"event_name2",
		...
	}

	// 一个事件的结构, note that nesting can be any combination of "sequence", or "randomize"
      "event_name": {
        "sequence": [
          { /* 这些先执行 */ },
          { /* 这些后执行 */ },
          { /* 其他 */},
          { 
            "sequence": [
              { 
                // nested nodes
              },
              ...
            ]
          },
          { 
            "randomize": [
              {
                "weight": <float>
                /* data for this option, including other sequences/randoms */
              },
              ...
            ]
          }
        ]
      },

      // Fields for a particlar event.  Note that any of the above nodes can have events inserted into their blocks.
      "event_subpart": {
          "particle_effect": {
            // identifier of the effect
            "effect": <string>,
            // "emitter", "emitter_bound", "particle" or "particle_with_velocity"
            "type": <string>,
            // this MoLang is run on the emitter for this event once this
            // event fires
            // NOTE: this will not have access to the event
            // triggering emitter's MoLang data
            "pre_effect_expression": <string>,
          },
          // Runs this MoLang expression on the event-firing emitter
          "expression": <string>,
          // for debugging, this will log a message, along with the firing effect's name and event position
          // the log message will show up in the content logger
          "log": <string>
      }

    // simple example:
    "events": {
        "event_name1": {
            "particle_effect": {
                "effect": "a_particle_effect",
                "type": "emitter"
            }
        }
    }


现行的组件列表

在这些组件的字段里可使用下列标记:

<float> - 接受浮点数输入的字段
<float/molang> - 接受浮点数或MoLang表达式输入的字段
<default:val> - 如果字段未指定输入则使用指定的默认值
<bool> - true或false
<string> - 字符串
<default> - 不属于特定行的部分,如果字段未指定输入则使用其默认值

颗粒生成容器类组件(Emitter Components)

颗粒生成容器寿命类组件(Emitter Lifetime Components)

颗粒生成容器寿命表达式组件(Emitter Lifetime Expression component)

当表达式为非0时生成器将打开,当为0时关闭。这对于形如以一个行为变量来驱动一个实体关联性颗粒生成器一类的情况用途显著。

"minecraft:emitter_lifetime_expression": {
    // When the expression is non-zero, the emitter will emit particles.
    // Evaluated every frame
    "activation_expression": <float/molang> <default:1>

    // Emitter will expire if the expression is non-zero.
    // Evaluated every frame
    "expiration_expression": <float/molang> <default:0>
}


颗粒生成容器循环执行组件(Emitter Lifetime Looping component)

颗粒生成器将循环工作直到其被去除。

"minecraft:emitter_lifetime_looping": {

    // emitter will emit particles for this time per loop
    // evaluated once per particle emitter loop
    "active_time": <float/molang> <default:10>

    // emitter will pause emitting particles for this time per loop
    // evaluated once per particle emitter loop
    "sleep_time": <float/molang> <default:0>
}


颗粒生成容器单次执行组件(Emitter Lifetime Once component)

颗粒生成器将执行一次。一旦颗粒寿命结束或被允许生成的颗粒数已被生成,生成器终止。

"minecraft:emitter_lifetime_once": {
    // how long the particles emit for
    // evaluated once
    "active_time": <float/molang> <default:10>
}

颗粒生成容器频率类组件(Emitter Rate Components)

颗粒生成容器即时生成组件(Emitter Rate Instant component)

所有颗粒被一次生成,接下来除非生成器循环,否则行为结束。

"minecraft:emitter_rate_instant": {
    // this many particles are emitted at once
    // evaluated once per particle emitter loop
    "num_particles": <float/molang> <default:10>
}


颗粒生成容器手动生成组件(Emitter Rate Manual component)

颗粒仅在其生成器被指示通过游戏来自主工作时被生成。这被那些已非现役的颗粒效果广泛运用。

"minecraft:emitter_rate_manual": {
    // evaluated once per particle emitted
    "max_particles": <float/molang> <default:50>
}


颗粒生成容器稳定生成组件(Emitter Rate Steady component)

颗粒随时间以一个稳定或合乎MoLang的比率被生成。

"minecraft:emitter_rate_steady": {
    // how often a particle is emitted, in particles/sec
    // evaluated once per particle emitted
    "spawn_rate": <float/molang> <default:1>

    // maximum number of particles that can be active at once for this emitter
    // evaluated once per particle emitter loop
    "max_particles": <float/molang> <default:50>
}

颗粒生成容器形状类组件(Emitter Shape Components)

形状控制颗粒生成源的朝向及颗粒的初始朝向。

颗粒生成容器自定义形状组件(Emitter Shape Custom component)

所有颗粒都基于一个指定的MoLang表达式被生成。

"minecraft:emitter_shape_custom": {
    // specifies the offset from the emitter to emit the particles
    // evaluated once per particle emitted
    "offset": [<float/molang>, <float/molang>, <float/molang>] <default:[0, 0, 0]>

    // specifies the direciton for the particle
    // evaluated once per particle emitted
    "direction": [<float/molang>, <float/molang>, <float/molang>] <default:[0, 0, 0]>    
}


颗粒生成容器轴向边界盒形状组件(Emitter Shape Entity-AABB component)

所有颗粒均从生成器所依附实体(当无实体时为生成点)的轴向边界盒(Axis-Aligned Bounding Box;AABB)被生成出。

"minecraft:emitter_shape_entity_aabb": {
    // evaluated once per particle emitted
    "direction": [<float/molang>, <float/molang>, <float/molang>] <default:[0, 0, 0]>    
}


颗粒生成容器偏移点组件(Emitter Shape Point component)

所有颗粒均生成自来源于生成器的点状偏移。

"minecraft:emitter_shape_point": {
    // specifies the offset from the emitter to emit the particles
    // evaluated once per particle emitted
    "offset": [<float/molang>, <float/molang>, <float/molang>] <default:[0, 0, 0]>

    // specifies the direciton of particles.  
    // evaluated once per particle emitted
    "direction": [<float/molang>, <float/molang>, <float/molang>]
}


颗粒生成容器球体形状组件(Emitter Shape Sphere component)

所有颗粒均生成自来源于生成器的球状偏移。

"minecraft:emitter_shape_sphere": {
    // specifies the offset from the emitter to emit the particles
    // evaluated once per particle emitted
    "offset": [<float/molang>, <float/molang>, <float/molang>] <default:[0, 0, 0]>

    // sphere radius
    // evaluated once per particle emitted
    "radius": <float/molang> <default:1>

    // emit only from the surface of the sphere
    "surface_only": <bool> <default:false>

    // specifies the direciton of particles.  Defaults to "outwards"
    "direction": "inwards" // particle direction towards center of sphere
    "direction": "outwards" // particle direction away from center of sphere
    // evaluated once per particle emitted
    "direction": [<float/molang>, <float/molang>, <float/molang>]
}

初始状态类组件(Initial State components)

颗粒生成容器本地空间组件(Emitter Local Space component)

这种组件指定了颗粒生成器的参考框架,仅在生成器依附于实体时被应用。当“position”的布尔值为“true”时,颗粒将模拟实体的形状,否则其将模拟世界的形状。控制转向的“rotation”工作模式相同。两者的默认布尔值均为“false”,使得颗粒相对于生成器被生成,接着独立地模拟实体。需要注意的是,“rotation”及“position”的布尔值分别为“true”与“false”是非法设置。

"minecraft:emitter_local_space": {
    "position": <bool>
    "rotation": <bool>
}

颗粒类组件(Particle Components)

颗粒外形类组件(Particle Appearance Components)

颗粒告示牌组件(Particle Appearance Billboard component)

该组件能告知颗粒系统如何显示给玩家一个相对于游戏世界方向的镜头,以及该以怎么样的朝向呈现给该镜头。

"minecraft:particle_appearance_billboard": {
    // specifies the x/y size of the billboard
    // evaluated every frame
    "size": [<float/molang>, <float/molang>],

    // used to orient the billboard.  Options are:
    // "rotate_xyz" - aligned to the camera, perpendicular to the view axis
    // "rotate_y" -aligned to camera, but rotating around world y axis
    // "lookat_xyz" - aimed at the camera, biased towards world y up
    // "lookat_y" - aimed at the camera, but rotating around world y axis
    // "direction" - billboard is aligned perpendicular to the direction vector, 
    //    e.g. a direction of [0, 1, 0] would have the particle facing upwards
    "face_camera_mode": <string>

    // specifies the UVs for the particle.  
    "uv": {
        // specifies the assumed texture width/height
        // defaults to 1
        // when set to 1, UV's work just like normalized UV's
		// when set to the texture width/height, this works like texels
        "texturewidth": <int>,
        "textureheight": <int>,

        // Assuming the specified texture width and height, use these 
        // uv coordinates.  
        // evaluated every frame
        "uv": [<float/molang>, <float/molang>],
        "uv_size": [<float/molang>, <float/molang>],

        // alternate way via specifying a flipbook animation
		// a flipbook animation uses pieces of the texture to animate, by stepping over time from one 
		// "frame" to another
        "flipbook": {
            "base_UV": [ <float/molang>, <float/molang> ], // upper-left corner of starting UV patch
            "size_UV": [ <float>, <float> ], // size of UV patch
            "step_UV": [ <float>, <float> ], // how far to move the UV patch each frame
            "frames_per_second": <float>, // default frames per second
            "max_frame": <float/molang>, // maximum frame number, with first frame being frame 1
            "stretch_to_lifetime": <bool>, // optional, adjust fps to match lifetime of particle. default=false
            "loop":  <bool> // optional, makes the animation loop when it reaches the end? default=false
        }
    }
}


颗粒光源组件(Particle Appearance Lighting)

当存在该组件时,颗粒将在游戏中通过局部照明的方式来进行着色

"minecraft:particle_appearance_lighting": {}


颗粒外形着色组件(Particle Appearance Tinging component)
// color fields are special, they can be either an RGB, or a "#RRGGBB"
// field (or RGBA or "AARRGGBB").  If RGB(A), the channels are
// from 0 to 1.  If the string is "#RRGGBB" or "#AARRGGBB", the values are
// hex from 00 to ff.
//
// this pseudo-type will be denoted by <color>
"minecraft:particle_appearance_tinting": {
    // interpolation based color
    "color": {
        // an array of colors
        // it is assumed that the colors are equally spaced for interpolation
        // and that the range of the color interpolation values are 0 to 1
        //
        // for example, a 3 color "color" field with an interpolant value
        // of 0.5 would pick the second color
        "gradient": [ <color>, <color>, ...],
        "interpolant": <float/molang> // hint: use a curve here!
    }

    // directly set the color
    "color": <color>
}



颗粒初始状态类组件(Particle Initial State Components)

颗粒初始速度组件(Particle Initial Speed Component)

该组件控制颗粒以一个指定的速度以及由生成器形状决定的朝向生成。

// evaluated once
"minecraft:particle_initial_speed": <float/molang> <default:0>


颗粒初始状态组件(Particle Initial State Component)

该组件控制颗粒以一个指定的方位及转角生成。

"minecraft:particle_initial_spin": {
    // specifies the initial rotation in degrees
    // evaluated once
    "rotation": <float/molang> <default:0>

    // specifies the spin rate in degrees/second
    // evaluated once
    "rotation_rate": <float/molang> <default:0>
}

颗粒寿命类组件(Particle Lifetime Components)

方块中终止颗粒组件(Particle Expire If In Blocks component)

该组件控制颗粒当处在列表列出的方块类型中时终止。注意:该组件可与particle_lifetime_expression并行。

"minecraft:particle_expire_if_in_blocks" [
    // minecraft block names, e.g. 'minecraft:water', 'minecraft:air'
    // these are typically the same name as in the /setblock command
    // except for the minecraft: prefix
    "blockname1",
    "blockname2", 
    ...
],


方块中不终止颗粒组件(Particle Expire If Not In Blocks component)

该组件控制颗粒当处在列表列出的方块类型中时不终止。注意:该组件可与particle_lifetime_expression并行。

"minecraft:particle_expire_if_not_in_blocks" [
    // minecraft block names, e.g. 'minecraft:water', 'minecraft:air'
    // these are typically the same name as in the /setblock command
    // except for the minecraft: prefix
    "blockname1",
    "blockname2", 
    ...
],


颗粒寿命表达式组件(Particle Lifetime Expression component)

标准的寿命组件。这些表达式控制颗粒的寿命。

"minecraft:particle_lifetime_expression": {
    // this expression makes the particle expire when true (non-zero)
    // The float/expr is evaluated once per particle
    // evaluated every frame
    "expiration_expression": <float/molang> <default:0>
 
	// alternate way to express lifetime
    // particle will expire after this much time
    // evaluated once
    "max_lifetime": <float/molang>
},

颗粒运动类组件(Particle Motion Components)

颗粒运动碰撞组件(Particle Motion Collision component)

该组件使得地形与颗粒能够产生碰撞。Minecraft中的碰撞监测包括监测二者的交集,为颗粒移动到最近的非交集点(如果可能)并设置导向使其不会瞄准碰撞(通常是与碰撞表面垂直)。注意:若该组件不存在,碰撞将不会发生。

"minecraft:particle_motion_collision": {
    // enables collision when true/non-zero.
    // evaluated every frame
    "enabled": <bool/molang> <default:true>

    // alters the speed of the particle when it has collided
    // useful for emulating friction/drag when colliding, e.g a particle
    // that hits the ground would slow to a stop.
    // This drag slows down the particle by this amount in blocks/sec
    // when in contact
    "collision_drag": <float>

    // used for bouncing/not-bouncing
    // Set to 0.0 to not bounce, 1.0 to bounce back up to original height
    // and in-between to lose speed after bouncing.  Set to >1.0 to gain height each bounce
    "coefficient_of_restitution": <float>

    // used to minimize interpenetration of particles with the environment
    // note that this must be less than or equal to 1/2 block
    "collision_radius": <float>
}


颗粒运动动态组件(Particle Motion Dynamic component)

该组件指定了颗粒的动态特性,即促使颗粒行动的模拟立点。这些动态会改变由指向与速率共同决定的颗粒的速度。颗粒的指向将永远是颗粒速度的方向。

"minecraft:particle_motion_dynamic": {
    // the linear acceleration applied to the particle, defaults to [0, 0, 0].
    // Units are blocks/sec/sec
    // An example would be gravity which is [0, -9.8, 0]
    // evaluated every frame
    "linear_acceleration": [<float/molang>, <float/molang>, <float/molang>],

    // using the equation:
    // acceleration = -linear_drag_coefficient*velocity
    // where velocity is the current direction times speed
    // Think of this as air-drag.  The higher the value, the more drag
    // evaluated every frame
    "linear_drag_coefficient": <float/molang> <default:0>

    // acceleration applies to the rotation speed of the particle
    // think of a disc spinning up or a smoke puff that starts rotating
    // but slows down over time
    // evaluated every frame
    // acceleration is in degrees/sec/sec
    "rotation_acceleration" <float/molang> <default:0>

    // drag applied to retard rotation
    // equation is rotation_acceleration += -rotation_rate*rotation_drag_coefficient
    // useful to slow a rotation, or to limit the rotation acceleration
    // Think of a disc that speeds up (acceleration) 
    // but reaches a terminal speed (drag)
    // Another use is if you have a particle growing in size, having
    // the rotation slow down due to drag can add "weight" to the particle's
    // motion
    "rotation_drag_coefficient" <float/molang> <default:0>
}


颗粒运动参数组件(Particle Motion Parametric component)

该组件直接控制颗粒。注意:该组件不工作于手动生成的颗粒及基于实体且不处于本地空间的颗粒生成器。

"minecraft:particle_motion_parametric": {
    // directly set the position relative to the emitter. 
    // E.g. a spiral might be:
    // "relative_position": ["Math.cos(Params.LifeTime)", 1.0, 
    //                       "Math.sin(Params.Lifetime)"]
    // defaults to [0, 0, 0]
    // evaluated every frame
    "relative_position": [<float/molang> <float/molang> <float/molang>]

    // directly set the 3d direction of the particle
    // doesn't affect direction if not specified
    // evaluated every frame
    "direction": [<float/molang> <float/molang> <float/molang]

    // directly set the rotation of the particle
    // evaluated every frame
    "rotation": <float/molang> <default:0>
}}

示例

火焰颗粒

这种形似微小火光的颗粒见于火把熔炉来象征火焰。这种颗粒很简单,包括一个固定不动的火光,仅有一些变化。注意:颗粒行为的变量由MoLang语言创造。

此外,对于告示牌组件的UV节段中材质宽度/高度的运用允许经过材质像素对UV的参考:

{
  "format_version": "1.8.0",
  "particles": {
    "minecraft:basic_flame_particle": {
      "basic_render_parameters": {
        "material": "particles_alpha",
        "texture": "textures/particle/particles"
      },
      "components": {
        "minecraft:emitter_rate_instant": {
          "num_particles": 1
        },
        "minecraft:emitter_lifetime_once": {
          "active_time": 0
        },
        "minecraft:emitter_shape_sphere": {
          "radius": 0.025,
          "direction": [ 0, 0, 0 ]
        },
        "minecraft:particle_lifetime_expression": {
          "max_lifetime": "Math.random(0.6, 2.0) "
		},
		"minecraft:particle_appearance_billboard": {
			"size": [
				"(0.1 + variable.ParticleRandom1*0.1) - (0.1 * variable.ParticleAge)",
					"(0.1 + variable.ParticleRandom1*0.1) - (0.1 * variable.ParticleAge)"
			],
				"facing_camera_mode" : "lookat_xyz",
					"uv" : {
					"texturewidth": 128,
						"textureheight" : 128,
						"uv" : [0, 24],
						"uv_size" : [8, 8]
				}
		}
	  }
	}
  }
}


烟雾颗粒

该颗粒为一种通用的烟雾团,常见于火把熔炉烈焰人等。这是一种带有包括上拉的上向加速度的上向运动。

这种颗粒的主要特性与火焰颗粒的不同之处在于其翻页式的材质动画。见于下方的颗粒细节,但其特效运用了一个告示牌组件中翻页式的子部分来驱动UV坐标随时间推移逐帧变换。

此外,对于告示牌组件的UV节段中材质宽度/高度的运用允许经过翻页式材质像素对UV的参考:

{
  "format_version": "1.8.0",
  "particles": {
    "minecraft:basic_smoke_particle": {
      "basic_render_parameters": {
        "material": "particles_alpha",
        "texture": "textures/particle/particles"
      },
      "components": {
        "minecraft:emitter_rate_instant": {
          "num_particles": 1
        },
        "minecraft:emitter_lifetime_once": {
          "active_time": 0
        },
        "minecraft:emitter_shape_custom": {
          "offset": [ 0, 0, 0 ],
          "direction": [ "Math.random(-0.1, 0.1)", 1.0, "Math.random(-0.1, 0.1)" ]
		},
		"minecraft:particle_initial_speed": 1.0,
			"minecraft:particle_lifetime_expression" : {
			"max_lifetime": "Math.random(0.4, 1.4)"
		},
			"minecraft:particle_motion_dynamic" : {
				"linear_acceleration": [0, 0.4, 0]
			},
				"minecraft:particle_appearance_billboard" : {
					"size": [0.1, 0.1],
						"facing_camera_mode" : "lookat_xyz",
						"uv" : {
						"texturewidth": 128,
							"textureheight" : 128,
							"flipbook" : {
							"base_UV": [56, 0],
								"size_UV" : [8, 8],
								"step_UV" : [-8, 0],
								"frames_per_second" : 8,
								"max_frame" : 8,
								"stretch_to_lifetime" : true,
								"loop" : false
						}
					}
				},
					"minecraft:particle_appearance_tinting": {
					"color": ["variable.ParticleRandom1*0.5", "variable.ParticleRandom1*0.5", "variable.ParticleRandom1*0.5", 1.0]
				},
					"minecraft:particle_appearance_lighting" : {}
	  }
	}
  }
}


生物火焰效果

该效果运用于烈焰人的火球充能状态中。这也是一种上向翻页式的效果。

这种颗粒生成器通常基于实体,因为对火焰萦绕烈焰人周身的需要而允许物品轴向边界盒(AABB)形状的运用。该特效基于实体被创造/破坏,因而特效自身仅需要保持开启。

材质宽度/高度被用以使该效果的材质像素达到”一画一帧“,因此允许了这些帧的推进保持唯一:

{
  "format_version": "1.8.0",
  "particles": {
    "minecraft:mobflame_emitter": {
      "basic_render_parameters": {
        "material": "particles_alpha",
        "texture": "textures/flame_atlas"
      },
      "components": {
        "minecraft:emitter_local_space": {
          "position": true,
          "rotation": true
        },
        "minecraft:emitter_rate_steady": {
          "spawn_rate": "Math.random(15, 25)",
          "max_particles": 50
        },
        "minecraft:emitter_lifetime_expression": {
          "activation_expression": 1,
          "expiration_expression": 0
        },
        "minecraft:emitter_shape_entity_aabb": {
          "direction": [ 0, 1, 0 ]
        },
        "minecraft:particle_initial_speed": "Math.random(0, 1)",
        "minecraft:particle_lifetime_expression": {
          "max_lifetime": 1.25
        },
        "minecraft:particle_motion_dynamic": {
          "linear_acceleration": [ 0, 1.0, 0 ],
          "linear_drag_coefficient": 0.0
        },
        "minecraft:particle_appearance_billboard": {
          "size": [ 0.5, 0.5 ],
          "facing_camera_mode": "lookat_xyz",
          "uv": {
            "texturewidth": 1,
            "textureheight": 32,
            "flipbook": {
              "base_UV": [ 0, 0 ],
              "size_UV": [ 1, 1 ],
              "step_UV": [ 0, 1 ],
              "frames_per_second": 32,
              "max_frame": 32,
              "stretch_to_lifetime": true,
              "loop": false
            }
          }
        }
      }
    }
  }
}


跳动的气泡

该颗粒生成一连串四处弹跳的气泡:

{
  "format_version": "1.8.0",
  "particles": {
    "minecraft:bounce": {
      "basic_render_parameters": {
        "material": "particles_alpha",
        "texture": "textures/particle/particles"
      },
      "components": {
        "minecraft:emitter_rate_instant": {
          "num_particles": 100
        },
        "minecraft:emitter_lifetime_once": {
          "active_time": 2
        },
        "minecraft:emitter_shape_sphere": {
          "offset": [ "Math.random(-0.5, 0.5)", "Math.random(-0.5, 0.5)", "Math.random(-0.5, 0.5)" ],
          "direction": "outwards",
          "radius": 1
        },
        "minecraft:particle_initial_speed": 5.0,
        "minecraft:particle_initial_spin": {
          "rotation": "Math.random(0, 360)",
          "rotation_rate": 0
        },
        "minecraft:particle_lifetime_expression": {
          "max_lifetime": "5"
        },
        "minecraft:particle_motion_dynamic": {
          "linear_acceleration": [ 0, -9.8, 0 ]
        },
        "minecraft:particle_motion_collision": {
          "coefficient_of_restitution": 0.5,
          "collision_drag": 4,
          "collision_radius": 0.1
        },
        "minecraft:particle_appearance_billboard": {
          "size": [ "0.1", "0.1" ],
          "facing_camera_mode": "rotate_xyz",
          "uv": {
            "texturewidth": 128,
            "textureheight": 128,
            "uv": [ 0, 16 ],
            "uv_size": [ 8, 8 ]
          }
        },
        "minecraft:particle_appearance_lighting": {}
      }
    }
  }
}
}

与颗粒实体的交互


基岩引擎中颗粒生成的主要用途是生成与实体,如怪物,相关联的颗粒,例如烈焰人 在攻击程式中燃起火焰,或唤魔者在召唤恼鬼时的魔咒效果。其目标是允许对关联于实体的颗粒的约束及管理。

接下来的概念对于通过.json对其进行管理十分重要:
- 效果列表 它们与材质等一同存在于实体的资源定义.json文件中。它们列出了可用于实体的效果,伴有一个针对效果的内部实体名称,以及将要进行的关联效果。
- 定位器 它们存在于几何文件中并指定了一个几何位置。这些定位器可被关联于主架构,因而可以在动作时跟随主架构。
- 基于动画控制器的颗粒管理 利用动画控制器形态的机械概念,一触而发的以及持续的颗粒效果都可以被启动。
- 动画时轴颗粒管理 因其为实体动画.json文件的一部分,我们可以设置一条在动画播放时于特定时间触发颗粒效果的时间轴。 需要注意:其仅需要动画的.json结构,而非实际的物理动画。

关联于实体的颗粒本质上是与实体绑定的。若该实体终止其存在,则颗粒效果也会随之终止。生成器跟随于实体或实体的定位器。

效果列表(Effect Lists)

该列表列出了实际颗粒效果捆绑的内部颗粒名称,为给实体加入颗粒效果的通用形式。列表中包含有实际颗粒效果简称的清单。所有效果的参考运用其在动画及动画控制器中的简称。注意:其本身并不会使颗粒效果出现。

{
  "format_version": "1.8.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:entity_name",
      ...
       "particle_effects": {
            "shorthand_name1": "effect_name1",
            "shorthand_name2": "effect_name2",
        },
        ...
    }
  }
}



以下这个例子展示了烈焰人的燃焰效果。我们可以在实体的资源定义文件中的“description”节段内增添一个具有name/value对的“particle_effects”节段。“name”是其他.json文件会参考到的名称,而“value”是由颗粒效果的.json文件指定的其本身的名称。

{
  "format_version": "1.8.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "minecraft:blaze",

      ...

       "particle_effects": {
            "charged_flames": "minecraft:mobflame_emitter"
        },

        ...

    }
  }
}


效果事件(Effect Events)


实体中的效果事件具有以下特性:
- “effect”是由实体的资源定义.json文件(颗粒效果列表)所指定的效果名称。它指定了何种颗粒效果应被启动或播放。
- “locator”是一个用以定向资源定义文件中同名定位器的可选参数。通过指定定位器,颗粒生成器将会在实体动画进行时绕跟该定位器,包含其方向。如果其未被指定,效果将在实体原位置产生。
- “pre_effect_script”是一个在颗粒生成器启动时运行的可选参数,其本质为一个MoLang表达式。它可以设置随后可被颗粒效果的.json文件内部参考到的MoLang变量(例如“particle color”,即颗粒颜色)。

{
    "effect": "internal_name",
    "locator": "locator_name", // optional
    "pre_effect_script" // optional
}


动画控制器效果(Animation Controller Effects)


动画控制器可以为效果的状态指定其效果事件。这将允许颗粒效果的列表在状态进入时被启动,以及在颗粒效果脱离该状态时被自动停止。对于那些不终止(或不在其状态转换前终止)的颗粒,它们将在脱离状态时被终止。

其模式为:
"particle_effects": [
// array of effect events
]
这组阵列语法允许多于一种效果在状态进入时被触发。

下面将给出的例子是烈焰人在其动画控制器中的燃焰效果。这种动画控制器共有两层状态:“default”及“flaming”。控制器通过“query.is_charged”这一实体标示检查在两种状态间转换。当处于“flaming”状态时,“charged_flames”效果启动(不带有定位器或初始化MoLang表达式),且在脱离状态时被终止。

{
  "format_version": "1.8.0",
  "animation_controllers": {

    ...

    "controller.animation.blaze.flame": {
      "states": {
        "default": {
          "transitions": [
            { "flaming": "query.is_charged" }
          ]
        },
        "flaming": {
          "particle_effects": [
            {
              "effect": "charged_flames"
            }
          ],
          "transitions": [
            { "default": "!query.is_charged" }
          ]
        }
      }
    },

    ...

  }
}




以下例子展示了另一个唤魔者的魔咒效果。它促使唤魔者以其左手和右手的定位器来执行两个“spell”(魔咒)效果。魔咒效果自身是连续性的,故颗粒生成器会在唤魔者停止施咒前一直保持工作。

{
  "format_version": "1.8.0",
  "animation_controllers": {
    "controller.animation.evoker.general": {
      "states": {
        "default": {
            ...
          "transitions": [
            { "casting": "query.is_casting" }
          ]
        },
        "casting": {
            ...
          "particle_effects": [
            {
              "effect": "spell",
              "locator": "left_hand"
            },
            {
              "effect": "spell",
              "locator": "right_hand"
    	    }
          ],
          "transitions": [
            { "default": "!query.is_casting" }
          ]
        }
      }
    }
  }
}


动画时轴效果(Animation Timeline Effects)

动画本身亦可触发颗粒效果。这均为一些“一键无忧”式的,与时间轴绑定的效果。当动画抵达某个时间点时,(一个或多个)效果即会被触发。

"particle_effects": {
    "time1" : [
        // array of effect events
    ],
    "time2" : [
        // array of effect events
    ],
    "time3" : {
      // single effect
    }
}



“time1”“time2”等等是数值化的时间点(例如“0.0”)。

在下面的例子里,猫咪坐下3秒后,一个烟雾团会被生成。

{
  "format_version": "1.8.0",
  "animations": {
    ...
    "animation.cat.sit": {
      "loop": true,
      "animation_length": 5.0,
      "bones": {
          // bone animation stuff
       },
      "particle_effects": {
        "3.0": [
          {
            "effect": "smoke_puff"
          }
        ]
      }
    },
    ...
    }
  }
}

另见

Advertisement