utils

package
v1.52.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: GPL-3.0 Imports: 49 Imported by: 0

Documentation

Overview

Package utils ...

Index

Constants

This section is empty.

Variables

View Source
var CmdName = "invalid"
View Source
var ErrorHandler = func(err error) {
	logrus.Fatal(err)
}
View Source
var LogOff bool
View Source
var PackFromBase = func(pack resource.Pack) (resource.Pack, error) {
	return pack, nil
}
View Source
var Version string

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 CreateShared added in v1.45.1

func CreateShared(name string) (*os.File, 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 FormatPackName added in v1.42.0

func FormatPackName(packName string) string

func GetLocalIP

func GetLocalIP() (string, error)

func Img2rgba

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

func IsDebug added in v1.46.0

func IsDebug() bool

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 MakeValidFilename added in v1.45.1

func MakeValidFilename(name string) string

func NewCfb8 added in v1.31.1

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

func OpenShared added in v1.45.1

func OpenShared(name string) (*os.File, error)

func ParseJson added in v1.31.1

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

func PathCache added in v1.45.1

func PathCache(p ...string) string

func PathData added in v1.45.1

func PathData(p ...string) string

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 StripAnsi added in v1.45.1

func StripAnsi(str string) string

func StripAnsiBytes added in v1.45.1

func StripAnsiBytes(str []byte) []byte

func UserInput added in v1.28.0

func UserInput(ctx context.Context, q string, validator func(string) bool) (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 CountingWriter added in v1.45.1

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

func NewCountingWriter added in v1.45.1

func NewCountingWriter(w io.Writer) *CountingWriter

func (*CountingWriter) BytesWritten added in v1.45.1

func (w *CountingWriter) BytesWritten() int64

func (*CountingWriter) Write added in v1.45.1

func (w *CountingWriter) Write(b []byte) (int, error)

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 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)

Jump to

Keyboard shortcuts

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