DynamicItemScan Modded Bingo
这是一个仅适用于 1.12.2 服务端端的 Forge 模组。
这个模组是关于什么的?
此模组允许你在 Minecraft 中玩宾果游戏(Bingo),以所有在生存模式下可获取的已加载原版及模组物品作为目标。
每个队伍或单人玩家都会获得一张包含物品网格的宾果卡副本。方形网格的大小可以从 3x3 调整到 9x9。在生存模式中找到或制作卡片上的物品后,该物品格子会被划掉。第一个凑齐整行、整列或对角线的队伍或单人玩家获胜!
这个模组的特别之处在哪里?
动态物品扫描
此模组会遍历所有已加载战利品表、合成配方、村民交易和熔炉烧炼配方的所有现存模组,并记录它找到的所有新物品。它还尝试通过二元排列来测试应用于战利品表中物品的所有可能的 LootFunctions 组合,以捕获所有可能在生存模式中出现或制作的物品。
不会搜索完整的物品注册表,因为它可能包含仅在创造模式下才能获得的物品,而在生存模式下无法获取。
确保物品是唯一的,这样每个物品出现在宾果卡上的概率都是相同的。要添加到最终物品列表中,一个物品必须在注册表名称、元数据和 NBT 标签上与列表中已有的物品完全不相同。
请注意,无论安装了什么模组,这都有效。如果模组文件夹的内容在服务器重启后发生变化,物品池会自动适应。
动态物品扫描的主要局限性:
- 我们无法保证扫描能发现每一个可获取的物品。如果一个物品没有注册在任何合成或烧炼配方或战利品表中,而是通过模组添加的机器获得的,它将不会被检测到。
- 假设合成配方的原料是可获取的,以缓解上述问题,但这可能并非总是如此
- 我们无法检测哪些附魔适用于哪些物品。为了添加一些附魔物品,每种已注册附魔的附魔书都被添加到物品池中。
“至少”原则 - 如何检查物品的相等性?
核心思想是以不对称的方式处理宾果卡上所需的物品和玩家背包中找到的物品。
当找到的物品满足所需物品的至少所有属性时,两个物品被称为相等。找到的物品可以拥有多余的属性。
注意:
- 数量被忽略
- 物品元数据和物品耐久使用同一个变量。如果物品被标记为可损坏,如果它“认为它是可损坏的”,该变量用于耐久,我们将其作为属性忽略
考虑以下示例:
| 属性 |
找到的物品 |
所需的物品 |
| 注册表名称 |
stone_hoe |
stone_hoe |
| 元数据 |
0 |
23 |
这些物品将被视为不相等,因为所需的物品有指定的元数据,而找到的物品没有。
| 属性 |
找到的物品 |
所需的物品 |
| 注册表名称 |
stone_hoe |
stone_hoe |
| 元数据 |
23 |
0 |
然而在这里,物品将被视为相等,因为找到的物品满足的属性比所需的物品拥有的更多。
如果找到的物品已附魔而所需的物品未附魔,或者找到的物品比所需的物品有更多的附魔,情况也是如此。
可变大小的宾果卡
通常,宾果游戏是用 5x5 的正方形卡片进行的。在这里,你可以自定义宾果卡的大小,范围从 3x3 到 9x9。
玩家可以重新加入
当玩家离开时,模组会记住他所处的队伍。一旦他重新加入且游戏仍在运行,他将自动被放入正确的队伍,并且卡片上的进度会更新。
游戏循环
设置队伍 -----------> 开始 ---------> 自然结束(完成宾果)/ 取消 -------> 设置队伍
命令
- /teams: 设置指定的队伍
- /start: 用指定设置开始新游戏
- /cancel: 取消当前运行的游戏
用法:
- /teams [player1,player2][player3] (需要括号!) 结果如
| 队伍 1 | 队伍 2 |
|---|
| player1, player2 | player3 |
|---|
- /start 3-9(网格大小) 3-6(背包大小) true-false(不同队伍使用不同卡片) true-false(每人一把钻石镐) true-false(每人一个合成台) true-false(keepInventory) true-false(noHunger)
括号中的文本仅用于解释,在实际命令语法中不需要。
因此,该命令总共接受 7 个参数。
例如:/start 5 6 false true true true true 将开始一场游戏,使用 5x5 宾果卡,6x9 背包,所有队伍使用相同卡片(所有人追求相同的目标),每人一把钻石镐和一个合成台,开启 keepInventory,游戏中无饥饿值流逝。
/start 9 6 true true true true true 将是 9x9 宾果卡,6x9 背包,不同队伍使用不同地图(每个人都有各自的目标,可能相对于其他队伍的目标难度而言运气好或坏),钻石镐,合成台,keepInventory 和无饥饿值。
- /cancel
为什么会有 "z"?
物品扫描意味着此模组需要在所有其他模组的物品加载完成后加载。因此,由于 Forge 模组加载器倾向于按字母顺序加载模组,此模组的 modid 以及 jar 文件名都以 3 个 "z" 开头。
其他
数据包
此模组修改了用于客户端与服务器通信所必需的数据包。
本模组已经过测试,但请注意,服务端数据包和客户端数据包的管道中若出现任何错误,都可能导致服务器和/或客户端崩溃。
反射
本项目使用反射机制来实现其功能。通常不建议使用反射。
请注意,这会导致项目高度不稳定且仅适用于特定版本。
本模组已在 Forge 1.12.2-14.23.5.2847 版本下经过测试。理论上,其他 1.12.2 版本也应该可以运行,但未经过测试。
本人不承担任何责任。
克隆与构建
本模组是为 Minecraft 1.12.2 开发的,构建时需要 JDK 1.8.0。测试用例使用的 JDK 版本为 1.8.0_302。
- 在本地选择的目录中克隆仓库(参见源码链接)
- 确保您的设备上已安装 JDK 1.8.0 版本
- 在克隆的目录中打开命令提示符
- 使用 Gradle Wrapper 进行构建,并指定使用的 Java 版本:
- Windows: gradlew build -Dorg.gradle.java.home=PATH_TO_JDK_1.8.0
- Unix: ./gradlew build -Dorg.gradle.java.home=PATH_TO_JDK_1.8.0
生成的模组 jar 文件将位于 /build/libs 目录下,您可以将其粘贴到服务器的 mods 文件夹中。
DynamicItemScan Modded Bingo
This is a 1.12.2 server side only forge mod.
What is this mod about?
This mod lets you play bingo in Minecraft, with all loaded vanilla and mod items that are obtainable in survival as goals.
Each team or single player gets a copy of a bingo card that contains a grid of items. The square grid can be varied in size, from 3x3 to 9x9. Items in the card are crossed out by finding or crafting them in survival mode. The first team or single player to get a full row, column or diagonal, wins!
What´s so special about this mod?
The dynamic item scan
This mod goes through all loaded loot tables, crafting recipes, villager trades and furnace smelting recipes of all present mods and records all new items that it finds. It also tries out every possible combination of LootFunctions, that are applied on items in LootTables, by doing a binary permutation, to catch all items that can appear or be crafted in
survival mode.
The full item registry is not searched, because it could contain mere creative mode items that cannot be obtained in survival mode.
Items are ensured to be unique, such that the probability of each item appearing in the bingo card is the same. To be added to the final item list, an item must not be identical in all registry name, metadata and NBT tag to an item already in the list.
Note that this works regardless of what mods are installed. All mods are scanned, if the contents of the mods folder change, after a server restart, the item pool adapts automatically.
Key caveats of the dynamic item scan:
- We cannot ensure the scan will find every obtainable item. If an item is not registered in a crafting or smelting recipe or a loot table, but is rather obtained by a mod-added machine, it will not be detected.
- Crafting recipe ingredients are assumed to be obtainable to mitigate the point above, which may not be the case
- We cannot detect which enchantments are applicable to which items. To add some enchanted items, enchanted books of each registered enchantment are added to the item pool.
The "at least" principle - how are items checked for equality?
The key idea is to treat the required item in the bingo card and the found item in the player´s inventory asymmetrically.
Two items are called equal, when the found item meets at least all properties of the required item. The found item can have excess properties.
Note that:
- count is ignored
- Item metadata and item damage use the same variable. If the item is marked to be damageable, if it "thinks that it´s damageable", the variable is used for damage and we ignore it as a property
Consider the following example:
| Property |
found item |
required item |
| Registry name |
stone_hoe |
stone_hoe |
| Metadata |
0 |
23 |
The items would not be considered equal, since the required item has a specified metadata, and the found item has not.
| Property |
found item |
required item |
| Registry name |
stone_hoe |
stone_hoe |
| Metadata |
23 |
0 |
Here however, the items would be considered equal, since the found item fulfills more properties than the required item has.
The same would be true if the found item is enchanted and the required item is not, or the found item has more enchantments than the required item.
Variable bingo card sizes
Normally, bingo is played with a 5x5 square card. Here, you can customize the bingo card size ranging from 3x3 up to 9x9.
Players can rejoin
When a player leaves, the mod will remember the team that he was in. Once he rejoins and the game is still running, he will be automatically put in the right team, with progress on the card updated.
Game Loop
SET TEAMS -----------> START --------> NATURAL FINISH (BINGO) / CANCEL -------> SET TEAMS
Commands
- /teams: Sets the specified teams
- /start: starts a new game with specified settings
- /cancel: cancels a currently running game
Usage:
- /teams [player1,player2][player3] (brackets needed!) results in
| Team 1 | Team 2 |
|---|
| player1, player2 | player3 |
|---|
- /start 3-9(grid-size) 3-6(backpack-size) true-false(different cards for different teams) true-false(with diamond pickaxe for everyone) true-false(with inventory crafting table for everyone) true-false(keepInventory) true-false(noHunger)
The text in parentheses is only for explanation and is not needed in the actual command syntax.
The command thus takes a total of 7 arguments.
For example: /start 5 6 false true true true true will start a game with a 5x5 bingo card, 6x9 backpack, same card for all teams (all chase the same goals), diamond pickaxes and crafting tables for everyone, keepInventory on and no hunger ticks during the game.
/start 9 6 true true true true true will be 9x9 bingo card, 6x9 backpack, different maps for different teams (all have their own goals and can be lucky or unlucky regarding the goals difficulty relative to the other teams), diamond pickaxes, crafting tables, keepInventory and no hunger.
- /cancel
Why the "z"´s?
The item scan implies that this mod needs to be loaded after all other mods have loaded in their items. Therefore, since the forge mod loader tends to load mods alphabetically, the modid as well as the jar name of this mod start with 3 "z".
Other
Packets
This mod modifies ingoing and outgoing packets that are necessary for client-server-communication.
The mod was tested, but note that any error in the serverbound and clientbound packet pipeline will likely crash the server and/or the client.
Reflection
This project uses reflection to make its features work. Use of reflection is usually not recommended.
Please note that this makes the project highly unstable and version specific.
The mod was tested with forge version 1.12.2-14.23.5.2847. In theory, other 1.12.2 versions should also work, but weren´t tested.
I do not take any responsibility.
Cloning and Building
This Mod was developed for Minecraft 1.12.2, and requires JDK 1.8.0 for building. Test case version was JDK version 1.8.0_302.
- Clone the repository (see sources link) in a local directory of your choice
- Make sure you have a JDK version 1.8.0 installed somewhere on your device
- Open Command Prompt in the cloned directory
- use gradle wrapper to build, specifying the java version used:
- gradlew build -Dorg.gradle.java.home=PATH_TO_JDK_1.8.0 for Windows
- ./gradlew build -Dorg.gradle.java.home=PATH_TO_JDK_1.8.0 for Unix
The generated mod jar file will be located in /build/libs and can be pasted into the mods folder of your server.
评论 0
登录后参与评分
还没有评论,来抢沙发吧