Skip to content

Hooks & Integrations

Vaan1310 edited this page Jan 19, 2026 · 10 revisions

Cannons works together with other plugins:

  • Movecraft support to have ships with cannons
  • Vault to allow prices for cannons buying cannons
  • Placeholder API support
  • Allows to define cannon schematics with WorldEdit
  • Hooks for custom block handling

Movecraft

This is for 3.4.3+, as most of the tags are new.
In addition to allowing cannons to move correctly on crafts, we also define a custom tag usable in your .craft files:
Note: the designID is the filename of the design

Max and Min cannons

maxCannons:
    <designID>: <quantity>
    [<design1>,<design2>,<design3> ...]: <quantity>

minCannons:
    <designID>: <quantity>
    [<design1>,<design2>,<design3> ...]: <quantity>

Examples:

maxCannons:
    6 inch: N1 # only one allowed
    Basic cannon: 0.01 # maximum one per hundred blocks
    [classic, ironCannon]: N3 # the sum of the classic and ironCannon cannons cannot exceed 3

minCannons:
    6 inch: N1 # at least one allowed
    Basic cannon: 0.01 # at least one per hundred blocks
    [classic, ironCannon]: N3 # the sum of the classic and ironCannon cannons must be at least 3 or above

Mass limits

Each cannon design has a massOfCannon setting in its yml definition, that is the mass of the cannon, you can set limits of mass on the ships

maxMass: <int>
minMass: <int>
excludeFromMass: # String list
    - "<design1>"
    - "<design2>"
    - ...

Examples

maxMass: 700 # sum of all cannon masses CAN'T exceed 700
minMass: 100 # sum of all cannons masses MUST exceed or be equal to 100
excludeFromMass: # Don't count the mass of classic cannons
    - "classic"

A more complex example can be:

maxCannons:
    [classic, ironCannon]: N6 # the player can decide 2 more cannons to add either ironCannons or classic cannons

minCannons:
    classic: N2
    ironCannon: N2

maxMass: 700
minMass: 100
excludeFromMass: # handle this in max/min cannons 
    - "classic"
    - "ironCannon"

Other

useShipAngles: <boolean> # if true and on a ship, use ship angles instead (settings like: "maxHorizontalAngleOnShip"), default value is false

Placeholder API

The current placeholder return data regarding the player's aimed cannon, new placeholder suggestions are welcome.

cannons_name: Fetches and returns the name of the cannon being operated on.
cannons_design: Retrieves the cannon's design name and identifies its model or structure.
cannons_horizontal_angle: Returns the horizontal angle (yaw) at which the cannon is oriented.
cannons_vertical_angle: Returns the vertical angle (pitch) of the cannon's orientation.
cannons_temperature: Provides the cannon's temperature.
cannons_loaded_gunpowder: Indicates how much gunpowder is loaded into the cannon for firing.
cannons_loaded_projectile:
  
    Checks if there is a projectile loaded in the cannon.
    If no projectile is loaded or an error occurs, it returns "None."
    If a projectile is loaded, it checks for a custom name and uses it if available.
    Otherwise returns the material name.

Clone this wiki locally