Front Rotation Tool(前面旋转工具)
基本信息
| 属性 | 值 |
|---|---|
| 注册名 | structurelib:item.structurelib.frontRotationTool |
| 物品类 | com.gtnewhorizon.structurelib.item.ItemFrontRotationTool |
| 显示名 | Front Rotation Tool (Standalone) |
| 未本地化名称 | item.structurelib.frontRotationTool |
| 最大堆叠 | 1(setMaxStackSize(1)) |
| 创意模式标签 | StructureLib |
注册调用为 GameRegistry.registerItem(itemFrontRotationTool = new ItemFrontRotationTool(), itemFrontRotationTool.getUnlocalizedName()),与 Constructable Trigger 相同,注册名中会重复一次 item. 前缀。
功能
Front Rotation Tool 用于旋转多方块结构件的朝向。它不修改方块本身的 metadata,而是改变目标方块实体所实现的 IAlignment 中的 ExtendedFacing(方向 + 旋转 + 翻转三元组)。
使用方式
唯一的交互入口是 onItemUseFirst,调用 AlignmentUtility.handle(player, world, x, y, z):
| 条件 | 行为 |
|---|---|
目标位置没有方块实体,或玩家是 FakePlayer |
直接返回 player instanceof EntityPlayerMP,不改动任何状态 |
目标是服务端玩家且方块实体实现 IAlignmentProvider |
按潜行状态分别调整朝向,详见下表 |
| 其他情况 | 返回 false,无效果 |
AlignmentUtility.handle 的潜行分支是本物品的核心语义:
| 玩家状态 | 调用 | 效果 |
|---|---|---|
| 不潜行 | alignment.toolSetRotation(null) |
依次尝试下一个 Rotation 状态,跳过被 IAlignmentLimits 禁止的组合 |
| 潜行 | alignment.toolSetFlip(null) |
依次尝试下一个 Flip 状态,同样跳过被禁止的组合 |
传入 null 时,遍历是循环递增的:旋转在 4 个值中轮转,翻转也在 4 个值中轮转;一旦某个新状态通过 checkedSetRotation/checkedSetFlip 的合法性检查就立即停下并返回 true。因此连续使用同一工具会持续绕圈,直到转到该方块允许的下一个状态为止。全部尝试失败则返回 false。
悬浮提示(仅客户端)
addInformation 标注了 @SideOnly(Side.CLIENT),依次显示三行:
Triggers Front Rotation Interface(无颜色修饰)Rotates only the front panel,(蓝色)which allows structure rotation.(蓝色)