@occultus/toolkit 0.22.3 → 0.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/entity/entityUtils.ts +2 -1
- package/src/identifier/namespace.ts +24 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "@minecraft/server";
|
|
12
12
|
import { EffectData, effectGroupMap, EffectGroups } from "@occultus/common";
|
|
13
13
|
import { OccultusSDKError } from "@occultus/core";
|
|
14
|
+
import { ensureNoNamespace } from "../identifier/namespace";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* 尝试对实体进行操作
|
|
@@ -189,7 +190,7 @@ export function addEffect(
|
|
|
189
190
|
for (const effect of effects) {
|
|
190
191
|
if (duration === "infinite") {
|
|
191
192
|
entity.runCommand(
|
|
192
|
-
`effect @s ${effect} infinite ${options?.amplifier ?? 0} ${options?.showParticles ?? false}`
|
|
193
|
+
`effect @s ${ensureNoNamespace(effect)} infinite ${options?.amplifier ?? 0} ${options?.showParticles ?? false}`
|
|
193
194
|
);
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 确保命名空间存在,若不存在则自动加上`minecraft:`命名空间
|
|
4
|
+
* @param identifier 要检查的标识符
|
|
5
|
+
* @return 存在命名空间的标识符
|
|
6
|
+
*/
|
|
7
|
+
export function ensureNamespace(identifier: string): string {
|
|
8
|
+
if (identifier.includes(":")) {
|
|
9
|
+
return identifier;
|
|
10
|
+
}
|
|
11
|
+
return `minecraft:${identifier}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 确保命名空间**不**存在,若存在则自动去掉命名空间
|
|
16
|
+
* @param identifier 要检查的标识符
|
|
17
|
+
* @return 不存在命名空间的标识符
|
|
18
|
+
*/
|
|
19
|
+
export function ensureNoNamespace(identifier: string): string {
|
|
20
|
+
if (identifier.includes(":")) {
|
|
21
|
+
return identifier.split(":")[1];
|
|
22
|
+
}
|
|
23
|
+
return identifier;
|
|
24
|
+
}
|
package/src/index.ts
CHANGED