Plot
基本信息
| 属性 | 值 |
|---|---|
| 类名 | mytown.entities.Plot |
| 文件 | src/main/java/mytown/entities/Plot.java |
| 行数 | 353 |
| 实现 | IChatFormat |
| 启用版本 | Minecraft 1.7.10 |
功能
地块 —— 城镇内部可独立转让、独立设 flag 的长方体区域。
一个 Plot 属于某个 Town,有自己的成员与所有者。
⚠️ 重要澄清:Plot 不是多方块
本 mod 没有任何多方块结构(multiblock)。
Plot 是一个纯粹的长方体领地声明,用两个对角点描述:
| 字段 | 说明 |
|---|---|
dim |
世界维度 ID(int) |
x1, y1, z1 |
角点 1 |
x2, y2, z2 |
角点 2 |
toVolume() 把这 6 个坐标 + 维度转成 Volume 供保护判定使用。
⚠️ 不存在控制器方块、不存在结构模板、不存在「可否旋转 / 可否拆除」等 多方块字段。把 Plot 描述成多方块结构(本仓库最常见的编造点)会完全跑偏。
字段
| 字段 | 类型 | 说明 |
|---|---|---|
dbID |
int |
数据库主键 |
dim, x1, y1, z1, x2, y2, z2 |
final int |
全部不可变 |
town |
Town |
所属城镇 |
key, name |
String |
内部键 / 展示名 |
flagsContainer |
final Flag.Container |
地块 flag |
membersContainer |
final Resident.Container |
成员 |
ownersContainer |
final Resident.Container |
所有者 |
坐标自动归一化
构造器 Plot(String name, Town town, int dim, int x1, int y1, int z1, int x2, int y2, int z2)
对三轴分别做交换,保证 x1 <= x2、z1 <= z2、y1 <= y2:
if (x1 > x2) { int aux = x2; x2 = x1; x1 = aux; }
// z1 > z2 同理;y1 > y2 同理
⚠️ 因此传入的角点顺序无所谓,不需要调用方自行排序。
源码注释 // Second parameter is always highest 描述的正是这一行为。
⚠️ 归一化只处理三轴,dim 不参与交换(维度 ID 只有一个值,本无成对概念)。
Plot.Container
extends ArrayList<Plot>,实现 IChatFormat,提供 4 个重载 get:
| 重载 | 用途 |
|---|---|
get(String name) |
按名取 |
get(int dim, int x, int y, int z) |
按坐标取 |
get(Resident res) |
按居民取其 Plot |
get(int plotID) |
按数据库 ID 取 |
另有 getPlotsOwned(Resident) 返回 List<Plot>,以及 toChatMessage()。
⚠️ get(int, int, int, int) 与 get(int) 重载并存,
单参数版取的是 plotID 而非坐标,容易误用。
相关条目
- Town -
plotsContainer宿主,容量受defaultMaxPlots限制 - Config -
minPlotsArea/maxPlotsArea/enablePlots等 6 项地块配置 - PlotSelectionTool - 圈选地块
- ProtectionManager -
Volume判定