launcher

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package launcher provides the necessary functions to start the game.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsoleRunner

func ConsoleRunner(cmd *exec.Cmd) error

An ConsoleRunner is an implementation of Runner which logs game output to the console.

func DoesInstanceExist added in v1.3.0

func DoesInstanceExist(name string) bool

DoesInstanceExist reports whether an instance with the specified name exists.

func Launch

func Launch(launchEnv LaunchEnvironment, runner Runner) error

Launch starts a LaunchEnvironment with the specified runner.

The Java executable is checked and the classpath and command arguments are finalized.

func RemoveInstance

func RemoveInstance(name string) error

RemoveInstance removes the instance with the specified name.

Types

type AssetsResolvedEvent

type AssetsResolvedEvent struct {
	Total int
}

AssetsResolvedEvent is called when all game assets have been identified and filtered.

type DownloadingEvent

type DownloadingEvent struct {
	Completed int
	Total     int
}

DownloadingEvent is called when a download has progressed.

type EventWatcher

type EventWatcher func(event any)

An EventWatcher is a controller that can handle multiple types of events.

type Instance

type Instance struct {
	Name          string         `toml:"-" json:"-"`
	GameVersion   string         `toml:"game_version" json:"game_version"`
	Loader        meta.Loader    `toml:"mod_loader" json:"mod_loader"`
	LoaderVersion string         `toml:"mod_loader_version,omitempty" json:"mod_loader_version,omitempty"`
	Config        InstanceConfig `toml:"config" json:"config"`
}

An Instance represents a full installation of Minecraft and its information.

func CreateInstance

func CreateInstance(options InstanceOptions) (Instance, error)

CreateInstance creates a new instance with the specified options.

func FetchAllInstances added in v1.1.0

func FetchAllInstances() ([]Instance, error)

FetchAllInstances retrieves all valid instances within the instance directory.

func FetchInstance added in v1.1.0

func FetchInstance(name string) (Instance, error)

FetchInstance retrieves the instance with the specified name.

func (Instance) Dir

func (inst Instance) Dir() string

Dir returns the instance's directory

func (Instance) NativesDir added in v1.6.1

func (inst Instance) NativesDir() string

NativesDir returns the path to the instance's natives extraction directory.

func (*Instance) Rename added in v1.1.0

func (inst *Instance) Rename(new string) error

Rename renames instance to the specified new name

func (Instance) WriteConfig added in v1.1.0

func (inst Instance) WriteConfig() error

WriteConfig writes the instances configuration to its configuration file.

The Name field is ignored, as it is based on the instance's directory.

type InstanceConfig

type InstanceConfig struct {
	WindowResolution struct {
		Width  int `toml:"width" json:"width"`
		Height int `toml:"height" json:"height"`
	} `toml:"resolution" json:"resolution"                comment:"Game window resolution"`
	Java      string `toml:"java" json:"java"             comment:"Path to a Java executable. If blank, a Mojang-provided JVM will be downloaded."`
	JavaArgs  string `toml:"java_args" json:"java_args"   comment:"Extra arguments to pass to the JVM"`
	CustomJar string `toml:"custom_jar" json:"custom_jar" comment:"Path to a custom JAR to use instead of the normal Minecraft client"`
	MinMemory int    `toml:"min_memory" json:"min_memory" comment:"Minimum game memory, in MB"`
	MaxMemory int    `toml:"max_memory" json:"max_memory" comment:"Maximum game memory, in MB"`
}

InstanceConfig represents the configurable values of an Instance.

type InstanceOptions

type InstanceOptions struct {
	Name          string
	GameVersion   string
	Loader        meta.Loader
	LoaderVersion string

	Config InstanceConfig
}

InstanceOptions are options used to designate an instance's version and other parameters on creation.

type LaunchEnvironment added in v1.1.0

type LaunchEnvironment struct {
	GameDir   string
	Java      string
	MainClass string
	Classpath []string
	JavaArgs  []string
	GameArgs  []string
}

A LaunchEnvironment represents the information needed to start the game.

func Prepare

func Prepare(inst *Instance, options LaunchOptions, watcher EventWatcher) (LaunchEnvironment, error)

Prepare prepares the instance to be launched, returning a LaunchEnvironment, with the provided options and sends events to watcher.

type LaunchOptions added in v1.2.0

type LaunchOptions struct {
	Session auth.Session

	InstanceConfig
	QuickPlayServer    string
	QuickPlayWorld     string
	Demo               bool
	DisableMultiplayer bool
	DisableChat        bool
	// contains filtered or unexported fields
}

LaunchOptions represents configuration options when preparing an instance to be launched.

type LibrariesResolvedEvent

type LibrariesResolvedEvent struct {
	Total int
}

LibrariesResolvedEvent is called when all game libraries have been identified and filtered.

type MetadataResolvedEvent added in v1.1.0

type MetadataResolvedEvent struct{}

MetadataResolvedEvent is called when all metadata has been retrieved

type PostProcessingEvent added in v1.3.0

type PostProcessingEvent struct{}

PostProcessingEvent is called when, usually Forge, pre-processing begins.

type Runner

type Runner func(cmd *exec.Cmd) error

A Runner is a controller which manages the starting of the game.

Jump to

Keyboard shortcuts

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