yoni-mcscripts-lib
Version:
为 Minecraft Script API 中的部分接口创建了 wrapper,并提供简单的事件管理器和任务管理器,另附有一些便于代码编写的一些小工具。
43 lines (42 loc) • 1.21 kB
JavaScript
/**
* 获取所有维度。
*/
export function getAllVanillaDimensions() {
const dimensions = [];
const names = Object.getOwnPropertyNames(Minecraft.MinecraftDimensionTypes);
for (const dimensionEnumName of names) {
const dimensionId = Minecraft.MinecraftDimensionTypes[dimensionEnumName];
const dimension = VanillaWorld.getDimension(dimensionId);
dimensions.push(dimension);
}
return dimensions;
}
import { Minecraft, dim, VanillaWorld } from "./basis.js";
export const DimensionValues = Object.freeze({
"minecraft:nether": dim.nether,
"nether": dim.nether,
"-1": dim.nether,
"minecraft:overworld": dim.overworld,
"overworld": dim.overworld,
"0": dim.overworld,
"minecraft:the_end": dim.theEnd,
"the_end": dim.theEnd,
"the end": dim.theEnd,
"theEnd": dim.theEnd,
"1": dim.theEnd
});
/**
* @param {any} value
* @returns {Minecraft.Dimension}
*/
export function fromValueGetDimension(value) {
if (value instanceof Minecraft.Dimension) {
return value;
}
else if (value in DimensionValues) {
return DimensionValues[value];
}
else {
throw new Error("unknown dimension");
}
}