92 lines
2.6 KiB
JavaScript
92 lines
2.6 KiB
JavaScript
var portalColor;
|
|
|
|
ServerEvents.highPriorityData((event) => {
|
|
if (config.dimensions) {
|
|
config.dimensions.forEach((dimension) => {
|
|
const [modId, dimId] = dimension.id.split(":");
|
|
|
|
// Add dimension
|
|
/** @type {any} */
|
|
const dimJson = { type: "minecraft:overworld" };
|
|
if (dimension.worldgen)
|
|
dimJson["generator"] = {
|
|
type: "minecraft:flat",
|
|
settings: {
|
|
biome: "minecraft:plains",
|
|
lakes: false,
|
|
features: false,
|
|
structures: {},
|
|
layers: Object.entries(dimension.worldgen).map(
|
|
([block, count]) => ({
|
|
block: block,
|
|
height: count,
|
|
}),
|
|
),
|
|
},
|
|
};
|
|
event.addJson(`${modId}:dimension/${dimId}.json`, dimJson);
|
|
|
|
// Add portal
|
|
const portal = dimension.portal;
|
|
if (portal) {
|
|
portalColor = hexToRgb(portal.color);
|
|
event.addJson(
|
|
`${modId}:portals/${dimId}.json`,
|
|
/** @type {any} */ ({
|
|
block: portal.material,
|
|
dim: dimension.id,
|
|
r: portalColor.r,
|
|
g: portalColor.g,
|
|
b: portalColor.b,
|
|
ignitionType: "FLUID",
|
|
ignitionSource: portal.fluid,
|
|
}),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// Setup Dimensional Inventories
|
|
PlayerEvents.loggedIn((event) => {
|
|
if (config.dimensions) {
|
|
config.dimensions.forEach((dimension) => {
|
|
const [modId, dimId] = dimension.id.split(":");
|
|
const data = event.server.persistentData;
|
|
if (!data.getBoolean(`${dimId}Initialized`)) {
|
|
data.putBoolean(`${dimId}Initialized`, true);
|
|
event.server.scheduleInTicks(
|
|
20,
|
|
/** @type {any} */ (
|
|
() => {
|
|
event.server.runCommandSilent(`diminv pool ${dimId} create`);
|
|
event.server.runCommandSilent(
|
|
`diminv pool ${dimId} dimension ${dimension.id} assign`,
|
|
);
|
|
event.server.runCommandSilent(
|
|
`diminv pool ${dimId} gameMode ${dimension.gamemode}`,
|
|
);
|
|
event.server.runCommandSilent(
|
|
`diminv pool ${dimId} progressAdvancements false`,
|
|
);
|
|
event.server.runCommandSilent(
|
|
`diminv pool ${dimId} incrementStatistics false`,
|
|
);
|
|
}
|
|
),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// Disable entity spawning
|
|
EntityEvents.checkSpawn((event) => {
|
|
if (!event.level) return;
|
|
|
|
config.dimensions.forEach((dimension) => {
|
|
if (event.level.dimension.toString() === dimension.id) {
|
|
event.cancel();
|
|
}
|
|
});
|
|
});
|