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

Improve compatibility of dispensersToggleThings by optionally using Fabric API's stub players #302

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

altrisi
Copy link
Collaborator

@altrisi altrisi commented Jul 25, 2023

Supersedes #283.

This PR makes Carpet Extra use Fabric API's new stub players (confusingly called FakePlayer in the API) for dispensersToggleThings if the API is available. Otherwise, it keeps using null and handling null where vanilla doesn't.

The API access is done via a constant MethodHandle that will directly either call the api or return null. Constant MethodHandles can even be inlined to a plain call, so this should ensure no performance loss vs directly calling the api.

Vs #283, this:

  • Uses a standard API for doing this, which is likely to further increase compatibility
  • Respects that a player has properties like the World and not have the same for all dimensions in all worlds joined (singleplayer)
  • Doesn't make us reimplement a stub player that may have many methods a mod would want to use that we'd have to patch
  • Leaks a lot more! I've found a bug on fapi where creating one of these will make its world leak forever, and given we're now respecting what world they're in, they'll all be leaked! Yay!

I'll hold on merging until this last point is resolved in Fabric API, but otherwise this is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant