-
Notifications
You must be signed in to change notification settings - Fork 9
Morph API
The goal of this page is to show how to interact with the code of this mod via Java. If you want to instead write a datapack, you should take a look at File Layouts and [Datapack Overview](https://github.com/Budschie/BudschieMorphMod/wiki/Datapack-Overview
There are currently a bunch of ways to interact with this mod.
For example, there is the class MorphUtil: It contains a bunch of useful utils related to this mod. If you want to automatically morph the player to an entity, calling MorphUtil.morphToServer is your best bet, just make sure to insert a if(!level.isClientSide()) check to make sure that this method is indeed only being called on the logical server side.
There are also a bunch of events dedicated to handle morphing. For a full list of them, just look into the class PlayerMorphEvent. If you want to prevent a player from morphing, this is probably the best event for this kind of thing.
If your goal is to modify the creation of morphs which is not covered by data transformers and morph_nbt files, use the MorphCreatedFromEntityEvent.
There is also the AcquiredMorphEvent to hook into the behavior of acquiring morphs.
To render the morph instead of the player, a proxy entity representing the morph is being created. You can use the InitializeMorphEntityEvent, which is being fired solely on the logical (and therefor also physical) client side whenever a proxy entity has been created out of a morph, to modify this entity on creation.
If you want to change certain data of the proxy entity on a per-tick basis, create a class and implement the IEntitySynchronizer interface. Then, after filling this class with code accordingly (the JavaDoc of this interface is your best guide here), register the synchronizer on the FMLClientSetupEvent event by calling the thread-safe method EntitySynchronizerRegistry.addEntitySynchronizer.