Skip to main content

BasicMachine

info

BasicMachine is the foundational class of Dorios Machinery Core.

It provides the base infrastructure required for machine logic including:

  • machine entity access
  • inventory container access
  • progress tracking
  • energy integration
  • refresh‑speed tick validation

Both higher level machine classes extend this base:

BasicMachine
├─ Machine
└─ Generator

Index

Properties


Methods


Constructor

new BasicMachine

new BasicMachine(block: Block, rate: number)

Creates a new machine instance bound to a machine block.

Parameters

  • blockBlock

    The block representing the machine in the world.

  • ratenumber

    Base energy processing rate defined by the machine configuration.


Properties

entity

Type: Entity

Reference to the machine entity associated with the block.

const entity = machine.entity

This entity stores runtime machine data such as:

  • dynamic properties
  • progress values
  • machine inventory

block

Type: Block

Block representing the machine in the world.

const block = machine.block

Used for block state manipulation and machine visuals.


dimension

Type: Dimension

Dimension where the machine exists.

const dimension = machine.dimension

Useful when interacting with nearby entities or spawning items.


container

Type: Container

Inventory container attached to the machine entity.

const container = machine.container

Used for:

  • input items
  • output items
  • UI display items

energy

Type: EnergyStorage

Energy manager associated with the machine.

const energy = machine.energy

Handles:

  • energy capacity
  • energy transfer
  • energy UI display

baseRate

Type: number

Base processing rate defined by the machine configuration.

const baseRate = machine.baseRate

This value represents the energy or progress rate per tick, assuming normal Minecraft tick speed.

Example:

baseRate = 20

Means the machine processes 20 units per tick.


rate

Type: number

Effective processing rate used internally by the machine.

const rate = machine.rate

The rate is automatically scaled using the addon's refresh speed.

rate = baseRate * tickSpeed

Example:

baseRate = 20
tickSpeed = 20
rate = 400

This ensures machines keep the same behavior even when the addon processes logic less frequently.


valid

Type: boolean

Indicates whether the machine should process logic during the current tick.

const valid = machine.valid

The machine becomes invalid if:

  • the machine entity cannot be found
  • the current tick is skipped due to refresh‑speed optimization

Typical usage:

if (!machine.valid) return

Methods

setRate

setRate(baseRate: number): void

Updates the machine base rate and recalculates the effective rate.

Parameters

  • baseRatenumber

    New base processing rate.


setLabel

setLabel(text: string, slot?: number): void

Displays a label inside the machine inventory using a placeholder item.

Parameters

  • textstring

    Text displayed in the label.

  • slotnumber

    Inventory slot used for the label.


addProgress

addProgress(amount: number, index?: number): void

Adds progress to the machine.

Parameters

  • amountnumber

    Amount of progress added to the machine.

  • indexnumber

    Optional progress index used when machines track multiple progress values.


getProgress

getProgress(index?: number): number

Returns the current progress value stored in the machine.

Parameters

  • indexnumber

    Progress index to retrieve.


setProgress

setProgress(value: number, options?: object): void

Sets the machine progress value and optionally updates the visual progress bar.

Parameters

  • valuenumber

    New progress value.

  • optionsobject

    Optional display configuration.

    Supported options:

    slot?: number
    type?: string
    display?: boolean
    index?: number

Options

  • slotnumber

    Inventory slot used to render the progress item.

  • typestring

    Texture type used for the progress indicator.

    Example:

    arrow_right
    arrow_left
  • displayboolean

    Whether the progress bar should update visually.

  • indexnumber

    Progress index used when multiple progress bars exist.


displayProgress

displayProgress(maxValue: number, options?: object): void

Displays the machine progress visually inside the machine inventory.

Parameters

  • maxValuenumber

    Maximum progress value used to normalize the visual scale.

  • optionsobject

    Display configuration options.

    slot?: number
    type?: string
    index?: number
    scale?: number

Options

  • slotnumber

    Inventory slot used to display the progress item.

  • typestring

    Progress bar texture identifier.

  • indexnumber

    Progress index to read from.

  • scalenumber

    Maximum visual progress scale.

    Example:

    scale = 16

    Creates a progress bar with 16 visual steps.


displayEnergy

displayEnergy(slot?: number): void

Displays the current machine energy using EnergyStorage.display().

Parameters

  • slotnumber

    Inventory slot used to display the energy bar.


blockSlots

blockSlots(slots: number[]): void

Blocks inventory slots using a placeholder item.

Parameters

  • slotsnumber[]

    Array of slot indices to block.


unblockSlots

unblockSlots(slots: number[]): void

Removes placeholder items used for blocked slots.

Parameters

  • slotsnumber[]

    Array of slot indices to unblock.


Example

const machine = new BasicMachine(block, 20)

if (!machine.valid) return

machine.displayEnergy()

machine.addProgress(machine.rate)

if (machine.getProgress() >= 200) {
machine.setProgress(0)
}

Notes

BasicMachine is designed as the core infrastructure class of Dorios Machinery Core.

Higher‑level machine behavior is implemented in:

  • Machine
  • Generator