Piggy Lib
为所有 Piggy 模组提供核心基础设施和高性能工具类的共享库。它集中化了通用系统,以确保一致性、稳定性以及反作弊合规性。
⚡ 中央 Piggy 动作队列
Piggy 套件中最关键的组件。所有玩家交互(点击槽位、放置方块、使用物品)都必须通过此队列路由。
- 有状态动作:交互被封装在
IAction对象中(例如InteractBlockAction、MoveItemAction)。 - 基于验证而非假设:动作在数据包发送时不被视为“已完成”。它们使用
onExecute阶段来触发,并使用verify阶段轮询成功结果(例如,检查物品是否确实移动到了目标槽位)。 - 速率限制与 CPS:全局每秒点击次数(CPS)限制器遵循可配置的服务端规则。常规动作(如整理)会被节流处理,而救命级动作(如 MLG)则使用
ActionPriority.HIGHEST优先级以绕过限制器。 - 数据包打包:在安全的情况下将相关的交互分组为单刻执行,从而最大限度地减少网络开销。
? 性能与遥测
PerfMonitor
用于跟踪服务端健康状况和网络条件的强大工具类。
- 动态 TPS 追踪:计算实时服务器刻每秒(Ticks Per Second)。
- 延迟计算:提供稳定、平滑的延迟数据,供
piggy-build用于预判动作触发。
Meta-Action Sessions
用于诊断复杂故障的高级遥测引擎。
- 上下文日志记录:在动作前后捕获库存状态、玩家位置和元数据。
- 取证报告:为失败的操作(如失败的库存整理或未命中的 MLG)生成详细的 JSON/Markdown 报告。
- 丰富格式:使用
PiggyTelemetryFormatter提供交互式、可点击的聊天组件,以便管理员审查。
? 库存 API
InventorySearcher
一个模块化、高性能的跨多个容器查找物品的引擎。
- 基于条件的搜索:按类型、标签、NBT 或自定义谓词过滤物品。
- 多槽位解析:处理涉及拆分堆叠或“超级堆叠”(>64 个物品)的复杂搜索。
? UI 与配置
- 统一径向菜单:标准化的
GenericRadialMenuScreen,用于保持一致的选择界面。 - YACL 配置包装器:一种简化的工厂模式,用于使用 Yet Another Config Lib 构建美观的分类配置屏幕。
- 反作弊反馈:HUD 覆盖层和浮动通知,告知玩家哪些功能受到服务端限制。
依赖项
- Fabric API
- YACL(配置 UI 必需)
许可证
CC0-1.0
Piggy Lib
A shared library providing the core infrastructure and high-performance utilities for all Piggy mods. It centralizes common systems to ensure consistency, stability, and anti-cheat compliance.
⚡ Central Piggy Action Queue
The most critical component of the Piggy suite. All player interactions (clicking slots, placing blocks, using items) must be routed through this queue.
- Stateful Actions: Interactions are wrapped in
IActionobjects (e.g.,InteractBlockAction,MoveItemAction). - Verification over Assumption: Actions are not considered "done" when the packet is sent. They use an
onExecutephase to trigger and averifyphase to poll for success (e.g., checking if an item actually moved to the destination slot). - Rate Limiting & CPS: A global Clicks-Per-Second (CPS) limiter follows configurable server rules. Routine actions (sorting) are throttled, while life-saving actions (MLG) use
ActionPriority.HIGHESTto bypass the limiter. - Packet Bundling: Groups related interactions into single-tick executions when safe, minimizing network overhead.
? Performance & Telemetry
PerfMonitor
A robust utility for tracking server-side health and network conditions.
- Dynamic TPS Tracking: Calculates real-time Server Ticks Per Second.
- Latency Calculation: Provides stable, smoothed ping data used by
piggy-buildfor preemptive action triggering.
Meta-Action Sessions
A sophisticated telemetry engine for diagnosing complex failures.
- Contextual Logging: Captures inventory states, player positions, and world metadata before and after actions.
- Forensic Reports: Generates detailed JSON/Markdown reports for failed operations (like a failed inventory sort or a missed MLG).
- Rich Formatting: Uses
PiggyTelemetryFormatterto provide interactive, clickable chat components for administrative review.
? Inventory API
InventorySearcher
A modular, high-performance engine for finding items across multiple containers.
- Condition-Based Search: Filter items by Type, Tag, NBT, or custom predicates.
- Multi-Slot Resolution: Handles complex searches involving split stacks or "mega-stacks" (>64 items).
? UI & Configuration
- Unified Radial Menus: Standardized
GenericRadialMenuScreenfor consistent selection interfaces. - YACL Config Wrappers: A simplified factory pattern for building beautiful, categorized configuration screens using Yet Another Config Lib.
- Anti-Cheat Feedback: Hud overlays and floating notifications that inform players when features are restricted by the server.
Dependencies
- Fabric API
- YACL (Required for config UI)
License
CC0-1.0
下载 Piggy Lib
下载 Piggy Lib
下载 Piggy Lib
下载 Piggy Lib
下载 Piggy Lib
下载 Piggy Lib
下载 Piggy Lib
排序的热修复
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
适用于 MC 1.18+ 的 Effekseer 加载器
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