Skip to content

Anvil inventories still don't work like they could #10352

Closed

Description

@NonSwag

Is your feature request related to a problem?

So, there's been an ongoing issue with Bukkit and anvil inventories that seems to have persisted for quite some time. It's been rather frustrating, to say the least. Essentially, when attempting to create an anvil inventory using Bukkit's createInventory method, things just don't function as expected.

The crux of the problem lies in anvils created this way ending up as type CraftInventoryCustom instead of the expected CraftInventoryAnvil. This leads to a myriad of issues – events fail to trigger properly, and window properties appear to be behaving strangely. It's all quite bothersome.

Currently, the most dependable method to obtain a functional anvil is by utilizing Player#openAnvil. However, let's be honest, that's not a universal solution. There are instances where greater flexibility is required.

Describe the solution you'd like.

It would be incredibly helpful to have a method like Bukkit#createAnvil or perhaps a solution to address the issues in the existing createInventory methods.

Describe alternatives you've considered.

Currently, the way to go is by using NMS, which seems a bit silly for such a simple task.

Other

No response

Activity

  1. Sytm commented on Mar 24, 2024

    @Sytm
    Contributor

    However, let's be honest, that's not a universal solution. There are instances where greater flexibility is required.

    Could you perhaps expand on the problems you have with this method?
    I use that method to open a text input GUI and have no problems customizing the behavior with the different inventory events that are already in the Paper API

  2. NonSwag commented on Mar 24, 2024

    @NonSwag
    SponsorContributorAuthor

    in some cases you want reusable inventories or custom inventory holders
    also it is not possible to define a custom name for the inv when using player open anvil

  3. Sytm commented on Mar 24, 2024

    @Sytm
    Contributor

    Yeah, applying a custom name is currently very annoying, because you need to override the title in the InventoryOpenEvent, but I already opened a PR that alleviates this problem (#9658).

    Iirc making the inventory reusable is not really possible, because the real inventory is tied to a player, but custom inventory holders would be indeed nice for easier handling of events

  4. NonSwag commented on Mar 24, 2024

    @NonSwag
    SponsorContributorAuthor

    I think anvils are not player but location bound

  5. locked and limited conversation to collaborators on Apr 28, 2024
  6. converted this issue into a discussion #10600 on Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featureRequest for a new Feature.

    Fields

    No fields configured for Feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions