Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
Model Engine 4 Model Engine 4
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 112
    • Issues 112
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • MythicCraft
  • Model Engine 4Model Engine 4
  • Wiki
    • Api
    • Advanced
  • Custom Mount Controller

Custom Mount Controller · Changes

Page history
Update Custom-Mount-Controller.md authored Sep 29, 2023 by Ticxo's avatar Ticxo
Show whitespace changes
Inline Side-by-side
Showing with 73 additions and 1 deletion
+73 -1
  • API/Advanced/Custom-Mount-Controller.md API/Advanced/Custom-Mount-Controller.md +73 -1
  • No files found.
API/Advanced/Custom-Mount-Controller.md
View page @ 335a7eec
WIP A mount controller is a per-entity Modeled Entity movement controller that is required when mounting an entity to a
\ No newline at end of file model. By default, Model Engine provides 4 common controllers, but you can add your own to create custom controlling
behavior. Read [this page](/Technical/Mount-Controllers) for more information on the default controllers.
## Creating a controller class
All controller class must implement `MountController` class, but you can also extend the `AbstractMountController`
instead, which provides implementations on some basic and generic functionalities. In this example, we will
use `AbstractMountController`.
```java
public class CustomMountController extends AbstractMountController {
// Type class used to specify the controller when mounting entity
// NEVER SUPPLY A STATIC INSTANCE
public static final MountControllerType CUSTOM = new MountControllerType(CustomMountController::new);
public CustomMountController(Entity entity, Mount mount) {
super(entity, mount);
}
@Override
public void updateDriverMovement(MoveController controller, ActiveModel model) {
// Update function for driver
}
@Override
public void updatePassengerMovement(MoveController controller, ActiveModel model) {
// Update function for passengers
}
}
```
### Using MoveController
The supplied `MoveController` object is a wrapper for the NMS `MoveControl` class. It contains numerous functions useful
for controlling the entity, many of which calls back directly to the base NMS method.
### Getting Inputs
Inputs are updated every movement tick, and can be obtained through `getInput()` method. The returned object contains
WASD, Jump and Sneak inputs.
### Caveats
In order for this system to work on most entities and have the movements be calculated correctly, while also altering
Minecraft's default movement handling code as little as possible, the system will not work under these conditions:
* The base entity is not a `Mob` (so armor stands will not work)
* The base entity has no AI
* The base entity never ticks
## Using the controller
Similar to mounting with default controllers, you mount with your own `MountControllerType`.
```java
ActiveModel model=...
model.getMountManager().ifPresent(mountManager -> {
mountManager.mountDriver(entity, CustomMountController.CUSTOM);
});
```
## Registering the controller
While technically optional, it is generally advised to register your custom controller into
the `MountControllerTypeRegistry` as this will allow you to use the controller with MythicMobs as well.
```java
// On plugin start-up
ModelEngineAPI.getMountControllerTypeRegistry().register("custom_controller", CustomMountController.CUSTOM);
```
\ No newline at end of file
Clone repository
Home
FAQ / Common Issues
Commands & Permissions
Configuration
Modeling
  • Creating a Model
    • Hitbox & Eye Height
    • Shadow
  • Bone Behaviors
  • Animating a Model
  • Importing a Model
  • Scriptable Keyframes
MythicMobs
  • Mechanics: Model
  • Mechanics: VFX
  • Conditions
  • Targeters
API
  • Basic
    • Apply / Remove Model
    • Play / Stop Animation
    • Configure Bone Behaviors
    • Per-Player Model
    • Events
  • Advanced
    • Custom Base Entity
    • Custom Mount Controller
    • Custom Importer
    • Custom Bone Behaviors
    • Custom Script Reader
    • Custom Timeline
    • Custom Animation Handler
    • Custom Render Type
Technical
  • Terminology
  • Animation Systems
  • Mount Controllers