Skip to content

Hotbar

namespace Griff.Modules.BlockWorlds;
public sealed class Hotbar : Component

A row of slots along the bottom of the screen showing what the Inventory holds, with how many. Pick a slot with the number keys or the mouse wheel; a BlockBuilder puts down the picked block.

This is a component: its saved properties are on its component page.

public IReadOnlyList<string> Colors { get; set; }

Item colors for the slots, one per row: a name and a color, e.g. “Dirt #8B5A2B”. Others get a color from their name.

public int Selected { get; set; }

The picked slot, counting from 0.

public int SelectedCount { get; }

How many of the picked slot’s item it holds: the blocks left to place.

public string? SelectedItem { get; }

The item in the picked slot, or null if it’s empty.

public IReadOnlyList<ValueTuple<string, int>> Shown { get; }

What’s in each slot and how many: each item keeps its slot until it runs out, and something new takes the first empty one. An empty slot’s item is null.

public int Slots { get; set; }

How many slots it has, up to 10.

public Color ColorOf(string item)

The color of item’s slot: from Colors, or picked from its name.

public int CountOf(string item)

How many of item (e.g. “Dirt”) its slots hold. Read as “Blocks:Dirt”.

public void Next()

Picks the next slot along, as the mouse wheel does (round to the first after the last).

public void Pick(int slot = 1)

Picks slot slot, counting from 1 as the number keys do.

public void Previous()

Picks the slot before, as the mouse wheel does (round to the last before the first).