ConditionalBarriers
ConditionalBarriers 是一款用于 Minecraft 的 Fabric 模组,允许玩家根据可配置规则或通过 API 接入的外部条件穿透屏障方块。
默认情况下,所有玩家都无法通过屏障方块。本模组改变了这一设定,提供了精细的控制权限,决定谁能穿过这些方块,非常适合地图制作者、服务器管理员和开发者使用。
功能特性
- 可配置的通行规则: 使用多种标准(游戏模式、权限等级、玩家名称、UUID、记分板标签)定义谁可以穿过屏障。
- 开发者 API: 轻松注册自定义条件,以便从其他模组控制屏障的可访问性。
- 游戏内命令: 无需重启服务器即可管理模组状态并重新加载配置。
- 防止窒息: 如果允许玩家穿过屏障,模组会自动防止玩家在屏障内部窒息。
- 高性能: 采用优化的 Mixins 实现,确保对服务器性能的影响降至最低。
命令
该模组提供以下命令(需要 2 级或更高权限):
/conditionalbarriers on:启用规则评估。
/conditionalbarriers off:禁用模组的逻辑(使所有屏障对所有人变得可穿透)。
/conditionalbarriers status:显示模组当前是否处于活动状态。
/conditionalbarriers reload:从磁盘重新加载配置文件。
/cb:/conditionalbarriers 的简短别名。
配置
配置文件位于 config/conditionalbarriers.json。它允许你定义一系列按顺序执行的规则。
示例配置
{
"defaultPassable": false,
"rules": [
{
"type": "SPECTATOR",
"action": "ALLOW"
},
{
"type": "CREATIVE",
"action": "ALLOW"
},
{
"type": "SCOREBOARD_TAG",
"action": "ALLOW",
"value": "can_pass_barriers"
},
{
"type": "OPERATOR_LEVEL",
"action": "ALLOW",
"operatorLevel": 4
}
]
}
规则类型
CREATIVE:匹配处于创造模式的玩家。
SPECTATOR:匹配处于旁观者模式的玩家。
OPERATOR_LEVEL:匹配具有特定权限等级的玩家。
PLAYER_NAME:匹配特定的玩家名称(支持区分大小写选项)。
PLAYER_UUID:匹配特定的玩家 UUID。
SCOREBOARD_TAG:匹配具有特定记分板标签的玩家。
安装与要求
ConditionalBarriers 必须在客户端和服务端均安装才能正常工作。这是因为客户端的物理引擎需要知道何时将屏障方块视为非实体,以实现平滑移动。
- 确保你在两端都安装了 Fabric Loader。
- 将
ConditionalBarriers JAR 文件放入客户端和服务端的 mods 文件夹中。
- (可选)如果尚未安装,请安装 Fabric API。
开发者 API
如果你是模组开发者,可以使用 ConditionalBarriersApi 添加你自己的逻辑。
将 API 添加到你的项目中
要在自己的模组中使用 ConditionalBarriers API,你可以将其作为依赖项添加到 Modrinth 或你偏好的 Maven 仓库中。
Gradle (Modrinth)
- 将 Modrinth 仓库添加到你的
build.gradle:
repositories {
maven {
name = "Modrinth"
url = uri("https://api.modrinth.com/maven")
}
}
- 添加依赖项:
dependencies {
modImplementation "maven.modrinth:conditional-barriers:<VERSION>"
}
注意:请将 <VERSION> 替换为你想要使用的实际版本号。
fabric.mod.json
在 depends 部分添加该模组,以确保其在运行时存在:
"depends": {
"conditionalbarriers": ">=1.0.0"
}
注册自定义条件
ConditionalBarriersApi.registerCondition(new Identifier("mymod", "special_access"), context -> {
if (someCustomLogic(context.player())) {
return BarrierDecision.ALLOW; // 允许通过
}
return BarrierDecision.PASS; // 让其他规则决定
});
手动覆盖
你也可以强制特定玩家无论其他规则如何都能通过(或被阻挡):
ConditionalBarriersApi.setPlayerOverride(player, PlayerBarrierOverride.ALLOW);
安装与要求
- 确保你已安装 Fabric Loader。
- 将
ConditionalBarriers JAR 文件放入你的 mods 文件夹中。
- (可选)如果尚未安装,请安装 Fabric API。
许可证
本项目遵循 LICENSE.txt 文件中规定的条款进行许可。
ConditionalBarriers
ConditionalBarriers is a Fabric mod for Minecraft that allows players to pass through barrier blocks based on configurable rules or external conditions via an API.
By default, barrier blocks are impassable for everyone. This mod changes that by allowing fine-grained control over who can walk through them, making it ideal for map makers, server administrators, and developers.
Features
- Configurable Pass Rules: Define who can pass through barriers using various criteria (Game Mode, Permission Level, Player Name, UUID, Scoreboard Tags).
- Developer API: Easily register custom conditions to control barrier accessibility from other mods.
- In-game Commands: Manage the mod's state and reload configuration without restarting the server.
- No More Suffocation: Automatically prevents players from suffocating inside barriers if they are allowed to pass through them.
- High Performance: Implemented using optimized Mixins to ensure minimal impact on server performance.
Commands
The mod provides the following commands (requires permission level 2 or higher):
/conditionalbarriers on: Enables rule evaluation.
/conditionalbarriers off: Disables the mod's logic (making all barriers passable for everyone).
/conditionalbarriers status: Displays whether the mod is currently active.
/conditionalbarriers reload: Reloads the configuration from the disk.
/cb: A shorter alias for /conditionalbarriers.
Configuration
The configuration file is located at config/conditionalbarriers.json. It allows you to define a list of rules that are evaluated in order.
Example Configuration
{
"defaultPassable": false,
"rules": [
{
"type": "SPECTATOR",
"action": "ALLOW"
},
{
"type": "CREATIVE",
"action": "ALLOW"
},
{
"type": "SCOREBOARD_TAG",
"action": "ALLOW",
"value": "can_pass_barriers"
},
{
"type": "OPERATOR_LEVEL",
"action": "ALLOW",
"operatorLevel": 4
}
]
}
Rule Types
CREATIVE: Matches players in Creative mode.
SPECTATOR: Matches players in Spectator mode.
OPERATOR_LEVEL: Matches players with a specific permission level.
PLAYER_NAME: Matches a specific player name (case-sensitive option available).
PLAYER_UUID: Matches a specific player UUID.
SCOREBOARD_TAG: Matches players with a specific scoreboard tag.
Installation & Requirements
ConditionalBarriers is required on both the client and the server to function correctly. This is because the client's physics engine needs to know when a barrier block should be non-solid to allow for smooth movement.
- Make sure you have the Fabric Loader installed on both sides.
- Drop the
ConditionalBarriers JAR file into the mods folder of both your client and server.
- (Optional) Install Fabric API if not already present.
Developer API
If you are a mod developer, you can use the ConditionalBarriersApi to add your own logic.
Adding the API to your project
To use the ConditionalBarriers API in your own mod, you can add it as a dependency using Modrinth or your preferred Maven repository.
Gradle (Modrinth)
- Add the Modrinth repository to your
build.gradle:
repositories {
maven {
name = "Modrinth"
url = uri("https://api.modrinth.com/maven")
}
}
- Add the dependency:
dependencies {
modImplementation "maven.modrinth:conditional-barriers:<VERSION>"
}
Note: Replace <VERSION> with the actual version you want to use.
fabric.mod.json
Add the mod to your depends section to ensure it's present at runtime:
"depends": {
"conditionalbarriers": ">=1.0.0"
}
Registering a Custom Condition
ConditionalBarriersApi.registerCondition(new Identifier("mymod", "special_access"), context -> {
if (someCustomLogic(context.player())) {
return BarrierDecision.ALLOW; // Let them pass
}
return BarrierDecision.PASS; // Let other rules decide
});
Manual Overrides
You can also force a specific player to be able to pass (or be blocked) regardless of other rules:
ConditionalBarriersApi.setPlayerOverride(player, PlayerBarrierOverride.ALLOW);
Installation & Requirements
- Make sure you have the Fabric Loader installed.
- Drop the
ConditionalBarriers JAR file into your mods folder.
- (Optional) Install Fabric API if not already present.
License
This project is licensed under the terms specified in the LICENSE.txt file.
评论 0
登录后参与评分
还没有评论,来抢沙发吧