utils

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: GPL-3.0 Imports: 63 Imported by: 0

Documentation

Overview

Package utils ...

Index

Constants

This section is empty.

Variables

View Source
var Auth *authsrv = &authsrv{
	log: logrus.WithField("part", "Auth"),
}
View Source
var ConnectInfoKey key
View Source
var ErrNotLoggedIn = errors.New("not logged in")
View Source
var ErrorHandler = func(err error) {
	logrus.Fatal(err)
}
View Source
var LogOff bool
View Source
var Options struct {
	Debug         bool
	IsInteractive bool
	ExtraDebug    bool
	Capture       bool
	Env           string
}
View Source
var PackFromBase = func(pack resource.Pack) (resource.Pack, error) {
	return pack, nil
}
View Source
var Tokene = func(w io.Writer, o any) error {
	return json.NewEncoder(w).Encode(o)
}
View Source
var Ver1token func(f io.ReadSeeker, o any) error

Functions

func BlendColors

func BlendColors(c1, c2 color.RGBA) (ret color.RGBA)

func CfbDecrypt added in v1.28.0

func CfbDecrypt(data []byte, key []byte) []byte

func CleanupName

func CleanupName(name string) string

CleanupName cleans name so it can be used as a filename

func CopyFS added in v1.39.1

func CopyFS(src fs.FS, dst WriterFS) error

func DrawImgScaledPos added in v1.28.0

func DrawImgScaledPos(dst *image.RGBA, src *image.RGBA, bottomLeft image.Point, sizeScaled int)

DrawImgScaledPos draws src onto dst at bottomLeft, scaled to size

func DumpStruct added in v1.28.0

func DumpStruct(f io.StringWriter, inputStruct any)

func Img2rgba

func Img2rgba(img *image.RGBA) []color.RGBA

func LERP

func LERP(p1, p2, alpha float64) float64

LERP is a linear interpolation function

func LookupColor added in v1.31.1

func LookupColor(name string) color.RGBA

func Netisolation added in v1.39.1

func Netisolation() error

func NewCfb8 added in v1.31.1

func NewCfb8(r io.Reader, key []byte) io.Reader

func OpenUrl added in v1.33.1

func OpenUrl(uri string) error

func ParseJson added in v1.31.1

func ParseJson(s []byte, out any) error

func PrintPanic added in v1.31.1

func PrintPanic(err error)

func RGBA2Img added in v1.37.0

func RGBA2Img(colors []color.RGBA, width, height int) *image.RGBA

func RandSeededUUID added in v1.28.0

func RandSeededUUID(str string) string

func RecoverCall added in v1.41.0

func RecoverCall(f func() error) (err error)

func RemoveDir added in v1.39.0

func RemoveDir(name string) error

func RemoveFile added in v1.39.0

func RemoveFile(name string) error

func RemoveTree added in v1.39.0

func RemoveTree(dir string) error

func ResolveColors added in v1.31.1

func ResolveColors(entries []protocol.BlockEntry, packs []resource.Pack) map[string]color.RGBA

func ShowFile added in v1.28.1

func ShowFile(path string)

func SizeofFmt added in v1.28.1

func SizeofFmt(num float32) string

func SplitExt

func SplitExt(filename string) (name, ext string)

SplitExt splits path to filename and extension

func StackToItem added in v1.32.0

func StackToItem(reg world.BlockRegistry, it protocol.ItemStack) item.Stack

stackToItem converts a network ItemStack representation back to an item.Stack.

func UploadError added in v1.31.1

func UploadError(err error)

func UploadPanic added in v1.31.1

func UploadPanic()

func UserInput added in v1.28.0

func UserInput(ctx context.Context, q string, validator func(string) bool) (string, bool)

func ValidateServerInput added in v1.30.0

func ValidateServerInput(server string) bool

func WriteManifest added in v1.28.0

func WriteManifest(manifest *resource.Manifest, fs WriterFS, fpath string) error

func ZipCompressPool added in v1.39.1

func ZipCompressPool(zw *zip.Writer)

Types

type BlockRID added in v1.32.0

type BlockRID = uint32

type ChunkRenderer added in v1.39.0

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

func (*ChunkRenderer) Chunk2Img added in v1.39.0

func (cr *ChunkRenderer) Chunk2Img(c *chunk.Chunk) *image.RGBA

func (*ChunkRenderer) ResolveColors added in v1.39.0

func (cr *ChunkRenderer) ResolveColors(entries []protocol.BlockEntry, packs []resource.Pack)

type ConnectInfo added in v1.39.1

type ConnectInfo struct {
	Gathering     *gatherings.Gathering
	Realm         *realms.Realm
	Replay        string
	ServerAddress string
}

func ParseServer added in v1.33.0

