Files
netease-modsdk-wiki/docs/wiki/particles/disabling-particles.md
2025-03-20 11:52:46 +08:00

49 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 禁用粒子效果
category: 巧思案例
tags:
- 新手
mentions:
- SirLich
- Joelant05
- MedicalJewel105
---
# 禁用粒子效果
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
当你需要禁用某个粒子效果时,建议直接在粒子文件中进行禁用,而不是简单地在 `particles.png` 中将粒子纹理设为透明。此外,与透明化处理相比,完全禁用粒子可能会带来小幅性能提升,因为透明粒子仍会被发射(只是不可见)。
禁用粒子发射的基本原理如下:
::: code-group
```json [RP/particles/some_vanilla_particle.json]
{
"format_version": "1.10.0",
"particle_effect": {
"description": {
"identifier": "minecraft:some_vanilla_particle",
"basic_render_parameters": {
"material": "particles_alpha",
"texture": "textures/particle/particles"
}
},
"components": {
"minecraft:emitter_lifetime_expression": {
"activation_expression": 0, // 立即激活
"expiration_expression": 1 // 立即结束生命周期(单位:秒)
},
"minecraft:emitter_rate_manual": {
"max_particles": 0 // 设置最大粒子生成数为0
}
}
}
}
```
:::
**实现原理说明:**
1. 通过 `emitter_lifetime_expression` 组件将粒子发射器的生命周期设为瞬时0秒激活1秒后过期
2. 使用 `emitter_rate_manual` 组件将最大粒子数设为0彻底阻止粒子生成
3. 保留原始渲染参数确保兼容性,但实际不会产生任何可见粒子