Create a Minecraft Paper plugin for version 1.21.11 with the following behavior:
Core Feature
Modify the smithing table behavior for Netherite upgrades:
* When a player uses:
* Netherite Upgrade Smithing Template * Netherite Ingot * Any diamond armor piece (helmet, chestplate, leggings, boots)
👉 The upgrade MUST NOT produce Netherite armor.
Instead:
* The result should remain the same diamond armor piece (unchanged) * The Netherite Ingot and Smithing Template are consumed (wasted) * This simulates a “failed upgrade”
Important Rules
* ONLY apply this restriction to diamond armor:
* Diamond Helmet * Diamond Chestplate * Diamond Leggings * Diamond Boots
* DO NOT block or modify:
* Diamond tools (pickaxe, axe, shovel, hoe) * Diamond sword * Any other smithing recipes
👉 These items should upgrade to Netherite normally.
Technical Requirements
* Use latest Paper API (1.21.1) * Listen to the appropriate smithing event (e.g., PrepareSmithingEvent or equivalent) * Ensure compatibility with vanilla mechanics (no duplication bugs, no crashes) * Prevent client-side desync (result preview must match final output) * Clean, well-structured Java code * Include plugin.yml
Optional (nice to have)
* Config option to enable/disable this feature * Permission node to bypass restriction
Expected Outcome
* Players attempting to upgrade diamond armor waste resources and get the same item back * All other Netherite upgrades behave normally
Plan:
NetheriteFailPlugin— main class, registers managers and listenersConfigManager— readsenabledtoggle from configSmithingListener— interceptsPrepareSmithingEvent, checks for diamond armor + netherite template + ingot, replaces result with the original diamond piece; bypass permission skips the restriction
Summary: The plugin intercepts PrepareSmithingEvent at HIGH priority — when the smithing table contains a Netherite Upgrade Template (slot 0), a diamond armor piece (slot 1), and a Netherite Ingot (slot 2), the result is replaced with a clone of the diamond armor instead of Netherite armor. Since the smithing table always consumes all three inputs when the result is taken, the template and ingot are wasted while the diamond piece is returned — exactly simulating a failed upgrade. Tools, swords, and all other smithing recipes are unaffected. Players with netheritefail.bypass permission skip the restriction entirely.
✅ Copy-paste this (fixed prompt)
Fix my Paper plugin for Minecraft 1.21.1/1.21.x (NetheriteFailPlugin).
The plugin does not currently work in-game.
I need a correct implementation for the modern smithing system (SmithingTransformRecipe).
Core behavior:
When a player uses:
Netherite Upgrade Template Netherite Ingot Diamond armor piece (helmet, chestplate, leggings, boots)
The result MUST stay the same diamond armor piece (no upgrade).
The template and ingot MUST still be consumed normally.
Critical requirements:
Must use correct 1.21 smithing handling (SmithingTransformRecipe system) Do NOT rely only on outdated PrepareSmithingEvent logic if it does not affect result anymore Ensure the preview result in the smithing table matches the final output (no client desync) Only affect diamond armor Do NOT affect tools or sword or other recipes Also include: full corrected Java source code correct plugin.yml explanation of what was wrong in the old version
Make sure it works on Paper 1.21.1 / 1.21.x
What was wrong:
PrepareSmithingEvent.setResult()in 1.21 correctly updates the preview slot, but when the player actually takes the result, the server re-runs the vanilla recipe and produces Netherite armor anyway — thesetResult()result is discardedThis means you get a desync: the preview shows diamond armor, but picking it up gives Netherite armor
The fix requires a second listener on
InventoryClickEventto intercept the actual pickup of the result slot, cancel it, and manually return the diamond armor while consuming the template and ingot
What was wrong & why this fixes it
Problem | Root cause | Fix |
|---|---|---|
Diamond armor still upgraded to Netherite | In Paper 1.21, PrepareSmithingEvent.setResult() only sets the visual preview . When the player clicks the result slot, the server re-evaluates the vanilla SmithingTransformRecipe and produces Netherite armor, discarding the custom result entirely | Added InventoryClickEvent on raw slot 3 (the result slot) — this intercepts the actual transaction , cancels it, and manually handles item distribution |
Client desync (preview showed diamond, received Netherite) | setResult() result was overwritten server-side during pickup | PrepareSmithingEvent is still kept to correctly set the preview , and InventoryClickEvent guarantees the final outcome matches |
Shift-click not handled | No interaction handling at all beyond the prepare event | isShiftClick() branch adds the diamond armor directly to the player’s inventory and drops any overflow |
Flow after the fix:
Player fills the smithing table →
PrepareSmithingEventfires → preview slot shows the diamond armor piecePlayer clicks the result →
InventoryClickEventfires atrawSlot == 3→ event is cancelled → template consumed, ingot consumed, base cleared, diamond armor placed on cursor (or shift-clicked into inventory)Players with
netheritefail.bypassskip both handlers and receive normal Netherite armor
package com.netheritefail;
import com.netheritefail.config.ConfigManager;
import com.netheritefail.listener.SmithingListener;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
public class NetheriteFailPlugin extends JavaPlugin {
@Getter
private ConfigManager configManager;
@Override
public void onEnable() {
saveDefaultConfig();
this.configManager = new ConfigManager(this);
getServer().getPluginManager().registerEvents(new SmithingListener(this), this);
}
@Override
public void onDisable() {
}
}