Skip to main content

Radial Menu (Entity Action Type)

Opens a radial menu on the player's screen. Each slice runs an entity action when it is picked, which lets one keybind offer a set of choices instead of a single ability.

Type ID: apoli:radial_menu

Fields

FieldTypeDefaultDescription
entriesarray of entry objectsrequiredThe slices, in order. See below.
sprite_locationIdentifieroptionalA texture used for the menu's own background sprites.

Entry fields

FieldTypeDefaultDescription
entity_actionEntity Action TyperequiredWhat picking this slice does.
conditionEntity Condition TypeoptionalChecked when the menu opens. A slice whose condition fails is left out of the menu entirely, and the remaining slices close up around the gap.
itemItem StackoptionalAn item drawn as the slice's icon.
iconIdentifieroptionalA texture drawn as the icon instead of an item.
highlight_icon_textureIdentifieroptionalThe icon used while the slice is hovered.
button_textureIdentifieroptionalThe slice's background.
highlight_button_textureIdentifieroptionalThe background while hovered.
tooltipText ComponentoptionalText shown while hovered.
distanceInteger-1How far from the centre the slice sits, in pixels. -1 uses the default.
velocityInteger-1How quickly the slice animates outward. -1 uses the default.
button_width, button_heightInteger16, 20The slice size in pixels.
icon_width, icon_heightInteger16The icon size.
item_width, item_heightInteger16The item icon size.
offset_xInteger0Pixels to shift the slice right of where the ring puts it. Negative moves it left.
offset_yInteger0Pixels to shift the slice down. Negative moves it up. This is what lets a menu take a shape other than a flat circle.
angleFloatevenly spacedThe slice's own angle around the centre, in degrees, with 0 pointing right and angles increasing clockwise. Set it on every entry to build an arc, a column or a cross instead of a full ring.

Closing the menu

Picking a slice closes the menu, and so do Esc and the inventory key. When a key press opened the menu, such as an apoli:action_on_key_press, pressing that key again closes it too, the way the inventory key opens and closes the inventory. A menu opened by picking a slice of another menu closes on the same key as the first one.

The key has to be let go before it can close the menu, so the press that opened it never closes it straight away, even while it is held down. In the same way, the press that closes the menu doesn't open it again.

Example

One keybind, three elemental choices:

{
  "type": "apoli:action_on_key_press",
  "key": { "key": "key.origins.primary_active" },
  "cooldown": 40,
  "entity_action": {
    "type": "apoli:radial_menu",
    "entries": [
      {
        "item": { "id": "minecraft:blaze_powder" },
        "tooltip": { "translate": "mypack.menu.fire" },
        "entity_action": { "type": "apoli:set_on_fire", "duration": 4 }
      },
      {
        "item": { "id": "minecraft:snowball" },
        "tooltip": { "translate": "mypack.menu.frost" },
        "entity_action": { "type": "apoli:freeze", "duration": 140 }
      },
      {
        "item": { "id": "minecraft:feather" },
        "tooltip": { "translate": "mypack.menu.leap" },
        "entity_action": { "type": "apoli:add_velocity", "y": 1.2, "space": "local" }
      }
    ]
  }
}

Laying the menu out by hand

distance moves a slice away from the centre along its own spoke, offset_x and offset_y move it anywhere after that, and angle decides which spoke it sits on in the first place. The offsets follow the same opening animation as distance, so a moved slice still flies out from the middle instead of snapping into place.

A three-slice arc across the top of the screen, with the middle slice a little higher than the others:

{
  "type": "apoli:radial_menu",
  "entries": [
    { "angle": 225, "distance": 60, "offset_y": -10, "item": {"id": "minecraft:blaze_powder"},
      "entity_action": {"type": "apoli:set_on_fire", "duration": 4} },
    { "angle": 270, "distance": 60, "offset_y": -24, "item": {"id": "minecraft:snowball"},
      "entity_action": {"type": "apoli:freeze", "duration": 140} },
    { "angle": 315, "distance": 60, "offset_y": -10, "item": {"id": "minecraft:feather"},
      "entity_action": {"type": "apoli:add_velocity", "y": 1.2, "space": "local"} }
  ]
}
warning

The choice is made on the client and confirmed by the server, so a slice whose action the player shouldn't be able to run still needs its own condition.