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 108
    • Issues 108
    • 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

Last edited by Ticxo Sep 29, 2023
Page history

Custom Mount Controller

A mount controller is a per-entity Modeled Entity movement controller that is required when mounting an entity to a model. By default, Model Engine provides 4 common controllers, but you can add your own to create custom controlling behavior. Read this page 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.

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.

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.

// On plugin start-up
ModelEngineAPI.getMountControllerTypeRegistry().register("custom_controller", CustomMountController.CUSTOM);
Clone repository
Home
FAQ / Common Issues
Commands & Permissions
Configuration

Modeling
  • Creating a Model
    • Hitbox & Eye Height
    • Shadow
  • Bone Behaviors
    • Player Limbs
  • Animating a Model
  • Importing a Model
  • Scriptable Keyframes
  • Optional Tools
MythicMobs
  • Mechanics
  • Conditions
  • Targeters
Citizens (R4.0.4)
  • Trait
  • Commands & Permissions

API
  • Basic
    • Apply / Remove Model
    • Play / Stop Animation
    • Configure Bone Behaviors
    • Mounting / Dismounting Model
    • 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
Promotional Material