Fabric API

Fabric API

108M Downloads

Fake Player API

zml2008 opened this issue ยท 5 comments

commented

It seems there are a few mods that use some sort of 'fake player' system in order to allow non-player actors to interact with the world. However, I've seen several implementations of this system that fail to replicate vanilla contracts of real players, causing conflicts with one of my mods.

By having one single fake player implementation in Fabric API, there would be only one set of quirks that mod developers would have to be aware of. Fabric API could also reasonably choose ways to alter the vanilla contracts if necessary to support a fake player system, in ways that other mods would have trouble getting away with.

Original issue: gnembon/fabric-carpet#1142
Another issue at the same point, caused by another incomplete fake player implementation: KyoriPowered/adventure-platform-mod#14

@altrisi @gnembon @TropheusJ what do you think about a Fabric API-based solution for your fake player systems?

commented

It is difficult to get them right, so IMO it is a reasonable API addition. It should also handle initializing/adjusting the state to the specific use like setting the fake player's position, maybe through the method yielding the fake player instances.

commented

The ultimate solution still lies in Mojang splitting up the player functionalities into more dedicated hierarchies seen in plugin APIs or the vanilla interface classes for their dimensions, and making methods use these less specific interfaces.

commented

There are many things Mojang could do better -- but given the amount of work involved in fixing this properly, I doubt mojang would do it unless they had Vanilla gameplay elements that justified the work. In the meantime, fake players are in use today as the 'standard' solution.

commented

What about just checking for ServerPlayerEntity subclasses? That sounds a lot simpler than advanced mocking of 10 classes.

https://github.com/AppliedEnergistics/Applied-Energistics-2/blob/97906c4a0e0a60d42685cbbc643c783606995e44/src/main/java/appeng/util/FakePlayer.java#L42

commented

See #3005.