Documentation ¶
Index ¶
- Variables
- type Instance
- func (i *Instance) AreDependenciesOutdated() (bool, error)
- func (i *Instance) AreRequirementsOutdated() (bool, error)
- func (i *Instance) AssetsDir() string
- func (i *Instance) BuildLaunchCmd(opts *LaunchOptions) (*exec.Cmd, error)
- func (i *Instance) BuildMod() *exec.Cmd
- func (i *Instance) CopyLocalSaves() error
- func (i *Instance) CopyOverwrites() error
- func (i *Instance) Desc() string
- func (i *Instance) EnsureDependencies(ctx context.Context) error
- func (i *Instance) FindMissingAssets(man *minecraft.LaunchManifest) ([]minecraft.AssetObject, error)
- func (i *Instance) FindMissingDependencies() ([]*manifest.DependencyLock, error)
- func (i *Instance) FindMissingLibraries(man *minecraft.LaunchManifest) (minecraft.Libraries, error)
- func (i *Instance) FindModJar() ([]MatchedJar, error)
- func (i *Instance) GetLaunchManifest() (*minecraft.LaunchManifest, error)
- func (i *Instance) GetResolver(ctx context.Context) (*resolver.Resolver, error)
- func (i *Instance) InstancesDir() string
- func (i *Instance) Java() (*java.Java, error)
- func (i *Instance) JavaDir() string
- func (i *Instance) Launch(opts *LaunchOptions) error
- func (i *Instance) LaunchCmd() string
- func (i *Instance) LibrariesDir() string
- func (i *Instance) LinkDependencies() error
- func (i *Instance) LockfilePath() string
- func (i *Instance) ManifestPath() string
- func (i *Instance) McDir() string
- func (i *Instance) ModsDir() string
- func (i *Instance) OverwritesDir() string
- func (i *Instance) PackageCacheDir() string
- func (i *Instance) Platform() uint8
- func (i *Instance) SaveLockfile() error
- func (i *Instance) SaveManifest() error
- func (i *Instance) UpdateLockfileDependencies(ctx context.Context) error
- func (i *Instance) UpdateLockfileRequirements(ctx context.Context) error
- func (i *Instance) VersionsDir() string
- type LaunchOptions
- type MatchedJar
- type MinecraftRelease
- type MinecraftReleaseResponse
Constants ¶
This section is empty.
Variables ¶
var ( // PlatformVanilla is a vanilla minecraft instance PlatformVanilla uint8 = 1 // PlatformFabric is a fabric minecraft instance PlatformFabric uint8 = 2 // PlatformForge is forge minecraft instance PlatformForge uint8 = 3 // ErrNoInstance is returned if no mc instance was found ErrNoInstance = &commands.CliError{ Text: "no minepkg.toml file was found in this directory", Suggestions: []string{ fmt.Sprintf("Create it with %s", gchalk.Bold("minepkg init")), "Move into a folder containing a minepkg.toml file", }, } // ErrMissingRequirementMinecraft is returned if requirements.minecraft is not set ErrMissingRequirementMinecraft = &commands.CliError{ Text: "the manifest is missing the required requirements.minecraft field", Suggestions: []string{ "Add the field as documented here https://preview.minepkg.io/docs/manifest#requirements", }, } )
var ( // ErrLaunchNotImplemented is returned if attemting to start a non vanilla instance ErrLaunchNotImplemented = errors.New("can only launch vanilla & fabric instances (for now)") // ErrNoCredentials is returned when an instance is launched without `MojangProfile` beeing set ErrNoCredentials = errors.New("can not launch without mojang credentials") // ErrNoPaidAccount is returned when an instance is launched without `MojangProfile` beeing set ErrNoPaidAccount = errors.New("you need to buy Minecraft to launch it") // ErrNoVersion is returned if no mc version was detected ErrNoVersion = errors.New("could not detect minecraft version") // ErrNoJava is returned if no java runtime is available to launch ErrNoJava = errors.New("no java runtime set to launch instance") )
var ( // TypeSnapshot is a snapshot release TypeSnapshot = "snapshot" // TypeRelease is a full "normal" release TypeRelease = "release" // TypeOldBeta is a "old_beta" release TypeOldBeta = "old_beta" // TypeOldAlpha is a "old_alpha" release TypeOldAlpha = "old_alpha" )
var ( // ErrNoFabricLoader is returned if the wanted fabric version was not found ErrNoFabricLoader = &commands.CliError{ Text: "Could not find fabric loader for wanted Minecraft version", Suggestions: []string{ "Check if fabric is compatible with the Minecraft version in your minepkg.toml", "Check your requirements.fabric field", "Try again later", }, } // ErrNoFabricMapping is returned if the wanted fabric mapping was not found ErrNoFabricMapping = &commands.CliError{ Text: "Could not find fabric mapping for wanted Minecraft version", Suggestions: []string{ "Check if fabric is compatible with the Minecraft version in your minepkg.toml", "Check your requirements.fabric field", "Try again later", }, } )
var ( ErrNoBuildFiles = &commands.CliError{ Text: "no jar files found", Suggestions: []string{ `Set the "dev.jar" field in your minepkg.toml`, `Checkout https://preview.minepkg.io/docs/manifest#devjar`, "Make sure that your build is outputing jar files", }, } )
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct { // GlobalDir contains persistent instance data // on linux this usually is $HOME/.config/minepkg GlobalDir string // CacheDir is similar to cache dir but only contains data that can easily be redownloaded // like java binaries, libraries, assets, versions & mod cache // on linux this usually is $HOME/.cache/minepkg CacheDir string // Directory is the path of the instance. defaults to current working directory Directory string Manifest *manifest.Manifest Lockfile *manifest.Lockfile MojangCredentials *mojang.AuthResponse MinepkgAPI *api.MinepkgAPI JavaFactory *java.Factory // contains filtered or unexported fields }
Instance describes a locally installed minecraft instance
func NewEmptyInstance ¶
func NewEmptyInstance() *Instance
NewEmptyInstance returns a new instance with the default settings panics if user config or cache directory can not be determined
func NewInstanceFromWd ¶
NewInstanceFromWd tries to detect a minecraft instance in the current working directory returning it, if successful
func (*Instance) AreDependenciesOutdated ¶
AreDependenciesOutdated returns true if the dependencies of this instance do not match what is currently set in the lockfile. Dependencies should be updated with "UpdateLockfileDependencies" in most cases if this is true
func (*Instance) AreRequirementsOutdated ¶
AreRequirementsOutdated returns true if the requirements of this instance do not match what is currently set in the lockfile. Requirements should be updated with "UpdateLockfileRequirements" in most cases if this is true
func (*Instance) AssetsDir ¶
AssetsDir returns the path to the assets directory it contains some shared Minecraft resources like sounds & some textures
func (*Instance) BuildLaunchCmd ¶
func (i *Instance) BuildLaunchCmd(opts *LaunchOptions) (*exec.Cmd, error)
BuildLaunchCmd returns a go cmd ready to start minecraft
func (*Instance) BuildMod ¶
BuildMod uses the manifest "dev.buildCmd" script to build this package falls back to "gradle --build-cache build"
func (*Instance) CopyLocalSaves ¶
CopyLocalSaves copies saves from the instance dir to the minecraft dir this should run BEFORE `Instance.LinkDependencies` because local saves should always have the highest priority
func (*Instance) CopyOverwrites ¶
CopyOverwrites copies everything from the instance dir (with a few exceptions) to the minecraft dir exceptions are: the minecraft folder itself and minepkg related files (manifest & lockfile)
func (*Instance) EnsureDependencies ¶
EnsureDependencies downloads missing dependencies
func (*Instance) FindMissingAssets ¶
func (i *Instance) FindMissingAssets(man *minecraft.LaunchManifest) ([]minecraft.AssetObject, error)
FindMissingAssets returns all missing assets
func (*Instance) FindMissingDependencies ¶
func (i *Instance) FindMissingDependencies() ([]*manifest.DependencyLock, error)
FindMissingDependencies returns all dependencies that are not present
func (*Instance) FindMissingLibraries ¶
FindMissingLibraries returns all missing assets
func (*Instance) FindModJar ¶
func (i *Instance) FindModJar() ([]MatchedJar, error)
FindModJar tries to find the right built mod jar
func (*Instance) GetLaunchManifest ¶
func (i *Instance) GetLaunchManifest() (*minecraft.LaunchManifest, error)
GetLaunchManifest returns the merged manifest for the instance
func (*Instance) GetResolver ¶ added in v0.0.63
func (*Instance) InstancesDir ¶
InstancesDir returns the path to the "global" instances directory
func (*Instance) Launch ¶
func (i *Instance) Launch(opts *LaunchOptions) error
Launch will launch the minecraft instance prefer BuildLaunchCmd if you need more control over the process
func (*Instance) LibrariesDir ¶
LibrariesDir returns the path to the libraries directory contains libraries needed to load minecraft
func (*Instance) LinkDependencies ¶
LinkDependencies links or copies all missing dependencies into the mods folder
func (*Instance) LockfilePath ¶
LockfilePath is the path to the `minepkg-lock.toml`. The file does not necessarily exist
func (*Instance) ManifestPath ¶
ManifestPath is the path to the `minepkg.toml`. The file does not necessarily exist
func (*Instance) McDir ¶
McDir is the path where the actual Minecraft instance is living. This is the `minecraft` subfolder this folder contains saves, configs & mods that should be loaded
func (*Instance) ModsDir ¶
ModsDir is the path where the mods get linked to. This is the `minecraft/mods` subfolder
func (*Instance) OverwritesDir ¶
OverwritesDir is the path where overwrite files reside in. They get copied to `McDir` on launch. This is the `overwrites` subfolder
func (*Instance) PackageCacheDir ¶
PackageCacheDir returns the path to the cache directory. contains downloaded packages (mods & modpacks)
func (*Instance) SaveLockfile ¶
SaveLockfile saves the lockfile to the current directory
func (*Instance) SaveManifest ¶
SaveManifest saves the manifest to the current directory
func (*Instance) UpdateLockfileDependencies ¶
UpdateLockfileDependencies resolves all dependencies
func (*Instance) UpdateLockfileRequirements ¶
UpdateLockfileRequirements updates the internal lockfile manifest with `VanillaLock`, `FabricLock` or `ForgeLock` containing the resolved requirements (semver requirement to actual version)
func (*Instance) VersionsDir ¶
VersionsDir returns the path to the versions directory
type LaunchOptions ¶
type LaunchOptions struct { LaunchManifest *minecraft.LaunchManifest // SkipDownload will NOT download missing assets & libraries SkipDownload bool // Offline is not implemented Offline bool Java string Server bool // Demo launches the client in demo mode. should have no effect on a server Demo bool // JoinServer can be a server address to join after startup JoinServer string // StartSave can be a savegame name to start after startup StartSave string Debug bool // RamMiB can be set to the amount of ram in MiB to start Minecraft with // 0 determins the amount by modcount + available system ram RamMiB int }
LaunchOptions are options for launching
type MatchedJar ¶ added in v0.0.62
type MatchedJar struct {
// contains filtered or unexported fields
}
func (*MatchedJar) Name ¶ added in v0.0.62
func (m *MatchedJar) Name() string
Name returns just the name of the jar eg "my-jar.jar"
func (*MatchedJar) Path ¶ added in v0.0.62
func (m *MatchedJar) Path() string
Path returns the full path to the jar file
type MinecraftRelease ¶
type MinecraftRelease struct { ID string `json:"id"` Type string `json:"type"` URL string `json:"url"` Time string `json:"time"` ReleaseTime string `json:"releaseTime"` }
MinecraftRelease is a released minecraft version
type MinecraftReleaseResponse ¶
type MinecraftReleaseResponse struct { Latest struct { Release string `json:"release"` Snapshot string `json:"snapshot"` } `json:"latest"` Versions []MinecraftRelease }
MinecraftReleaseResponse is the response from the launchermeta mojang api
func GetMinecraftReleases ¶
func GetMinecraftReleases(ctx context.Context) (*MinecraftReleaseResponse, error)
GetMinecraftReleases returns all available Minecraft releases