Oggvik's Inventory Freeze
一个用 Java 编写的简单 Minecraft Forge 模组,允许你为所有玩家“冻结”可配置的背包栏位。它的主要用途是在服务器上使用(例如角色扮演服务器中的角色扮演活动,为了增加沉浸感而限制背包栏位数量),或作为整合包的一部分(例如极限硬核生存整合包)。
该模组提供了一个单一命令,用于全局启用特定背包栏位的“冻结”功能:
/inventory-lock [true/false]
DESIGN
- ? 非常简洁清晰的 Java 代码
- ? 服务端看门狗机制,防止物品复制漏洞及物品删除
- ? 易于移植到更新的 Minecraft/Forge 版本
- ? 自定义物品拾取逻辑,防止将物品放入“冻结”/“锁定”的背包栏位中
- ? GUI 效果(前端)代码与程序内部逻辑(后端)隔离
- ? 体积小巧(目前仅约
~330 KB)
- ? 已测试在生存模式及多人服务器环境下均可正常运行
FUNCTIONALITY
- ? 当设置
/inventory-lock true 时,“冻结”玩家背包的部分栏位。
- ❌ 当
/inventory-lock 为 true 时,玩家无法将物品放入、取出或删除 自己 “冻结”/锁定的背包栏位中的物品。
- ? 仅冻结配置好的背包栏位。也就是说,不会影响箱子等其他模组的背包栏位(例如背包)、盔甲、披风以及其他与外观相关的自定义背包栏位。
- ? 要冻结的背包栏位可由服务器管理员轻松配置。
- ? 当玩家切换到创造模式时,会自动解除其背包的冻结状态;如果他们在
/inventory-lock 仍为 true 的情况下退出创造模式,则会再次冻结其背包。
- ?️ 被冻结的栏位会用半透明的灰色方块覆盖层进行指示(未来版本的指示器外观可能会更改)。
- [WIP]
??? 可选择性地将特定玩家排除在 /inventory-lock 之外。例如,在服务器上主持角色扮演活动的玩家或扮演角色的玩家,可以在活动期间被排除在 /inventory-lock 之外。
COMPATIBLE VERSIONS
Minecraft: 1.16.5
Mod Launcher: Forge (已在 36.2.42 上测试)
BUILDING THE PROJECT
首次构建项目时,你需要进入其根目录并运行:
./gradlew build --refresh-dependencies
而在后续编译中,只需运行 ./gradlew build 即可。
编译已通过 Java 17 OpenJDK 测试,但高于此版本的某些版本以及低至至少 Java 8 的版本也应能正常工作。
上述操作会在 ./build/libs 目录下生成一个 inventoryfreeeze-X.X.X.jar 文件,你可以将其添加到 Minecraft 1.16.5 Forge 配置文件中进行游玩。
此外,如果你使用的是 IntelliJ IDEA(我推荐使用的 IDE),还可以通过执行以下命令来编译 Forge Gradle Runs:
./gradlew genIntellijRuns
EXAMPLE SCREENSHOTS
Example 1 – With custom mod config
Example 1 显示了根据下方自定义服务器配置锁定的背包栏位:

Example 2 – With a modpack
以下是作为整合包一部分的背包冻结功能的示例:

Credits: "Dawn of Humanity" AoT-inspired modpack
Example 3 – With a modpack + resource pack
与 example 2 相同,但展示了应用资源包后覆盖层指示器效果也能正常工作。
请注意,锁定的背包栏位看起来比未锁定的快捷栏栏位更暗,而在本资源包中它们原本应具有相同的颜色。
Credits: "Dawn of Humanity: RP!" Resource pack
Oggvik's Inventory Freeze
A simple Minecraft Forge mod written in Java that lets you "freeze" configurable inventory slots globally for all players. It's main purpose is to be used on a server (e.g. an RP server with roleplaying events where you'd want to limit the number of inventory slots for the sake of added immersion) or as part of modpacks (e.g. ultra hardcore survival ones).
The mod provides a single command to enable globally "freezing" specific inventory slots using the command:
/inventory-lock [true/false]
DESIGN
- ? Very clean and simple code written in Java
- ? Server-side watchdog to prevent item duping exploits & item deletion
- ? Could easily be ported to newer Minecraft/Forge versions
- ? Custom item pickup logic to prevent picking up items into "frozen"/"locked" inventory slots
- ? GUI effects (frontend) code isolated from the rest of the program's internal logic (backend)
- ? Tiny size (currently a mere
~330 KB)
- ? Tested to work in both survival and on multiplayer with many people / on a server
FUNCTIONALITY
- ? "Freeze" parts of the players' inventories while
/inventory-lock true is set.
- ❌ When
/inventory-lock is true players cannot put in, take out, or delete items from their own "frozen"/locked inventory slots.
- ? Only freezes the inventory slots configured. Aka doesn't affect inventory slots such as chests, other mods (e.g. backpacks), armor, capes, and other custom inventory slots related to cosmetics.
- ? The inventory slots to be frozen are to be easily configurable by server admins.
- ? Automatically unfreezes the inventories of players when they switch to creative mode, then re-freezes them again if they exit creative mode while the
/inventory-lock is true.
- ?️ The slots that are frozen will be indicated with a gray transparent square overlay (indicator appearance might be altered in future versions).
- [WIP]
??? Optionally exclude specific players from the /inventory-lock. For example whoever is hosting an RP event on a server or playing an actor could be excluded from the /inventory-lock for the duration of that time.
COMPATIBLE VERSIONS
Minecraft: 1.16.5
Mod Launcher: Forge (tested on 36.2.42)
BUILDING THE PROJECT
To build the project for the first time you'll need to go to its root directory and run:
./gradlew build --refresh-dependencies
Though on subsequent compiles it is enough to simply run ./gradlew build
Compilation has been tested to work with Java 17 OpenJDK but some versions above that and any version lower until at least Java 8 should also work.
The above will generate an inventoryfreeeze-X.X.X.jar in the ./build/libs directory, which you can then add to a Minecraft 1.16.5 Forge profile to play.
Also, if you're using IntelliJ IDEA (which I'd recommend), you can also compile Forge Gradle Runs by executing:
./gradlew genIntellijRuns
EXAMPLE SCREENSHOTS
Example 1 – With custom mod config
Example 1 shows locked inventory slots according to the custom server config below:

Example 2 – With a modpack
Here is an example of the inventory freeze feature in action as part of a modpack:

Credits: "Dawn of Humanity" AoT-inspired modpack
Example 3 – With a modpack + resource pack
Same as example 2 but showing the overlay indicator effect also working when a resource pack is applied.
Notice the locked inventory slots appear darker than the unlocked hotbar slots, whereas in this resource pack they would normally all have the same color.
Credits: "Dawn of Humanity: RP!" Resource pack
评论 0
登录后参与评分
还没有评论,来抢沙发吧