自定义传送门
为你的整合包添加自定义传送门方块:每个方块都会将你传送到你指定的维度(例如自定义维度、下界、末地),且 x、y、z 坐标保持不变。
给整合包制作者: 使用 JSON 定义传送门(id、目的地、可选的基础/胶囊方块、音效、可用维度、默认返回)。文件需放入可配置的目录中——默认为游戏目录下的 kubejs/external_scripts/simp_cm_portal_portals/。该路径可在模组配置中更改。游戏加载时,模组还会在该文件夹中生成一份 PORTALS.md 文件,内容与下方的文档相同。无需 KubeJS;该路径名仅为默认值。
功能: 目的地可选的安全区建造、通过 usableIn 实现单向传送、支持 /simp_cm_portal_reload 命令以在不重启游戏的情况下实时重载配置。
本页其余内容为完整文档(与自动生成的 PORTALS.md 相同,该文件会创建在你放置传送门 JSON 脚本的同一文件夹中)。
配置路径
传送门定义从以下位置的 JSON 文件中加载:<game dir>/<externalScriptsPath>/simp_cm_portal_portals/。
externalScriptsPath 在模组配置中设置(默认为 kubejs/external_scripts)。仅读取 .json 文件。
JSON 格式
每个 JSON 文件可包含一个或多个传送门定义。根结构如下:
- type(必填):
"simp_cm_portal:portals" 或 "iska_utils:portals"。
- overwritable(可选):当前未使用。
- portals(必填):传送门对象数组。每项必须具有唯一的 id。
传送门对象
- id(必填):唯一标识符(例如
"custom_dimensions-portal_void")。用于方块注册表;仅在游戏启动时加载的传送门会生成对应的方块。重新加载后,仅更新已有 id 的逻辑。
- destination(必填):传送门将玩家送达的目标维度资源键(例如
"minecraft:overworld"、"custom_dimensions:void")。
- baseBlock(可选):安全区胶囊底部地板的方块 id(例如
"minecraft:stone")。若为空,则不替换地板。
- capsuleBlock(可选):胶囊墙壁和天花板的方块 id(例如
"minecraft:glass")。若为空,则不建造墙壁/天花板。
- box(可选):以方块中心为基准的可变尺寸盒体碰撞箱(及视觉边界)。格式为
"width height depth",数值为 0 到 1 之间的分数,用空格或逗号分隔。示例:"1 1 1" 或省略 = 完整方块;"0.5 1 0.5" = 宽度与深度减半,高度完整;"0.5" = 0.5×0.5×0.5 的立方体。无效或为空值 = 完整方块。
- usableIn(可选):维度键数组。若非空,则玩家必须处于这些维度之一时才能使用该传送门。可用于单向传送门(例如仅设置
["minecraft:overworld"],使得目标维度中的返回传送门失效)。
- defaultReturn(可选):当玩家已在 destination 维度中且使用了一个未存储返回目标的传送门时,将被传送到此维度。若为空,则从目标维度使用该传送门无任何效果。
- sound(可选):传送门方块的音效类型(放置、破坏、行走)。默认为
glass。详见下方的“支持的音效”。示例:"rock"。
支持的音效
sound 的有效值(若省略或未知,默认值为 glass)。示例:rock、glass、wood —— 完整列表请参阅与脚本同一文件夹下生成的 PORTALS.md 文件。
JSON 支持 // 和 /* */ 注释;解析前会被移除。
示例
最小配置(双向,无安全区样式美化):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "my_portal_void",
"destination": "custom_dimensions:void"
}
]
}
带安全区、默认返回目标和自定义音效的双向传送门(例如 主世界 ↔ 虚空):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "portal_void",
"destination": "custom_dimensions:void",
"baseBlock": "minecraft:stone",
"capsuleBlock": "minecraft:glass",
"sound": "rock",
"usableIn": [],
"defaultReturn": "minecraft:overworld"
}
]
}
单向传送门(仅能从主世界前往虚空;返回传送门无效):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "one_way_void",
"destination": "custom_dimensions:void",
"baseBlock": "minecraft:stone",
"capsuleBlock": "minecraft:glass",
"usableIn": ["minecraft:overworld"],
"defaultReturn": ""
}
]
}
自定义碰撞箱(细柱形,宽高减半、高度不变):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "slim_portal",
"destination": "minecraft:the_nether",
"box": "0.5 1 0.5"
}
]
}
其他 box 示例:"1 1 1" 表示完整方块;"0.5" 表示小型居中立方体。
单个文件中包含多个传送门:
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "portal_overworld",
"destination": "minecraft:overworld",
"baseBlock": "minecraft:grass_block",
"capsuleBlock": "minecraft:oak_planks",
"defaultReturn": "custom_dimensions:void"
},
{
"id": "portal_void",
"destination": "custom_dimensions:void",
"baseBlock": "minecraft:stone",
"capsuleBlock": "minecraft:glass",
"usableIn": ["minecraft:overworld"],
"defaultReturn": "minecraft:overworld"
}
]
}
行为
- 点击: 右键点击传送门方块以进行传送。目标维度为:该方块存储的返回维度(如果有的话),否则若已在目的地维度内,则使用 defaultReturn,否则使用 destination。
- 相同坐标: 目的地传送门(或胶囊)将创建在你点击的传送门的相同 x、y、z 坐标处。
- 返回传送门: 当模组在目的地构建胶囊时,它会放置一个同类型的传送门方块,并存储返回维度(即你来自哪里)。该方块随后始终会将你送回原处。
- 仅在需要时构建胶囊: 如果在目的地维度的同一位置,或在 32 格半径内已存在具有相同返回维度的传送门,玩家将被传送至该处,且不会构建新胶囊。
- 安全区: 构建完成后,胶囊内部空间为 3×3×4,包含地板(baseBlock)、墙壁和天花板(capsuleBlock),以及位于中心的返回传送门。
构建前的验证
在构建胶囊之前,模组会检查该区域内是否存在以下情况:
- 拥有原版标签
minecraft:features_cannot_replace 的方块
- 基岩方块
- 爆炸抗性 ≥ 3,600,000(不可破坏)
如果上述任一条件不满足,玩家会收到操作栏提示(例如“传送门位置无效”),并且不会执行构建或传送。
命令
- /simp_cm_portal_reload(权限等级 2):从 portals 文件夹中的所有 JSON 文件重新加载传送门定义(与放置脚本的路径相同),并刷新目的地映射。仅更新逻辑;JSON 中新增的 ID 在游戏重启前不会生成对应的方块。
从 JSON 中移除的传送门
如果世界中仍存在某个传送门方块,但其 id 已从所有 JSON 文件中移除(例如重载后),则该方块不会生效也不会导致崩溃:点击时将返回 PASS。游戏重启后,根据注册情况,该类型的方块可能不再存在。
Simple Custom Portal
Add custom portal blocks to your pack: each block teleports to a dimension you choose (e.g. custom dimensions, Nether, End) at the same x, y, z.
For pack creators: define portals in JSON (id, destination, optional base/capsule blocks, sound, usable dimensions, default return). Files go in a configurable directory — default: kubejs/external_scripts/simp_cm_portal_portals/ under the game directory. The path can be changed in the mod config. When the game loads, the mod also writes a PORTALS.md in that folder with the same documentation below. No KubeJS required; the path name is just the default.
Features: optional safe-zone building at destination, one-way portals via usableIn, /simp_cm_portal_reload for live reload without restart.
The rest of this page is the full documentation (same as the auto-generated PORTALS.md, which is created in the same folder where you put the portal JSON scripts).
Config path
Portal definitions are loaded from JSON files in: <game dir>/<externalScriptsPath>/simp_cm_portal_portals/.
externalScriptsPath is set in mod config (default: kubejs/external_scripts). Only .json files are read.
JSON format
Each JSON file can contain one or more portal definitions. Root structure:
- type (required):
"simp_cm_portal:portals" or "iska_utils:portals".
- overwritable (optional): currently unused.
- portals (required): array of portal objects. Each entry must have a unique id.
Portal object
- id (required): unique identifier (e.g.
"custom_dimensions-portal_void"). Used for the block registry; only portals loaded at game startup get a block. After a reload, only the logic of existing ids is updated.
- destination (required): dimension resource key the portal sends to (e.g.
"minecraft:overworld", "custom_dimensions:void").
- baseBlock (optional): block id for the floor of the safe-zone capsule (e.g.
"minecraft:stone"). If empty, floor is not replaced.
- capsuleBlock (optional): block id for walls and ceiling of the capsule (e.g.
"minecraft:glass"). If empty, walls/ceiling are not built.
- box (optional): hitbox (collision and visual) as a variable-size box centered in the block. Format:
"width height depth" as fractions from 0 to 1, space or comma separated. Example: "1 1 1" or omit = full block; "0.5 1 0.5" = half width and depth, full height; "0.5" = cube 0.5×0.5×0.5. Invalid or empty = full block.
- usableIn (optional): array of dimension keys. If non-empty, the portal can only be used when the player is in one of these dimensions. Use for one-way portals (e.g. only
["minecraft:overworld"] so the return portal in the destination does not work).
- defaultReturn (optional): when the player is already in destination and uses a portal without a stored return, they are sent to this dimension. If empty, using the portal from the destination does nothing.
- sound (optional): block sound type for the portal block (place, break, step). Default is
glass. See "Supported sounds" below. Example: "rock".
Supported sounds
Valid values for sound (default if omitted or unknown: glass). Examples: rock, glass, wood — full list in the PORTALS.md generated in the same folder as the scripts.
JSON can contain // and /* */ comments; they are stripped before parsing.
Examples
Minimal (two-way, no safe-zone styling):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "my_portal_void",
"destination": "custom_dimensions:void"
}
]
}
Two-way with safe-zone, default return and custom sound (e.g. overworld ↔ void):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "portal_void",
"destination": "custom_dimensions:void",
"baseBlock": "minecraft:stone",
"capsuleBlock": "minecraft:glass",
"sound": "rock",
"usableIn": [],
"defaultReturn": "minecraft:overworld"
}
]
}
One-way (only from overworld to void; return portal does not work):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "one_way_void",
"destination": "custom_dimensions:void",
"baseBlock": "minecraft:stone",
"capsuleBlock": "minecraft:glass",
"usableIn": ["minecraft:overworld"],
"defaultReturn": ""
}
]
}
Custom hitbox (thin pillar, half width/depth, full height):
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "slim_portal",
"destination": "minecraft:the_nether",
"box": "0.5 1 0.5"
}
]
}
Other box examples: "1 1 1" full block; "0.5" small centered cube.
Multiple portals in one file:
{
"type": "simp_cm_portal:portals",
"portals": [
{
"id": "portal_overworld",
"destination": "minecraft:overworld",
"baseBlock": "minecraft:grass_block",
"capsuleBlock": "minecraft:oak_planks",
"defaultReturn": "custom_dimensions:void"
},
{
"id": "portal_void",
"destination": "custom_dimensions:void",
"baseBlock": "minecraft:stone",
"capsuleBlock": "minecraft:glass",
"usableIn": ["minecraft:overworld"],
"defaultReturn": "minecraft:overworld"
}
]
}
Behaviour
- Click: right-click on a portal block to teleport. The target dimension is: the block’s stored return dimension if it has one, otherwise defaultReturn when already in destination, otherwise destination.
- Same coordinates: the destination portal (or capsule) is created at the same x, y, z as the portal you clicked.
- Return portal: when the mod builds a capsule in the destination, it places a portal block of the same type with a stored return dimension (where you came from). That block then always sends you back.
- Capsule only if needed: if in the destination dimension there is already a portal at the same position or with the same return dimension in a 32-block radius, the player is teleported there and no capsule is built.
- Safe zone: when built, the capsule has interior 3×3×4, with floor (baseBlock), walls and ceiling (capsuleBlock), and the return portal at the centre.
Validation before building
Before building the capsule, the mod checks that no block in the zone has:
- the vanilla tag
minecraft:features_cannot_replace
- the block is bedrock
- explosion resistance ≥ 3,600,000 (indestructible)
If any of these fail, the player gets an action-bar message (e.g. "Invalid position for portal") and no build/teleport happens.
Command
- /simp_cm_portal_reload (permission level 2): reloads portal definitions from all JSON files in the portals folder (same path where you put the scripts) and refreshes the destination map. Only logic is updated; new ids in JSON do not get new blocks until the game is restarted.
Portals removed from JSON
If a portal block still exists in the world but its id was removed from every JSON (e.g. after a reload), the block does nothing and does not crash: click returns PASS. After a game restart, that block type may no longer exist depending on registration.
评论 0
登录后参与评分
还没有评论,来抢沙发吧