Skip to content

Added getInstrument method to BlockData API - #14251

Open
ItzMatick wants to merge 4 commits into
PaperMC:mainfrom
ItzMatick:add-instrument
Open

ItzMatick wants to merge 4 commits into
PaperMC:mainfrom
ItzMatick:add-instrument

Conversation

@ItzMatick

Copy link
Copy Markdown

I added the missing getInstrument() method to the API as requested in issue #14228.

Changes:

  • Added the interface method to BlockData.
  • Added the translation logic in CraftBlockData.

@ItzMatick
ItzMatick requested a review from a team as a code owner September 13, 2026 13:59
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Sep 13, 2026
Comment thread paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java Outdated
@Lulu13022002

Copy link
Copy Markdown
Contributor

This only really depends on the block type so I think BlockType is a more suitable place

@ItzMatick

ItzMatick commented Sep 13, 2026

Copy link
Copy Markdown
Author

That’s a fair point, but I added it to BlockData because it directly mirrors Vanilla architecture (this.state.instrument()). If I move it to BlockType, I would have to pull it from default blocks.

@ItzMatick

Copy link
Copy Markdown
Author

@Lulu13022002 What do you think? Where should I put it?

@Lulu13022002

Copy link
Copy Markdown
Contributor

I think it can be on both if you really want it on BlockData, but it's fine to use the default block state (it wouldn't be the first method here). There is no need to fully mirror vanilla, the api is a bit inconsistent on where to place things here (some case using CraftBlock too).

@ItzMatick

Copy link
Copy Markdown
Author

Sure, I added it also to BlockType.

}
// Paper end - hasCollision API

// Paper start - getInstrument API

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comments are only necesary in NMS

*
* @return the associated instrument
*/
Instrument getInstrument();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing NotNull annotation.

@ItzMatick

Copy link
Copy Markdown
Author

Okay, I added anotation and removed comments. Should I do something about build failure with the previous commit, or is that ok?

@Doc94

Doc94 commented Sep 18, 2026

Copy link
Copy Markdown
Member

Okay, I added anotation and removed comments. Should I do something about build failure with the previous commit, or is that ok?

I rerun the build and all looks good by the moment.

@papermc-projects papermc-projects Bot moved this from Awaiting review to Delayed approval in Paper PR Queue Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Delayed approval

Development

Successfully merging this pull request may close these issues.

3 participants