PaperMC / PaperMC/Paper

Implement getSlot method for Shelf block

Open
#13,398 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: accepted
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?

There is no convenient way to detect which shelf slot a player has interacted with.

Describe the solution you'd like.

Like ChiseledBookshelf, I assumed Shelf blocks would have a getSlot method.

I need to be able to detect when a player has clicked on a specific shelf slot, so I can know which item, if any, is already present.

For example, I use this for chiseled bookshelves:

chiseledBookshelf.getInventory().getItem(chiseledBookshelf.getSlot(event.getClickedPosition()))

The 1.21.10 update tracking issue mentioned sharing this code between these blocks but nothing has come out of that.

Describe alternatives you've considered.

Only other way would be to calculate the slot from a vector myself which I'm not sure I can do purely from the API.

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

Compare the linked ChiseledBookshelf.java getSlot API with the Shelf block API and its inventory or event entry points. Trace how clicked positions and shelf contents are exposed, then verify that the Shelf API provides matching slot behavior through the relevant Paper build or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.