enchantlimiter-3.1.0.jar
Curse Maven Snippet
What's new
HUGE Thanks toKnozyy!!!
What
Until now the limit could only be switched off for the whole server (/enchantlimiter disable, stored in the config). This PR lets you exempt individual players, and optionally their whole FTB Teams party, while everyone else stays limited.
How to use it
1. Via advancement (e.g. "first Infinity ingot")
Add the advancement ID to enchantlimiter-server.toml:
[general] "exempt advancements" = ["mypack:obtained_infinity_ingot"]
The pack defines that advancement with a normal minecraft:inventory_changed criterion. When a player earns it, they are exempt. Players who earned it before the config entry existed are picked up on their next login.
2. Via command (op level 2, works for offline players too)
/enchantlimiter exempt <players> -> show status
/enchantlimiter exempt <players> true|false -> grant / revoke
3. FTB Teams (optional)
If FTB Teams is installed and anyone in a player's party is exempt, the whole party is exempt. This is checked live: joining an exempt party grants it, and leaving revokes it. Without FTB Teams nothing changes. It is a compileOnly dependency and mandatory=false in mods.toml.
How it works
The limit lives in EnchantmentHelper.setEnchantments / ItemStack.enchant, which have no player parameter. So the acting player is tracked in a ThreadLocal (PlayerContext) around the operations where a player is known:
- Enchanting tables: redirect around
clickMenuButtoninServerGamePacketListenerImpl.handleContainerButtonClick. This covers the vanilla table, Apotheosis' table (which overridesclickMenuButtonwithout calling super), Enchanting Infuser, and any other table that uses the vanilla button packet. - Anvil: head/return around
AnvilMenu.createResult. This also covers everyAnvilUpdateEventlistener, including this mod's own. - Apotheosis Library:
@Pseudomixin aroundEnchLibraryContainer.onButtonClick, because it uses Placebo's own packet. It hasrequire = 0, so it does nothing if Apotheosis is absent or changes.
Operations without a player (loot, villager trades, /enchant) stay limited. As a safety net, the context is cleared at the start of every server tick.
The exemption is synced to the client with a small packet. Anvil previews then match the server result, and the tooltip shows "Enchant Points: No limit" (en/ja/zh lang keys added).
Exemptions are stored per world in data/enchantlimiter_exemptions.dat, not in the config.
https://github.com/BOLTMAGIC/EnchantLimiter/pull/7
This mod has no additional files