Zones API
Zones API 是一个轻量级系统,用于在 Minecraft 服务器世界中定义和管理自定义区域(zones)。它提供了创建矩形区域(zones)、检查实体或方块位置是否位于这些区域内,以及通过标识符删除区域的核心方法。
该 API 可作为实现更复杂功能的基础,例如:
- 基于区域的规则(如 PvP 限制、建筑限制、受保护区域)
- 任务区域或自定义交互区域
- 按位置追踪玩家或实体
- 由区域存在触发的自定义游戏逻辑
特性:
- 支持 重叠区域
- 使用两个角点坐标(
BlockPos)简单创建区域
- 通过唯一的
Identifier 对象进行区域标识
- 支持基于 位置 或 实体 的成员资格检查
Zones API 本身不实现高级行为 —— 它旨在被集成到更大的系统中或根据需要进行扩展。它提供了其他功能可以构建的基本空间逻辑。
API 参考
package com.yeekworld.zones.api.ZonesAPI
通过 JitPack 添加依赖: (请使用 modImplementation 替代 implementation)
isInZone(ServerWorld world, BlockPos pos, Identifier zoneId)
检查特定的方块位置是否位于给定区域内。
| 参数 |
类型 |
描述 |
world |
ServerWorld |
执行检查的世界。 |
pos |
BlockPos |
需要检查的位置。 |
zoneId |
Identifier |
区域的唯一标识符。 |
| 返回类型 |
描述 |
boolean |
如果位置在区域内则返回 true,否则返回 false。 |
isInZone(Entity entity, Identifier zoneId)
检查实体是否位于特定区域内。
| 参数 |
类型 |
描述 |
entity |
Entity |
需要检查的实体。 |
zoneId |
Identifier |
目标区域的标识符。 |
| 返回类型 |
描述 |
boolean |
如果实体在区域内则返回 true,否则返回 false。 |
getZoneWhereIn(ServerWorld world, BlockPos pos)
获取给定方块位置所属的所有区域标识符列表。
| 参数 |
类型 |
描述 |
world |
ServerWorld |
位置所在的世界。 |
pos |
BlockPos |
需要检查的位置。 |
| 返回类型 |
描述 |
List<Identifier> |
包含该位置的所有区域列表。若无则返回空列表。 |
getZoneWhereIn(Entity entity)
获取实体当前所在的所有区域标识符列表。
| 参数 |
类型 |
描述 |
entity |
Entity |
需要检查的实体。 |
| 返回类型 |
描述 |
List<Identifier> |
包含该实体的所有区域列表。若无则返回空列表。 |
createZone(String zoneName, BlockPos pos1, BlockPos pos2, ServerWorld world)
创建一个由两个对角定义的矩形区域。
| 参数 |
类型 |
描述 |
zoneName |
String |
区域名称(用于生成 ID)。 |
pos1 |
BlockPos |
区域的一个角点。 |
pos2 |
BlockPos |
区域的对角点。 |
world |
ServerWorld |
创建区域的世界。 |
| 返回类型 |
描述 |
Identifier |
新区域的标识符。 |
removeZone(Identifier zoneId)
移除具有给定标识符的区域。
| 参数 |
类型 |
描述 |
zoneId |
Identifier |
要移除的区域 ID。 |
ℹ️ 注意事项
- 区域可以重叠;一个实体或位置可能属于多个区域。
- 区域边界是包含在内的(inclusive)。
- 标识符(
Identifier)应当在全局范围内唯一。
Zones API
Zones API is a lightweight system for defining and managing custom zones in a Minecraft server world. It provides core methods for creating rectangular areas (zones), checking whether entities or block positions are inside those zones, and removing zones by their identifiers.
This API serves as a foundation for implementing more complex features such as:
- Region-based rules (e.g., PvP restrictions, building limits, protected areas)
- Quest areas or custom interaction zones
- Player or entity tracking by location
- Custom game logic triggered by zone presence
Features:
- Supports overlapping zones
- Simple zone creation using two corner points (
BlockPos)
- Zone identification via unique
Identifier objects
- Membership checks based on either position or entity
Zones API does not implement high-level behaviors on its own — instead, it is intended to be integrated into larger systems or extended as needed. It provides the basic spatial logic upon which other features can be built.
API Reference
package com.yeekworld.zones.api.ZonesAPI
Add dependency via JitPack: (use modImplementation instead of implementation)
isInZone(ServerWorld world, BlockPos pos, Identifier zoneId)
Checks whether a specific block position is within a given zone.
| Parameter |
Type |
Description |
world |
ServerWorld |
The world in which the check is performed. |
pos |
BlockPos |
The position to check. |
zoneId |
Identifier |
The unique identifier of the zone. |
| Returns |
Description |
boolean |
true if the position is inside the zone, otherwise false. |
isInZone(Entity entity, Identifier zoneId)
Checks whether an entity is inside a specific zone.
| Parameter |
Type |
Description |
entity |
Entity |
The entity to check. |
zoneId |
Identifier |
The identifier of the target zone. |
| Returns |
Description |
boolean |
true if the entity is inside the zone, otherwise false. |
getZoneWhereIn(ServerWorld world, BlockPos pos)
Gets a list of zone identifiers that the given block position belongs to.
| Parameter |
Type |
Description |
world |
ServerWorld |
The world of the position. |
pos |
BlockPos |
The position to check. |
| Returns |
Description |
List<Identifier> |
List of all zones containing the position. Empty if none. |
getZoneWhereIn(Entity entity)
Gets a list of zone identifiers that the entity is currently inside.
| Parameter |
Type |
Description |
entity |
Entity |
The entity to check. |
| Returns |
Description |
List<Identifier> |
List of all zones containing the entity. Empty if none. |
createZone(String zoneName, BlockPos pos1, BlockPos pos2, ServerWorld world)
Creates a rectangular zone defined by two opposite corners.
| Parameter |
Type |
Description |
zoneName |
String |
The name of the zone (used in the ID). |
pos1 |
BlockPos |
One corner of the zone. |
pos2 |
BlockPos |
Opposite corner of the zone. |
world |
ServerWorld |
The world where the zone is created. |
| Returns |
Description |
Identifier |
The identifier of the new zone. |
removeZone(Identifier zoneId)
Removes the zone with the given identifier.
| Parameter |
Type |
Description |
zoneId |
Identifier |
The ID of the zone to remove. |
| Returns |
Description |
void |
No return value. |
ℹ️ Notes
- Zones can overlap; an entity or position may belong to multiple zones.
- Zone boundaries are inclusive.
- Identifiers (
Identifier) should be globally unique.
评论 0
登录后参与评分
还没有评论,来抢沙发吧