resource

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 11 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capability

type Capability string

Capability is a different features that the pack makes use of that isn't necessarily enabled by default. experimental_custom_ui: Allows HTML files in the pack to be used for custom UI, and scripts in the pack to

call and manipulate custom UI.

chemistry: Allows the pack to add, change or replace Chemistry functionality.

type Dependency

type Dependency struct {
	// UUID is the unique identifier of the pack that this pack depends on. It needs to be the exact same UUID
	// that the pack has defined in the header section of it's manifest file.
	UUID string `json:"uuid"`
	// Version is the specific version of the pack that the pack depends on. Should match the version the
	// other pack has in its manifest file.
	Version [3]int `json:"version"`
}

Dependency describes a pack that this pack depends on in order to work.

type Header struct {
	// Name is the name of the pack as it appears within Minecraft.
	Name string `json:"name"`
	// Description is a short description of the pack. It will appear in the game below the name of the pack.
	Description string `json:"description"`
	// UUID is a unique identifier identifier this pack from any other pack.
	UUID string `json:"uuid"`
	// Version is the version of the pack, which can be used to identify changes in the pack.
	Version [3]int `json:"version"`
	// MinimumGameVersion is the minimum version of the game that this resource pack was written for.
	MinimumGameVersion [3]int `json:"min_engine_version"`
}

Header is the header of a resource pack. It contains information that applies to the entire resource pack, such as the name of the resource pack.

type Manifest

type Manifest struct {
	// FormatVersion defines the current version of the manifest. This is currently always 1.
	FormatVersion int `json:"format_version"`
	// Header is the header of a resource pack. It contains information that applies to the entire resource
	// pack, such as the name of the resource pack.
	Header Header `json:"header"`
	// Modules describes the modules that comprise the pack. Each entry here defines one of the kinds of
	// contents of the pack.
	Modules []Module `json:"modules"`
	// Dependencies describes the packs that this pack depends on in order to work.
	Dependencies []Dependency `json:"dependencies,omitempty"`
	// Capabilities are the different features that the pack makes use of that aren't necessarily enabled by
	// default. For a list of options, see below.
	Capabilities []Capability `json:"capabilities,omitempty"`
	// contains filtered or unexported fields
}

Manifest contains all the basic information about the pack that Minecraft needs to identify it.

type Metadata

type Metadata struct {
	// Author is the name of the author(s) of the pack.
	Author string `json:"authors,omitempty"`
	// License is the license applied to the pack.
	License string `json:"license,omitempty"`
	// URL is the home website of the creator of the pack.
	URL string `json:"url,omitempty"`
}

Metadata contains additional data about the pack and is otherwise optional.

type Module

type Module struct {
	// UUID is a unique identifier for the module in the same format as the pack's UUID in the header. This
	// should be different from the pack's UUID, and different for every module.
	UUID string `json:"uuid"`
	// Description is a short description of the module. This is not user-facing at the moment.
	Description string `json:"description"`
	// Type is the type of the module. Can be any of the following: resources, data, client_data, interface or
	// world_template.
	Type string `json:"type"`
	// Version is the version of the module in the same format as the pack's version in the header. This can
	// be used to further identify changes in the pack.
	Version [3]int `json:"version"`
}

Module describes a module that comprises the pack. Each module defines one of the kinds of contents of the pack.

type Pack

type Pack struct {
	// contains filtered or unexported fields
}

Pack is a container of a resource pack parsed from a directory or a .zip archive (or .mcpack). It holds methods that may be used to get information about the resource pack.

func Compile

func Compile(path string) (*Pack, error)

Compile compiles a resource pack found at the path passed. The resource pack must either be a zip archive (extension does not matter, could be .zip or .mcpack), or a directory containing a resource pack. In the case of a directory, the directory is compiled into an archive and the pack is parsed from that. Compile operates assuming the resource pack has a 'manifest.json' file in it. If it does not, the function will fail and return an error.

func FromBytes

func FromBytes(data []byte) (*Pack, error)

FromBytes parses an archived resource pack written to a raw byte slice passed. The data must be a valid zip archive and contain a pack manifest in order for the function to succeed. FromBytes saves the data to a temporary archive.

func MustCompile

func MustCompile(path string) *Pack

MustCompile compiles a resource pack found at the path passed. The resource pack must either be a zip archive (extension does not matter, could be .zip or .mcpack), or a directory containing a resource pack. In the case of a directory, the directory is compiled into an archive and the pack is parsed from that. Compile operates assuming the resource pack has a 'manifest.json' file in it. If it does not, the function will fail and return an error. Unlike Compile, MustCompile does not return an error and panics if an error occurs instead.

func (*Pack) Checksum

func (pack *Pack) Checksum() [32]byte

Checksum returns the SHA256 checksum made from the full, compressed content of the resource pack archive. It is transmitted as a string over network.

func (*Pack) DataChunkCount

func (pack *Pack) DataChunkCount(length int) int

DataChunkCount returns the amount of chunks the data of the resource pack is split into if each chunk has a specific length.

func (*Pack) Dependencies

func (pack *Pack) Dependencies() []Dependency

Dependencies returns all dependency resource packs that must be loaded in order for this resource pack to function correctly.

func (*Pack) Description

func (pack *Pack) Description() string

Description returns the description of the resource pack.

func (*Pack) HasBehaviours

func (pack *Pack) HasBehaviours() bool

HasBehaviours checks if any of the modules of the resource pack have either the type 'data' or 'client_data', meaning they contain behaviours (or scripts).

func (*Pack) HasScripts

func (pack *Pack) HasScripts() bool

HasScripts checks if any of the modules of the resource pack have the type 'client_data', meaning they have scripts in them.

func (*Pack) HasTextures

func (pack *Pack) HasTextures() bool

HasTextures checks if any of the modules of the resource pack have the type 'resources', meaning they have textures in them.

func (*Pack) HasWorldTemplate

func (pack *Pack) HasWorldTemplate() bool

HasWorldTemplate checks if the resource compiled holds a level.dat in it, indicating that the resource is a world template.

func (*Pack) Len

func (pack *Pack) Len() int

Len returns the total length in bytes of the content of the archive that contained the resource pack.

func (*Pack) Manifest

func (pack *Pack) Manifest() Manifest

Manifest returns the manifest found in the manifest.json of the resource pack. It contains information about the pack such as its name.

func (*Pack) Modules

func (pack *Pack) Modules() []Module

Modules returns all modules that the resource pack exists out of. Resource packs usually have only one module, but may have more depending on their functionality.

func (*Pack) Name

func (pack *Pack) Name() string

Name returns the name of the resource pack.

func (*Pack) ReadAt

func (pack *Pack) ReadAt(b []byte, off int64) (n int, err error)

ReadAt reads len(b) bytes from the resource pack's archive data at offset off and copies it into b. The amount of bytes read n is returned.

func (*Pack) UUID

func (pack *Pack) UUID() string

UUID returns the UUID of the resource pack.

func (*Pack) Version

func (pack *Pack) Version() string

Version returns the string version of the resource pack. It is guaranteed to have 3 digits in it, joined by a dot.

Jump to

Keyboard shortcuts

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