PaperMC / PaperMC/Paper

Add `AnvilUseEvent` to the API

Open
#13,575 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: needs triage
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

Is your feature request related to a problem?

Yes - I am working on a special anvil interface that allows players to rename items with MiniMessage tags to add colours and decorations to their item names. I want to charge players an amount of in-game currency for using it - I want the code for this to run once the player has taken the renamed item out of the result slot.

Describe the solution you'd like.

An AnvilUseEvent, which should fire even for "fake" anvils (anvil views created with the MenuType API opened for players).

Describe alternatives you've considered.

I tried using InventoryClickEvent, but I found it to be unreliable for isolating this scenario. This is because the result slot can be clicked in many different ways (e.g. while holding an item which results in nothing). I tried making sure the InventoryAction was NOTHING, but I found that this was the even case when removing the item from the result slot by clicking it with a bundle, which doesn't seem correct.

I think having a dedicated AnvilUseEvent (or similar name) would be a much more robust way of isolating this scenario.

Other

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Anvil handling exposed through the MenuType API and comparing it with InventoryClickEvent and InventoryAction behavior for the result slot. Done means a dedicated AnvilUseEvent fires when a player takes the renamed result, including from fake anvils created through MenuType.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.