Skip to main content

API

The API is in the me.zombie_striker.qav.api package. QualityArmoryVehicles is the entry point, with static methods for every feature. Add QualityArmoryVehicles to the depend or softdepend list of your plugin.yml so your plugin loads after it.

Events

The me.zombie_striker.qav.api.events package has Bukkit events you can listen to: VehicleHitchEvent and VehicleUnhitchEvent can be cancelled. They give you the vehicle, the animal, the player (it can be null for an unhitch that no player started) and the index of the hitch point.

Hitboxes and seats

These methods were added in 2.6: A HitResult gives you the vehicle, the distance, the point in world and local coordinates, and the seat at that point.

Carriages

Custom attachments

Attachments are extra model parts that follow a vehicle. The built-in types are Wheel and Turret, and you can add your own.

1. Create the attachment

Extend me.zombie_striker.qav.attachments.Attachment. You must implement animate. You can also override the other methods: Each vehicle stores the state of its attachments in an AttachmentState, from vehicle.getAttachmentState(index). It has fields for yaw, spin, the last shot and the last input, and getData() for your own values.

2. Register the type

Register a type to use the attachment in the attachments section of the vehicle files. The factory gets the common options already read (name, id, material and position) and the section of the attachment for your own options. Throw an IllegalArgumentException if an option is not valid: the message is shown in the console.
The type name is not case-sensitive. You can register it at any time: vehicles that are already loaded and use the type are updated. Registering a type that already exists throws an IllegalArgumentException.

3. Use it in a vehicle file

The seat option sets which seat sends its keys to onInput: driver, none or a passenger seat index.

Adding an attachment from code

You can also add an attachment to a vehicle type directly:
Spawned vehicles get the attachment on their next tick. Attachments added this way are lost when the vehicles are reloaded, so register a type if the attachment should stay.

Folia

On Folia, each vehicle is ticked by the region that owns it. The update, animate and onInput methods of your attachments run on that region’s thread, so only touch entities and blocks near the vehicle from them.