mctools

package module
v0.0.0-...-9299ccb Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2016 License: BSD-1-Clause Imports: 6 Imported by: 0

README

mctools

mctools is a collection of packages used to read, edit and write Minecraft world data. Refer to the respective sub-packages for details on their purpose.

The code targets Minecraft 1.8+. Older worlds may work or they may not. Use at your own risk.

Warning

The code defines read->write->read roundtrip tests to ensure the written data is consistent and correct. Even so, you should always create backups of any world you are about to change. I am not responsible for any damage you may do to your world data or Minecraft itself.

This package has been tested with world data created in Vanilla Minecraft 1.8.3+. There are no guarantees that older worlds can be read or that changes to such a world will still load up in Minecraft. Test your changes thoroughly. And when you're done testing, test some more.

Additionally, don't read/write world data which is currently being used by Minecraft itself. The behaviour of this undefined and will very likely end up in tears.

Install

go get github.com/jteeuwen/mctools/...

License

Unless otherwise stated, all of the work in this project is subject to a 1-clause BSD license. Its contents can be found in the enclosed LICENSE file.

Documentation

Overview

package mctools holds a collection of tools used to read, edit and write Minecraft world data. Refer to the respective sub-packages for details on their purpose.

The code targets Minecraft 1.8+. Older worlds may work or they may not. Use at your own risk.

Warning

The code defines read->write->read roundtrip tests to ensure the written data is consistent and correct. Even so, you should __always create backups__ of any world you are about to change. I am __not__ responsible for any damage you may do to your world data or Minecraft itself.

This package has been tested with world data created in Vanilla Minecraft 1.8.3+. There are no guarantees that older worlds can be read or that changes to such a world will still load up in Minecraft. Test your changes thoroughly. And when you're done testing, test some more.

Additionally, don't read/write world data which is currently being used by Minecraft itself. The behaviour of this undefined and will very likely end up in tears.

Index

Constants

View Source
const (
	DimensionOverworld = "region"
	DimensionNether    = "DIM-1/region"
	DimensionEnd       = "DIM1/region"
)

Known dimension names.

Variables

This section is empty.

Functions

func BlockCoords

func BlockCoords(x, y, z int) (int, int, int)

BlockCoords returns block offsets in a chunk for the given, absolute block position.

func ChunkCoords

func ChunkCoords(x, z int) (int, int)

ChunkCoords returns the chunk coordinates for the given, absolute block position.

func RegionCoords

func RegionCoords(x, z int) (int, int)

RegionCoords returns region coordinates from the given, absolute block position.

Types

type World

type World struct {
	*anvil.Level // level.dat contents.
	// contains filtered or unexported fields
}

World defines a single Minecraft world.

func Open

func Open(root string) (*World, error)

Open opens a new world in the given root directory.

func (*World) CreateRegion

func (w *World) CreateRegion(dim string, x, z int) (*anvil.Region, error)

CreateRegion creates a new region in this world and specified dimension, using the given coordinates. Returns an error if the region already exists.

func (*World) DeleteRegion

func (w *World) DeleteRegion(dim string, x, z int) error

DeleteRegion deletes the given region.

If you have an open handle to this region, close it before calling this, as accessing its data afterwards will have undefined behaviour.

Note that this permanently deletes the region file from disk. This operation can not be undone.

func (*World) LoadRegion

func (w *World) LoadRegion(dim string, x, z int) (*anvil.Region, error)

LoadRegion loads the given region in the specified dimension. Returns nil if the region could not be loaded.

func (*World) Regions

func (w *World) Regions() map[string][][2]int

Regions returns the coordinates for all regions in the world. This yields a map which groups region X/Z pairs for each dimension.

func (*World) Save

func (w *World) Save() error

Save saves the level.dat information for this world.

Directories

Path Synopsis
Package anvil reads level.dat and .mca region files which make up Minecraft worlds.
Package anvil reads level.dat and .mca region files which make up Minecraft worlds.
biome
Package biome describes a set of known biomes.
Package biome describes a set of known biomes.
item
Package item defines constants with ids for all known items.
Package item defines constants with ids for all known items.
nbt
NBT (Named Binary Tag) is a tag based binary format designed to carry large amounts of binary data with smaller amounts of meta data.
NBT (Named Binary Tag) is a tag based binary format designed to carry large amounts of binary data with smaller amounts of meta data.
Package mcra defines an API to query Minecraft world data.
Package mcra defines an API to query Minecraft world data.
recipe
Package recipe defines an interface and listing of all known Minecraft recipes and facilities to create recipe trees.
Package recipe defines an interface and listing of all known Minecraft recipes and facilities to create recipe trees.

Jump to

Keyboard shortcuts

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