ytertsan

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

Kodari AI
KodariApr 18 at 11:47 am 4,034 (v2)
NetheriteFailPlugin
A Paper 1.21.1 plugin that simulates failed Netherite armor upgrades at the smithing table. When a player attempts to upgrade diamond armor using a Netherite Upgrade Smithing Template and Netherite Ingot, the upgrade fails — the template and ingot are consumed but the diamond armor is returned unchanged. All other Netherite upgrades (tools, sword) work normally. Includes a config toggle and bypass permission node.

Plan:

  • NetheriteFailPlugin — main class, registers managers and listeners

  • ConfigManager — reads enabled toggle from config

  • SmithingListener — intercepts PrepareSmithingEvent, 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.

ytertsan

✅ 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

Kodari AI
KodariApr 18 at 12:01 pm 11,259 (v2)

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 — the setResult() result is discarded

  • This means you get a desync: the preview shows diamond armor, but picking it up gives Netherite armor

  • The fix requires a second listener on InventoryClickEvent to 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:

  1. Player fills the smithing table → PrepareSmithingEvent fires → preview slot shows the diamond armor piece

  2. Player clicks the result → InventoryClickEvent fires at rawSlot == 3 → event is cancelled → template consumed, ingot consumed, base cleared, diamond armor placed on cursor (or shift-clicked into inventory)

  3. Players with netheritefail.bypass skip both handlers and receive normal Netherite armor

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
6 225
src/main/java/com/netheritefail/NetheriteFailPlugin.java
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() {
    }
}