wlwanpan / mcdata

Go struct code generator for easy access to Minecraft data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mcdata

mcdata is a code generator tool for generating a package of go structs of minecraft data entities from minecraft-data.

Note: go 1.16 is required since this package relies on the go embeded package.

Usage

go run cmd/main.go gen --edition PC --version 1.8 --output out/entities

Note: the generated package name will be the output dir name. For example, running the above command will generate a package "entities" with the following files:

- src
    /out
        /entities
            /materials.go
            /items.go
            /recipes.go
            /version.go
            /foods.go
            /particles.go
            /instruments.go
            /protocol.go
            /biomes.go
            /enchantments.go
            /entities.go
            /blocks.go
            /blockCollisionShapes.go
            /language.go
            /mapIcons.go
            /effects.go
            /windows.go

effects.go

package entities

type Effects []struct {
	DisplayName string `json:"displayName"`
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Type        string `json:"type"`
}

Load your pre-generated go struct

effects := &entities.Effects{}
err := mcdata.LoadDataToStruct("pc", "1.8", "effects", effects)
if err != nil {
	...
}

...

About

Go struct code generator for easy access to Minecraft data


Languages

Language:Go 100.0%