func ParseServer(ctx context.Context, server string) (*ConnectInfo, error)

func (*ConnectInfo) Address added in v1.39.1

func (c *ConnectInfo) Address(ctx context.Context) (string, error)

func (*ConnectInfo) Name added in v1.39.1

func (c *ConnectInfo) Name() string

type MultiWriterFS added in v1.39.0

type MultiWriterFS struct {
	FSs []WriterFS
}

func (MultiWriterFS) Create added in v1.39.0

func (m MultiWriterFS) Create(filename string) (w io.WriteCloser, err error)

type OSWriter added in v1.39.0

type OSWriter struct {
	Base string
}

func (OSWriter) Create added in v1.39.0

func (o OSWriter) Create(filename string) (w io.WriteCloser, err error)

type Skin added in v1.28.1

type Skin struct {
	*protocol.Skin
}

func (*Skin) Complex added in v1.28.1

func (skin *Skin) Complex() bool

func (*Skin) Hash added in v1.28.1

func (skin *Skin) Hash() uuid.UUID

func (*Skin) HaveAnimations added in v1.28.1

func (skin *Skin) HaveAnimations() bool

func (*Skin) HaveCape added in v1.28.1

func (skin *Skin) HaveCape() bool

func (*Skin) HaveGeometry added in v1.28.1

func (skin *Skin) HaveGeometry() bool

func (*Skin) HaveTint added in v1.28.1

func (skin *Skin) HaveTint() bool

func (*Skin) WriteCapePng added in v1.28.1

func (skin *Skin) WriteCapePng(output_path string) error

WriteCape writes the cape as a png at output_path

type SkinGeometry added in v1.28.1

type SkinGeometry struct {
	Description SkinGeometryDescription `json:"description"`
	Bones       json.RawMessage         `json:"bones"`
}

type SkinGeometryDescription added in v1.31.0

type SkinGeometryDescription struct {
	Identifier          string      `json:"identifier"`
	TextureWidth        json.Number `json:"texture_width"`
	TextureHeight       json.Number `json:"texture_height"`
	VisibleBoundsWidth  float64     `json:"visible_bounds_width"`
	VisibleBoundsHeight float64     `json:"visible_bounds_height"`
	VisibleBoundsOffset []float64   `json:"visible_bounds_offset,omitempty"`
}

type SkinGeometryFile added in v1.40.0

type SkinGeometryFile struct {
	FormatVersion string         `json:"format_version"`
	Geometry      []SkinGeometry `json:"minecraft:geometry"`
}

func ParseSkinGeometry added in v1.37.0

func ParseSkinGeometry(skin *protocol.Skin) (*SkinGeometryFile, string, error)

type SkinGeometry_Old added in v1.37.0

type SkinGeometry_Old struct {
	SkinGeometryDescription
	Bones json.RawMessage `json:"bones"`
}

type SkinMeta added in v1.28.1

type SkinMeta struct {
	SkinID        string
	PlayFabID     string
	PremiumSkin   bool
	PersonaSkin   bool
	CapeID        string
	SkinColour    string
	ArmSize       string
	Trusted       bool
	PersonaPieces []protocol.PersonaPiece
}

type SkinPack added in v1.28.1

type SkinPack struct {
	Name string
	// contains filtered or unexported fields
}

func NewSkinPack added in v1.28.1

func NewSkinPack(name, fpath string) *SkinPack

func (*SkinPack) AddSkin added in v1.28.1

func (s *SkinPack) AddSkin(skin *Skin) bool

func (*SkinPack) Save added in v1.28.1

func (s *SkinPack) Save(fpath string) error

type TexMapEntry added in v1.32.0

type TexMapEntry struct {
	X           uint16
	Y           uint16
	Transparent bool
}

type TexMapHash added in v1.32.0

type TexMapHash = uint64

type TexMapIdx added in v1.32.0

type TexMapIdx = uint32

type TextureMap added in v1.32.0

type TextureMap struct {
	BlockSize int
	Lookup    *image.RGBA
}

func NewTextureMap added in v1.32.0

func NewTextureMap() *TextureMap

func (*TextureMap) SetTextures added in v1.32.0

func (t *TextureMap) SetTextures(blocks []world.Block, resolvedTextures map[string]image.Image) map[BlockRID]TexMapEntry

type WriterFS added in v1.39.0

type WriterFS interface {
	Create(filename string) (w io.WriteCloser, err error)
}

func SubFS added in v1.39.1

func SubFS(base WriterFS, dir string) WriterFS

type ZipWriter added in v1.39.0

type ZipWriter struct {
	Writer *zip.Writer
}

func (ZipWriter) Create added in v1.39.0

func (z ZipWriter) Create(filename string) (w io.WriteCloser, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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