Mount Controllers Not Working Properly
Code I am using:
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Player p = event.getPlayer();
Entity e = event.getRightClicked();
ModeledEntity modeled = ModelEngineAPI.getModeledEntity(e);
if(modeled != null){
for(ActiveModel m : modeled.getModels().values()){
m.getMountManager().ifPresent(mountManager -> {
mountManager.mountDriver(p, Turret.MOUNT_CONTROLLER);
//I've also tried using the default mount controllers MEG provides.
});
//There's only 1 model on the entity I am using, so just break on the first iteration.
break;
}
}
}
//Turret.MOUNT_CONTROLLER code:
public class CustomMountController extends AbstractMountController {
public CustomMountController(Entity entity, Mount mount) {
super(entity, mount);
}
public void updateDriverMovement(MoveController controller, ActiveModel model) {
//message never gets sent.
Bukkit.broadcast(Component.text("test"));
Optional<?> mount = model.getMountManager();
if (mount.isPresent()) {
if(!(mount.get() instanceof BehaviorManager manager)) return;
if (this.input.isSneak()) {
((MountManager)manager).dismountDriver();
}
}
}
@Override
public void updateDirection(LookController controller, ActiveModel model) {
//message never gets sent.
Bukkit.broadcast(Component.text("rotate"));
super.updateDirection(controller, model);
}
public void updatePassengerMovement(MoveController controller, ActiveModel model) {
//message never gets sent.
Bukkit.broadcast(Component.text("test"));
Optional<?> mount = model.getMountManager();
if (mount.isPresent()) {
if(!(mount.get() instanceof BehaviorManager manager)) return;
if (this.input.isSneak()) {
((MountManager)manager).dismountPassenger(this.entity);
}
}
}
}
Whenever a player interacts with the model and gets in the driver seat, they're not able to dismount off of the entity. The player also has no control over the entity's rotation. I've tried using the custom mount controller stated above and MountControllerTypes.WALKING
- neither work correctly. The updateDriverMovement, updateDirection, and updatePassengerMovement functions never seem to get called.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information