本模组的主要目标是实现一个更优的 apugli 的 custom_footstep 能力的替代方案,但我计划在我想到一些酷炫的想法时,扩展新的能力、动作和条件。
我打算稍后将其中部分内容整合进 Apoli for Origins 1.20.1 :>
特性
- 能力类型
- 替换声音发射 (
techo:replace_sound_emission)
- 替换声音接收 (
techo:replace_sound_reception)
- 实体动作类型
- 播放声音 (
techo:play_sound) - 为原始的 apoli:play_sound 实体动作类型添加了新字段。
- 一种将资源能力值作为统一变量传递给后处理光影的方法(通过 资源值提供程序 数据类型)
能力类型
替换声音发射
将能力持有者发出的声音替换为另一种声音。
类型 ID:techo:replace_sound_emission
字段
| 字段 |
类型 |
默认值 |
描述 |
sounds |
Object |
|
包含 "key": "value" 键值对的对象,用于确定哪个声音("key")将被替换为新声音("value")。"value" 可以是 String、加权声音 或 加权声音数组。支持正则表达式匹配(并在替换中引用捕获组)和资源包声音 |
replace |
Boolean |
true |
正确匹配的声音是否应替换旧声音,还是与旧声音同时播放。如果为 false,旧声音和新声音都将播放 |
entity_action |
Entity Action |
可选 |
如果指定,此动作将在成功替换(或匹配)声音时在执行该能力的玩家身上执行 |
priority |
Integer |
0 |
决定能力的应用优先级。如果多个能力匹配声音,只有具有最高 priority 且 replace 设置为 true 的能力才会替换声音;而具有更高 priority 但 replace 设置为 false 的能力将与旧声音一起播放其声音 |
示例
{
"type": "techo:replace_sound_emission",
"sounds": {
"minecraft:entity.player.burp": "empty",
"entity.generic.eat": "minecraft:empty"
}
}
此示例将 entity.player.burp 和 entity.generic.eat 声音事件替换为 empty,这将静音来自能力持有者的所有进食声音(可以省略 minecraft 命名空间)。
{
"type": "techo:replace_sound_emission",
"sounds": {
"block.([a-z|0-9|-|_]*).step": "block.$1.break"
},
"condition": {
"type": "apoli:on_block",
"inverted": true,
"block_condition": {
"type": "apoli:and",
"conditions": [
{
"type": "apoli:in_tag",
"tag": "minecraft:wool"
}
]
}
}
}
此示例将能力持有者发出的任何踏步声替换为踩踏到的相同方块使用的破坏声(除非该方块是羊毛)。
{
"type": "techo:replace_sound_emission",
"sounds": {
"(.*)": {
"id": "$1",
"pitch": 0.5
}
}
}
此示例将使能力发出器发出的所有声音音高设置为 0.5,使其听起来缓慢且低沉。
{
"type": "techo:replace_sound_emission",
"sounds": {
"entity.player.(hurt|death)": [
{
"id": "minecraft:entity.axolotl.$1",
"volume": 2,
"pitch": 0.5,
"weight": 1
},
{
"id": "minecraft:entity.wither.$1",
"volume": 2,
"pitch": 0.5,
"weight": 1
}
]
},
"entity_action": {
"type": "apoli:execute_command",
"command": "say bleh XP"
},
"priority": 1
}
此示例将能力持有者的死亡和受伤声音替换为来自美西螈或凋灵的相应声音(每种声音有 50% 的几率)。结果声音将减慢 50%("pitch": 0.5),并能在 32 格距离内听到("volume": 2,因此 2 * 16 = 32 blocks)
历史记录
| 版本 |
变更 |
| 1.0.0 |
添加该能力 |
| 1.1.0 |
添加新字段:replace、entity_action、priority。sounds 中的值现在接受 加权声音 |
替换声音接收
将能力持有者接收到的声音替换为另一种声音。
类型 ID:techo:replace_sound_reception
字段
| 字段 |
类型 |
默认值 |
描述 |
sounds |
Object |
|
一个包含 "key": "value" 键值对的对象,用于确定将哪个声音("key")替换为新的声音("value")。"value" 可以是 String、加权声音 (Weighted Sound) 或 加权声音 (Weighted Sounds) 数组。支持正则匹配(在替换中引用捕获组)和资源包声音 |
replace |
Boolean |
true |
是否用新声音替换旧声音,还是与旧声音同时播放。如果为 false,则旧声音和新声音都会播放 |
entity_action |
Entity Action |
可选 |
如果指定,此操作将在成功替换(或匹配)声音时作用于玩家 |
priority |
Integer |
0 |
决定该能力的应用优先级。如果有多个能力匹配该声音,只有 replace 设置为 true 且 priority 最高的能力才会替换声音;而 replace 设置为 false 但具有更高 priority 的能力则会与其声音一起播放 |
示例
{
"type": "techo:replace_sound_reception",
"sounds": {
"(?!.*:ui\\.).*": "empty"
}
}
此示例将使拥有该能力的实体听不到任何声音,除了 UI 声音(例如:它不会静音 minecraft:ui.button.click)。
历史记录
实体动作类型
播放声音
在实体的位置播放声音,或由实体发出声音。
类型 ID: techo:play_sound
!!! Note
音量字段的值用于乘以声音事件的基础距离,该基础距离为 16 个方块(1.0)。
字段
| 字段 |
类型 |
默认值 |
描述 |
sound |
Identifier |
|
要播放的音效 ID。 |
category |
String |
可选 |
如果指定,则定义该音效所属的分类及选项;否则使用调用此动作的实体所指定的分类。接受的值包括 "master"、"music"、"record"、"weather"、"block"、"hostile"、"neutral"、"players"、"ambient" 或 "voice"。 |
volume |
Float |
1.0 |
音效的音量。 |
pitch |
Float |
1.0 |
音效的音调。 |
follow_entity |
Boolean |
false |
当实体移动时,是否让音效听起来是从实体的位置发出的。 |
global |
Boolean |
与 follow_entity 的值相同 |
即使超出范围,维度内的所有玩家是否仍应注册该音效正在播放。如果为 false,即使玩家进入范围内也听不到。 注意:这不会让所有玩家听到的音效都同样响亮。 |
internal |
Boolean |
false |
是否只有播放该音效的实体才能听到它。 |
示例
"entity_action": {
"type": "techo:play_sound",
"sound": "music_disc.pigstep",
"follow_entity": true
}
此示例将播放 pigstep 音乐唱片,若玩家距离播放该音效的实体足够近,则维度内所有玩家均可听到。
"entity_action": {
"type": "techo:play_sound",
"sound": "block.end_portal.spawn",
"volume": 1e9001
}
此示例将在整个维度中播放创建末地传送门的音效,且所有玩家听到的音量均相同(1e9001 会产生特殊的浮点数值:Infinity)。
"entity_action": {
"type": "techo:play_sound",
"sound": "ambient.cave",
"internal": true
}
此示例仅对该实体播放洞穴环境音效。
历史记录
| 版本 |
变更 |
| 1.0.0 |
添加该动作 |
| 1.2.0 |
添加新字段:internal |
数据类型
Weighted Sound
一个 对象,表示可以具有音量和音调的音效。如果在 数组 中,还可以包含权重,用于决定被选中的概率。
用于 替换音效发射 (Replace Sound Emission) 以提供音效替换方案。
字段
| 字段 |
类型 |
默认值 |
描述 |
id |
Identifier |
|
要播放的音效 ID。可包含正则表达式匹配组的反向引用(如 $1、$2 等) |
volume |
Float |
1.0 |
音效的音量。 |
pitch |
Float |
1.0 |
音效的音调。 |
weight |
Positive Integer |
1 |
音效的权重。选中该音效的概率由该权重除以所有权重之和确定(weight / sumOfAllWeights = chance)。 |
示例
[
{
"id": "entity.villager.yes",
"weight": 1
},
{
"id": "entity.villager.no",
"weight": 1
}
]
此示例将以相同的概率返回 entity.villager.yes 或 entity.villager.no。
历史记录
Resource Value Provider
提供来自 Resource 力量的缩放值(用于将整数资源值转换为分数浮点数)。
可以在后处理着色器中代替统一向量/矩阵的任何浮点值传递。
字段
| 字段 |
类型 |
默认值 |
描述 |
resource |
Identifier |
|
将从其设置统一值的资源力量的 ID。 |
scale |
Float |
0.01 |
可以定义而不是 min 和 max 对。由资源提供的值将乘以的系数。 |
min |
Float |
|
应将资源的 min 边界映射到的值。如果与 max 一起定义,则将替代 scale 使用。 |
max |
Float |
|
应将资源的 max 边界映射到的值。如果与 min 一起定义,则将替代 scale 使用。 |
示例
assets/example/shaders/post/chromatic_aberration.json
{
"targets": [
"swap"
],
"passes": [
{
"name": "deconverge",
"intarget": "minecraft:main",
"outtarget": "swap",
"uniforms": [
{
"name": "ConvergeX",
"values": [ 0.0, 0.0, 0.0 ]
},
{
"name": "ConvergeY",
"values": [ 0.0, 0.0, 0.0 ]
},
{
"name": "RadialConvergeX",
"values": [ {"resource": "example:intensity", "min": 0.9, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0} ]
},
{
"name": "RadialConvergeY",
"values": [ {"resource": "example:intensity", "min": 0.9, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0} ]
}
]
},
{
"name": "blit",
"intarget": "swap",
"outtarget": "minecraft:main"
}
]
}
此示例将使 example:intensity 资源力量控制色差着色器的强度。
历史
致谢
- Chris The Big! - 激励我制作这个模组(他在他其中一个数据包中需要此功能)
- Robin - 提供了力量语法的想法
- Overgrown - 提供了加权声音列表的想法(待补充)
- Apoli 模组中的
apoli:replace_loot_table 力量 - 允许我借用其代码
Primary goal of this mod was to implement a better substitute for apugli's custom_footstep power, but I plan to expand with new powers, actions and conditions when I come up with some cool ideas.
I plan to make some of it a part of Apoli for Origins 1.20.1 later on :>
Features
- Power Types
- Replace Sound Emission (
techo:replace_sound_emission)
- Replace Sound Reception (
techo:replace_sound_reception)
- Entity Action Types
- Play Sound (
techo:play_sound) - adds new fields to original apoli:play_sound entity action type.
- A way to pass Resource power values as uniforms to post-processing shaders (via Resource Value Provider data type)
Power Types
Replace Sound Emission
Replaces a sound emissed by power holder with a different sound.
Type ID: techo:replace_sound_emission
Fields
| Field |
Type |
Default |
Description |
sounds |
Object |
|
An object with "key": "value" pairs that determine which sound ("key") will be replaced with a new sound ("value"). The "value" can be either a String, a Weighted Sound or an Array of Weighted Sounds Supports regex matching (with referencing captured groups in replacement) and resourcepack sounds |
replace |
Boolean |
true |
Whether the correctly matched sound should replace the old one, or play along with it. If false, both old and new sound will be played |
entity_action |
Entity Action |
optional |
If specified, this action will be executed on the player upon successfully replacing (or matching) sound |
priority |
Integer |
0 |
Determines the application priority of the power. If several powers match the sound only the highest priority with replace set to true will replace sound and powers with higher priority but with replace set to false will play their sound along |
Examples
{
"type": "techo:replace_sound_emission",
"sounds": {
"minecraft:entity.player.burp": "empty",
"entity.generic.eat": "minecraft:empty"
}
}
This example will replace entity.player.burp and entity.generic.eat sound events with empty, which will mute every eating sound coming from the power holder (minecraft namespace can be omitted).
{
"type": "techo:replace_sound_emission",
"sounds": {
"block.([a-z|0-9|-|_]*).step": "block.$1.break"
},
"condition": {
"type": "apoli:on_block",
"inverted": true,
"block_condition": {
"type": "apoli:and",
"conditions": [
{
"type": "apoli:in_tag",
"tag": "minecraft:wool"
}
]
}
}
}
This example will replace any stepping sound coming from the power holder with a breaking sound used by the same block that was stepped upon (unless that block is a wool).
{
"type": "techo:replace_sound_emission",
"sounds": {
"(.*)": {
"id": "$1",
"pitch": 0.5
}
}
}
This example will make all the sounds emitted by power holder have pitch set to 0.5 making them sound slow and low.
{
"type": "techo:replace_sound_emission",
"sounds": {
"entity.player.(hurt|death)": [
{
"id": "minecraft:entity.axolotl.$1",
"volume": 2,
"pitch": 0.5,
"weight": 1
},
{
"id": "minecraft:entity.wither.$1",
"volume": 2,
"pitch": 0.5,
"weight": 1
}
]
},
"entity_action": {
"type": "apoli:execute_command",
"command": "say bleh XP"
},
"priority": 1
}
This example will replace power holder's death and hurt sounds with the corresponding sound from axolotl or wither (50% chance for either). The result sounds will be slowed 50% ("pitch": 0.5) and will be heard in distance of 32 blocks ("volume": 2, so 2 * 16 = 32 blocks)
History
| Version |
Change |
| 1.0.0 |
Added the power |
| 1.1.0 |
Added new fields: replace, entity_action, priority. Values in sounds now accepts Weighted Sounds |
Replace Sound Reception
Replaces a sound recepted by power holder with a different sound.
Type ID: techo:replace_sound_reception
Fields
| Field |
Type |
Default |
Description |
sounds |
Object |
|
An object with "key": "value" pairs that determine which sound ("key") will be replaced with a new sound ("value"). The "value" can be either a String, a Weighted Sound or an Array of Weighted Sounds Supports regex matching (with referencing captured groups in replacement) and resourcepack sounds |
replace |
Boolean |
true |
Whether the correctly matched sound should replace the old one, or play along with it. If false, both old and new sound will be played |
entity_action |
Entity Action |
optional |
If specified, this action will be executed on the player upon successfully replacing (or matching) sound |
priority |
Integer |
0 |
Determines the application priority of the power. If several powers match the sound only the highest priority with replace set to true will replace sound and powers with higher priority but with replace set to false will play their sound along |
Examples
{
"type": "techo:replace_sound_reception",
"sounds": {
"(?!.*:ui\\.).*": "empty"
}
}
This example will mute everything the power holder hears, except for UI sounds (ex. it won't mute minecraft:ui.button.click)
History
| Version |
Change |
| 1.2.0 |
Added the power |
Entity Actions Types
Play Sound
Plays a sound either at the entity's position or coming from the entity.
Type ID: techo:play_sound
!!! Note
The value of the volume field is used to multiply the base distance of the sound event, which is 16 blocks (1.0).
Fields
| Field |
Type |
Default |
Description |
sound |
Identifier |
|
The ID of the sound to play. |
category |
String |
optional |
If specified, this specifies the category and options the sound falls under. Otherwise, uses the category specified in the entity that invoked this action. Accepts "master", "music", "record", "weather", "block", "hostile", "neutral", "players", "ambient" or "voice". |
volume |
Float |
1.0 |
The volume of the sound. |
pitch |
Float |
1.0 |
The pitch of the sound. |
follow_entity |
Boolean |
false |
Whether the sound should be heard coming from entity's position when it moves. |
global |
Boolean |
value of follow_entity |
Whether all players in the dimension should register this sound as playing even if outside of its range. If false player won't hear it even if they come in the range. Note: This does not make all the players hear the sound just as loud. |
internal |
Boolean |
false |
Whether only the entity that plays this sound should hear it. |
Examples
"entity_action": {
"type": "techo:play_sound",
"sound": "music_disc.pigstep",
"follow_entity": true
}
This example will play the pigstep music disc that will be heard by all players in the dimension it was played if they are close enough to the entity that played this sound.
"entity_action": {
"type": "techo:play_sound",
"sound": "block.end_portal.spawn",
"volume": 1e9001
}
This example will play the sound of creating end portal all around the dimension with all the players hearing it just as loud (1e9001 yields special float value: Infinity).
"entity_action": {
"type": "techo:play_sound",
"sound": "ambient.cave",
"internal": true
}
This example plays cave ambient only for this entity.
History
| Version |
Change |
| 1.0.0 |
Added the action |
| 1.2.0 |
Added new field: internal |
Data Types
Weighted Sound
An Object representing a sound that can have volume and pitch. If in an Array it can also have weight that determines how likely it is to be chosen.
Used in Replace Sound Emission to provide a sound replacement.
Fields
| Field |
Type |
Default |
Description |
id |
Identifier |
|
The ID of the sound to play. Can contain backreferences ($1, $2 etc.) of the regex groups matched |
volume |
Float |
1.0 |
The volume of the sound. |
pitch |
Float |
1.0 |
The pitch of the sound. |
weight |
Positive Integer |
1 |
The weight of the sound. The chance of the sound to be picked is determined by dividing the weight to the sum of all weights (weight / sumOfAllWeights = chance). |
Examples
[
{
"id": "entity.villager.yes",
"weight": 1
},
{
"id": "entity.villager.no",
"weight": 1
}
]
This example will return either entity.villager.yes or entity.villager.no with the same probability for both.
History
| Version |
Change |
| 1.1.0 |
Added the data type |
Resource Value Provider
Provides a scaled value from a Resource power (in order to convert an integer resource value to a fraction float).
Can be passed instead of any float value of a uniform vector/matrix in a post shader
Fields
| Field |
Type |
Default |
Description |
resource |
Identifier |
|
The ID of the resource power from which the uniform value will be set. |
scale |
Float |
0.01 |
Can be defined instead of min and max pair. The value by which the one provided by resource will be multiplied. |
min |
Float |
|
The value to which the min boundary of the resource should be mapped. If defined with max, will be used instead of scale. |
max |
Float |
|
The value to which the max boundary of the resource should be mapped. If defined with min, will be used instead of scale. |
Examples
assets/example/shaders/post/chromatic_aberration.json
{
"targets": [
"swap"
],
"passes": [
{
"name": "deconverge",
"intarget": "minecraft:main",
"outtarget": "swap",
"uniforms": [
{
"name": "ConvergeX",
"values": [ 0.0, 0.0, 0.0 ]
},
{
"name": "ConvergeY",
"values": [ 0.0, 0.0, 0.0 ]
},
{
"name": "RadialConvergeX",
"values": [ {"resource": "example:intensity", "min": 0.9, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0} ]
},
{
"name": "RadialConvergeY",
"values": [ {"resource": "example:intensity", "min": 0.9, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0}, {"resource": "example:intensity", "min": 1.02, "max": 1.0} ]
}
]
},
{
"name": "blit",
"intarget": "swap",
"outtarget": "minecraft:main"
}
]
}
This example will let the example:intensity resource power control the intensity of a Chromatic Aberration shader
History
| Version |
Change |
| 1.2.0 |
Added the data type |
Credits
- Chris The Big! - for inspiring me to do this mod in the first place (he needed this functionality in one of his datapacks)
- Robin - for giving the idea for power's syntax
- Overgrown - for giving the idea for weighted sound list (TBA)
apoli:replace_loot_table power from Apoli mod - for letting me borrow its code
评论 0
登录后参与评分
还没有评论,来抢沙发吧