Skip to content

Comments

Add getProvidedBlock method to BlockProvider#4959

Open
ChiefArug wants to merge 5 commits intoVazkiiMods:1.20.xfrom
ChiefArug:getProvidedBlock
Open

Add getProvidedBlock method to BlockProvider#4959
ChiefArug wants to merge 5 commits intoVazkiiMods:1.20.xfrom
ChiefArug:getProvidedBlock

Conversation

@ChiefArug
Copy link

This lets people determine what a block provider provides without iterating the registry.

My plan for this is compatibility with Tinkers Construct exchanging ability, which replaces mined blocks with the block in the offhand, and adding the ability to provide blocks from things such as the black hole talisman. To replace the block Tinkers needs to know what block its placing.

This is not a breaking change to the API as the method has a default implementation, so the two published addons that implement this interface won't break.

@williewillus
Copy link
Member

What if an item wants to provide multiple types of Blocks?

@ChiefArug
Copy link
Author

It can either choose one to return, or simply return null to indicate that what it provides isn't as simple as a single block type (which is what the hand of ender does in this PR).

The intended usecase of this is for things that can consume any block and so need to be told what block to consume, so changing the return type to a list doesn't make sense for that usecase (the additional entries in the list will just end up being ignored).

@ChiefArug ChiefArug changed the title Add getProvidedBlock method to BlocKProvider Add getProvidedBlock method to BlockProvider Jan 28, 2026
@ChiefArug
Copy link
Author

Updated the javadoc to better clarify what to do if it can return multiple blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants