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.
Supersedes #283.
This PR makes Carpet Extra use Fabric API's new stub players (confusingly called
FakePlayer
in the API) fordispensersToggleThings
if the API is available. Otherwise, it keeps usingnull
and handlingnull
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:
I'll hold on merging until this last point is resolved in Fabric API, but otherwise this is ready.