mc

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mc implements facilities for detecting and working with Minecraft instances.

Index

Constants

View Source
const (
	StMenu    int = iota // Main menu
	StDirt               // Dirt world generation screen
	StPreview            // World preview
	StIdle               // World generation finished
	StIngame             // Currently being played
)

The set of possible states an instance can be in.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	InstanceInfo
	// contains filtered or unexported fields
}

Instance represents a single Minecraft instance and takes care of reading its log file and performing actions on it.

func NewInstance added in v0.4.0

func NewInstance(info InstanceInfo, conf *cfg.Profile, x *x11.Client) Instance

NewInstance creates a new Instance from the given instance information.

func (*Instance) Click added in v0.4.0

func (i *Instance) Click() error

Click clicks on the instance's window.

func (*Instance) Focus added in v0.4.0

func (i *Instance) Focus()

Focus focuses the instance's window. If an error occurs, it will be logged.

func (*Instance) FocusAndUnpause added in v0.4.0

func (i *Instance) FocusAndUnpause(timestamp xproto.Timestamp, idle bool)

FocusAndUnpause focuses the instance's window and then unpauses if the user has set `unpause_on_focus` in their config. If an error occurs, it will be logged.

func (*Instance) PressEsc added in v0.4.0

func (i *Instance) PressEsc(timestamp xproto.Timestamp)

PressEsc presses escape to [un]pause the instance. If an error occurs, it will be logged.

func (*Instance) PressF3 added in v0.4.0

func (i *Instance) PressF3(timestamp xproto.Timestamp)

PressF3 presses F3 to hide the pie chart.

func (*Instance) PressF3Esc added in v0.4.0

func (i *Instance) PressF3Esc(timestamp xproto.Timestamp)

PressF3Esc presses F3+Escape to pause the instance without the pause menu. If an error occurs, it will be logged.

func (*Instance) Reset

func (i *Instance) Reset(timestamp xproto.Timestamp)

Reset presses the instance's reset key. If an error occurs, it will be logged.

func (*Instance) Stretch added in v0.4.0

func (i *Instance) Stretch(conf cfg.Profile) error

Stretch stretches the instance's window.

func (*Instance) Unstretch added in v0.4.0

func (i *Instance) Unstretch(conf cfg.Profile) error

Unstretch resizes the window back to its normal dimensions.

type InstanceInfo added in v0.4.0

type InstanceInfo struct {
	Id       int           // Instance number
	Pid      uint32        // Process ID
	Wid      xproto.Window // Window ID
	Dir      string        // .minecraft directory
	Version  int           // Minecraft version
	ResetKey x11.Key       // Atum reset key
}

InstanceInfo contains information about how to interact with a Minecraft instance, such as its game directory and window ID.

func FindInstances added in v0.4.0

func FindInstances(x *x11.Client) ([]InstanceInfo, error)

FindInstances returns a list of all running Minecraft instances.

type InstanceState

type InstanceState struct {
	State    int // Current state of the instance
	Progress int // World generation progress (0 to 100)
}

InstanceState contains information about the current state of the instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL