Enchantment Limiter Fork

Restrict the number of enchantments that may be applied to an item.
Back to Files

enchantlimiter-3.1.0.jar

File nameenchantlimiter-3.1.0.jar
Uploader
BOLT_M4G1CBOLT_M4G1C
Uploaded
Sep 25, 2026
Downloads
512
Size
60.1 KB
Mod Loaders
Forge
File ID
8973904
Type
R
Release
Supported game versions
  • 1.20.1

Curse Maven Snippet

Forge

implementation fg.deobf("curse.maven:enchantment-limiter-fork-1415105:8973904")

Learn more about Curse Maven

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 clickMenuButton in ServerGamePacketListenerImpl.handleContainerButtonClick. This covers the vanilla table, Apotheosis' table (which overrides clickMenuButton without calling super), Enchanting Infuser, and any other table that uses the vanilla button packet.
  • Anvil: head/return around AnvilMenu.createResult. This also covers every AnvilUpdateEvent listener, including this mod's own.
  • Apotheosis Library: @Pseudo mixin around EnchLibraryContainer.onButtonClick, because it uses Placebo's own packet. It has require = 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