旋转(Rotate Grid)

基本信息

属性 值
键位 ID key.craftingtweaks.rotate
默认按键 Keyboard.KEY_NONE(未绑定,需玩家自行在「选项 → 控制」中设置)
分类 key.categories.craftingtweaks(英文 “Gregory Tweaks For Crafting” / 中文「合成辅助」)
注册位置 ClientProxy.init() → ClientRegistry.registerKeyBinding
触发方式 TickEvent.ClientTickEvent 边沿触发

英文显示名 Rotate Grid,中文「旋转」。

触发条件

必须同时满足(ClientProxy.onClientTick):

  1. 客户端已连接且有玩家实体(FMLClientHandler.getClientPlayerEntity() != null)
  2. entityPlayer.openContainer != null
  3. CraftingTweaks.instance.getProvider(container) != null —— 即当前打开的容器已在 容器注册表 中登记
  4. getModSupportState(provider.getModId()) 为 ENABLED 或 HOTKEYS_ONLY (见 模组支持状态)
  5. 若安装了 NEI,且 NEI 的物品搜索框正在输入(LayoutManager.getInputFocused() != null), 则所有热键一律失效(NEIHotkeyCheck.allowHotkeys())

按边沿触发:每个键配一个 wasRotated 布尔量,按下瞬间置 true,松键后复位, 因此长按不会连续触发。

行为

按键组合 行为
直接按 合成网格顺时针旋转 90°
按住 Shift 合成网格逆时针旋转 90°

isShiftDown 判定为 Keyboard.KEY_LSHIFT 或 Keyboard.KEY_RSHIFT 任一按下, 结果作为 counterClockwise 布尔量随封包发送。

无服务端时(isServerSideInstalled == false)客户端直接调用 clientProvider.rotateGrid(provider, player, container, 0, isShiftDown); 有服务端时发送 MessageRotate(id 0)。

客户端侧旋转的前置条件(ClientProvider.canRotate):

  • !provider.requiresServerSide() —— 即该容器的 provider 未开启 phantomItems
  • provider.getCraftingGridSize(...) == 9 —— 网格大小必须正好是 9

不满足时静默返回,不做任何事。

旋转本身先 dropOffMouseStack 把鼠标上的东西放回背包,再执行搬运。 优先使用 rotateGridWithBuffer(需要玩家背包里有 2 个空槽做缓冲), 否则退回无缓冲的循环 pick-up/put-down。

2×2 网格与 9 格网格使用不同的旋转映射表,详见 合成网格操作 的「旋转映射表」。

相关条目