由于似乎没有适用于 Forge 1.20.1 的此类模组,我决定快速编写一个用于个人用途,然后上传以防其他人需要。
基本上,这个模组的作用是:如果自然生成的战利品使用了 enchant_randomly 或 enchant_with_levels 函数,它将重新掷骰(reroll)任何命中配置文件中列表内附魔的附魔物品。配置文件中的列表由 _description_ ID 组成,因为这些最容易获取,例如 "enchantment.minecraft.sharpness"。如果你想了解某个特定附魔的 ID,请查看包含该附魔模组的语言文件(lang files)。
因此,例如,如果你的配置文件如下所示:
bannedEnchantIds = ["enchantment.spartanweaponry.propel", "enchantment.spartanweaponry.razors_edge", "enchantment.spartanweaponry.incendiary", "enchantment.spartanweaponry.lucky_throw", "enchantment.spartanweaponry.hydrodynamic", "enchantment.spartanweaponry.supercharge", "enchantment.spartanweaponry.expanse", "enchantment.spartanweaponry.sharpshooter", "enchantment.spartanweaponry.collectorang"]
当你掷出一个使用 enchant_randomly 或 enchant_with_levels 掉落附魔装备的战利品表时,如果表中任何一项掷出了上述附魔之一,它将使用相同的设置持续重新掷骰,直到不再拥有这些附魔为止。在我的案例中,我通过上述配置 essentially 移除了 Spartan Weaponry 的额外附魔。
此模组不影响附魔台,要实现这一点你需要像 Enchantato 这样的模组,你可以在 Curseforge 上找到它。未来如果我想要添加该功能可能会支持,但目前仅针对战利品。
注意:此模组使用 mixins,实际上它基本上只有两个 mixins 和两个 mixin 接口。具体来说,我在 EnchantRandomlyFunction 和 EnchantWithLevelsFunction 的 TAIL 处进行混合以调整返回值,并使用一些访问器和调用器来获取它们的非公共代码。如果出于某种原因你有另一个也混合到这些区域的模组,可能会出现奇怪的现象或损坏的行为。
警告:理论上,如果你尝试禁止所有附魔,会导致一些延迟。为了防止无限循环,有一个硬编码的重掷限制为每个物品 100 次(之后它就给你当前掷出的结果,无论是否被禁),但这并非完全“免费”计算。尽管如此,在正常使用情况下你可能不会注意到任何卡顿或类似问题。如果你在配置中输入了错误的值(或删除了一个模组但忘记更新配置),它 simply 不会执行任何操作,因为它无法匹配 ID,几乎没有成本或对终端用户的负面影响,除了几个字符串检查。
除此之外,我测试过并且对我有效。你会看到一些 INFO 日志输出,每当它重新掷骰某物时,这将告诉你它在正常工作。
至于许可证,此模组提供几乎零支持或保证修复错误/添加功能,但也对你如何使用它没有任何限制。我没有将它上传到 github,但你可以随意反编译、复制、用于你自己的作品等。不需要署名,但我不能阻止你想署名的行为。我将其归入 MIT 许可证,因为这是最宽松的可用许可证。
Since nothing like this seems to exist for Forge 1.20.1, I decided to hack something together quickly for personal use, then upload it in case others needed it.
Basically, this mod will make it so that if a piece of naturally generated loot uses the enchant_randomly or enchant_with_levels functions, it will reroll any enchanted items that hit an enchant from the list in the config. The list in the config is made of description ids, since those are easiest to get, so things like "enchantment.minecraft.sharpness". If you want to know what a given enchantment's ID is, check the lang files for the mod that contains it.
So, for example, if your config looks like this:
bannedEnchantIds = ["enchantment.spartanweaponry.propel", "enchantment.spartanweaponry.razors_edge", "enchantment.spartanweaponry.incendiary", "enchantment.spartanweaponry.lucky_throw", "enchantment.spartanweaponry.hydrodynamic", "enchantment.spartanweaponry.supercharge", "enchantment.spartanweaponry.expanse", "enchantment.spartanweaponry.sharpshooter", "enchantment.spartanweaponry.collectorang"]
and you roll a loot table that drops enchanted gear using enchant_randomly or enchant_with_levels, if anything in that table rolls one of those enchantments it will reroll itself continually with the same settings until it no longer has one of those enchantments. In my case, I have essentially removed the extra enchantments from Spartan Weaponry using the config above.
This mod does not affect the enchanting table, to do that you'll need something like Enchantato, which you can find over on Curseforge. It might in the future if I want to add that feature but right now it's just for loot.
NOTICE: This mod uses mixins, in fact it's basically just two mixins and two mixin interfaces. Specifically, I am mixing in to EnchantRandomlyFunction and EnchantWithLevelsFunction at TAIL on both to adjust the return values, and with some accessors and invokers to get at their non-public code. If, for some reason, you have another mod that also mixes in to those areas there may be weirdness or broken behavior.
WARNING: Hypothetically, if you try to ban every enchant, you will cause some lag. There is a hardcoded reroll limit of 100 times per item (after which it just gives you what it rolls, banned or not) to prevent infinite loops but this isn't exactly "free" computation. Still, for normal use you probably won't notice any hitching or anything. If you enter a bad value in the config (or remove a mod but forget to update the config), it simply won't do anything since it won't match an ID, near-zero cost or negative end-user effect besides a few string checks.
Other than that, I tested it and it works for me. You'll see some INFO log emits whenever it rerolls something, which will tell you it's working.
As for the license, this mod is provided with essentially zero support or guarantees of bugfixing/features, but also zero restrictions with what you do with it. I'm not uploading it to github but feel free to decompile, copy, put it on your own work, whatever. No credits necessary, but I can't stop you if you want to give them. I filed it under MIT since that's the most permissive license available.
评论 0
登录后参与评分
还没有评论,来抢沙发吧