Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.22+] Tighten getEnchantPowerBonus to BlockGetter #1453

Open
Shadows-of-Fire opened this issue Aug 14, 2024 · 2 comments
Open

[1.22+] Tighten getEnchantPowerBonus to BlockGetter #1453

Shadows-of-Fire opened this issue Aug 14, 2024 · 2 comments
Assignees
Labels
1.21.2 Targeted at Minecraft 1.21.2 breaking change Breaks binary compatibility cleanup Change that isn't an enhancement or a bug fix

Comments

@Shadows-of-Fire
Copy link
Contributor

I have a situation where I would like to resolve the enchant power of a block but might not have access to a level (i.e. in a tooltip).

Currently, the best attempt is to make a fake LevelReader which returns reasonable results from the methods one might expect someone to call, and catching any exceptions. I think there's no reason this method needs access to the full LevelReader and would be sufficiently executable with just BlockGetter (which also makes providing an "empty" level easier).

The most common case is resolving the BlockEntity or the states of nearby blocks, both of which are possible through BlockGetter. I don't see the additional context of LevelReader being useful here whatsoever.

@Shadows-of-Fire Shadows-of-Fire added cleanup Change that isn't an enhancement or a bug fix breaking change Breaks binary compatibility 1.21.2 Targeted at Minecraft 1.21.2 labels Aug 14, 2024
@Shadows-of-Fire Shadows-of-Fire self-assigned this Aug 14, 2024
@Technici4n
Copy link
Member

We could make the level @Nullable as an alternative.

@Shadows-of-Fire
Copy link
Contributor Author

I think it's unreasonable to expect implementers to have to deal with a @Nullable level (since it pushes the burden of a null check on everyone else) - but BlockGetter should provide all context that could be reasonably necessary without impacting implementers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.2 Targeted at Minecraft 1.21.2 breaking change Breaks binary compatibility cleanup Change that isn't an enhancement or a bug fix
Projects
None yet
Development

No branches or pull requests

2 participants