Documentation ¶
Overview ¶
Package minecraft is a level viewer/editor for the popular creative game minecraft.
Example ¶
package main import ( "fmt" "vimagination.zapto.org/minecraft" ) func main() { path := minecraft.NewMemPath() level, _ := minecraft.NewLevel(path) level.LevelName("TestMine") name := level.GetLevelName() fmt.Println(name) }
Output: TestMine
Index ¶
- Constants
- Variables
- type Biome
- type Block
- func (b *Block) AddTicks(t ...Tick)
- func (b Block) Equal(e interface{}) bool
- func (b Block) EqualBlock(c Block) bool
- func (b Block) GetMetadata() nbt.Compound
- func (b Block) GetTicks() []Tick
- func (b Block) HasMetadata() bool
- func (b Block) HasTicks() bool
- func (b Block) IsLiquid() bool
- func (b Block) Light() uint8
- func (b Block) Opacity() uint8
- func (b *Block) SetMetadata(data nbt.Compound)
- func (b *Block) SetTicks(t []Tick)
- func (b Block) String() string
- type ConflictError
- type FilePath
- func (p *FilePath) Defrag(x, z int32) error
- func (p *FilePath) GetChunk(x, z int32) (nbt.Tag, error)
- func (p *FilePath) GetChunks(x, z int32) ([][2]int32, error)
- func (p *FilePath) GetRegions() [][2]int32
- func (p *FilePath) HasLock() bool
- func (p *FilePath) Lock() error
- func (p *FilePath) ReadLevelDat() (nbt.Tag, error)
- func (p *FilePath) RemoveChunk(x, z int32) error
- func (p *FilePath) SetChunk(data ...nbt.Tag) error
- func (p *FilePath) WriteLevelDat(data nbt.Tag) error
- type FilePathSetError
- type Level
- func (l *Level) AllowCommands(a bool)
- func (l *Level) BorderCenter(x, z float64)
- func (l *Level) BorderSize(w float64)
- func (l *Level) Close()
- func (l *Level) CommandBlockOutput(d bool)
- func (l *Level) CommandFeedback(d bool)
- func (l *Level) DayLightCycle(d bool)
- func (l *Level) DeathMessages(d bool)
- func (l *Level) Difficulty(d int8)
- func (l *Level) DifficultyLocked(dl bool)
- func (l *Level) FireTick(d bool)
- func (l *Level) GameMode(gm int32)
- func (l *Level) Generator(generator string)
- func (l *Level) GeneratorOptions(options string)
- func (l *Level) GetBiome(x, z int32) (Biome, error)
- func (l *Level) GetBlock(x, y, z int32) (Block, error)
- func (l *Level) GetHeight(x, z int32) (int32, error)
- func (l *Level) GetLevelName() string
- func (l *Level) GetSpawn() (x int32, y int32, z int32)
- func (l *Level) Hardcore(h bool)
- func (l *Level) HealthRegeneration(d bool)
- func (l *Level) KeepInventory(d bool)
- func (l *Level) LevelName(name string)
- func (l *Level) LogAdminCommands(d bool)
- func (l *Level) MapFeatures(mf bool)
- func (l *Level) MobGriefing(d bool)
- func (l *Level) MobLoot(d bool)
- func (l *Level) MobSpawning(d bool)
- func (l *Level) RainTime(time int32)
- func (l *Level) Raining(raining bool)
- func (l *Level) Save() error
- func (l *Level) Seed(seed int64)
- func (l *Level) SetBiome(x, z int32, biome Biome) error
- func (l *Level) SetBlock(x, y, z int32, block Block) error
- func (l *Level) Spawn(x, y, z int32)
- func (l *Level) ThunderTime(time int32)
- func (l *Level) Thundering(thundering bool)
- func (l *Level) TicksExisted(t int64)
- func (l *Level) TileDrops(d bool)
- func (l *Level) Time(t int64)
- type LightBlockList
- type MemPath
- type MissingTagError
- type MultiError
- type Option
- type Path
- type Tick
- type TransparentBlockList
- type UnexpectedValue
- type UnknownCompression
- type WrongTypeError
Examples ¶
Constants ¶
const ( DefaultGenerator = "default" FlatGenerator = "flat" LargeBiomeGenerator = "largeBiomes" AmplifiedGenerator = "amplified" CustomGenerator = "customized" DebugGenerator = "debug_all_block_states" )
Default minecraft generators
const ( Survival int32 = iota Creative Adventure Spectator )
Game Modes Settings.
const ( Peaceful int8 = iota Easy Normal Hard )
Difficulty Settings.
const ( SunRise = 0 Noon = 6000 SunSet = 12000 MidNight = 18000 Day = 24000 )
Time-of-day convenience constants.
const ( GZip byte = 1 Zlib byte = 2 )
Compression convenience constants.
Variables ¶
var ( // ErrOOB is an error returned when sanity checking section data. ErrOOB = errors.New("received out-of-bounds error") // ErrNoLock is an error returns by path types to indicate that the lock on the // minecraft level has been locked and needs reinstating to continue. ErrNoLock = errors.New("lost lock on files") )
var ( // TransparentBlocks is a slice of the block ids that are transparent. // This is used in lighting calculations and is user overridable for custom // blocks. TransparentBlocks = TransparentBlockList{0, 6, 18, 20, 26, 27, 28, 29, 30, 31, 33, 34, 37, 38, 39, 40, 50, 51, 52, 54, 55, 59, 63, 64, 65, 66, 69, 70, 71, 75, 76, 77, 78, 79, 81, 83, 85, 90, 92, 93, 94, 96, 102, 106, 107, 117, 118, 119, 120, 750} // LightBlocks is a map of block ids to the amount of light they give off. LightBlocks = LightBlockList{ 10: 15, 11: 15, 39: 1, 50: 14, 51: 15, 62: 13, 74: 13, 76: 7, 89: 15, 90: 11, 91: 15, 94: 9, 117: 1, 119: 15, 120: 1, 122: 1, 124: 15, 130: 7, 138: 15, } )
Functions ¶
This section is empty.
Types ¶
type Biome ¶
type Biome uint8
Biome is a convenience type for biomes.
const ( Ocean Biome = 0 Plains Biome = 1 Desert Biome = 2 ExtremeHills Biome = 3 Forest Biome = 4 Taiga Biome = 5 Swampland Biome = 6 River Biome = 7 Hell Biome = 8 Sky Biome = 9 FrozenOcean Biome = 10 FrozenRiver Biome = 11 IcePlains Biome = 12 IceMountains Biome = 13 MushroomIsland Biome = 14 MushroomIslandShore Biome = 15 Beach Biome = 16 DesertHills Biome = 17 ForestHills Biome = 18 TaigaHills Biome = 19 ExtremeHillsEdge Biome = 20 Jungle Biome = 21 JungleHills Biome = 22 JungleEdge Biome = 23 DeepOcean Biome = 24 StoneBeach Biome = 25 ColdBeach Biome = 26 BirchForest Biome = 27 BirchForestHills Biome = 28 RoofedForest Biome = 29 ColdTaiga Biome = 30 ColdTaigaHills Biome = 31 MegaTaiga Biome = 32 MegaTaigaHills Biome = 33 ExtremeHillsPlus Biome = 34 Savanna Biome = 35 SavannaPlateau Biome = 36 Mesa Biome = 37 MesaPlateauF Biome = 38 MesaPlateau Biome = 39 SunflowerPlains Biome = 129 DeserM Biome = 130 ExtremeHillsM Biome = 131 FlowerForest Biome = 132 TaigaM Biome = 133 SwamplandM Biome = 134 IcePlainsSpikes Biome = 140 JungleM Biome = 149 JungleEdgeM Biome = 151 BirchForestM Biome = 155 BirchForestHillsM Biome = 156 RoofedForestM Biome = 157 ColdTaigaM Biome = 158 MegaSpruceTaiga Biome = 160 MegaSpruceTaigaHills Biome = 161 ExtremeHillsPlusM Biome = 162 SavannaM Biome = 163 SavannaPlateauM Biome = 164 MesaBryce Biome = 165 MesaPlateauFM Biome = 166 MesaPlateauM Biome = 167 AutoBiome Biome = 255 )
Biome constants.
type Block ¶
Block is a type that represents the full information for a block, id, data, metadata and scheduled tick data.
func (Block) EqualBlock ¶
EqualBlock checks for equality between the two blocks.
func (Block) GetMetadata ¶
GetMetadata returns a copy of the metadata for this block, or nil is it has none.
func (Block) HasMetadata ¶
HasMetadata returns true if the block contains extended metadata.
func (*Block) SetMetadata ¶
SetMetadata sets the blocks metadata to a copy of the given metadata.
type ConflictError ¶
type ConflictError struct {
X, Z int32
}
ConflictError is an error return by SetChunk when trying to save a single chunk multiple times during the same save operation.
func (ConflictError) Error ¶
func (c ConflictError) Error() string
type FilePath ¶
type FilePath struct {
// contains filtered or unexported fields
}
FilePath implements the Path interface and provides a standard minecraft save format.
func NewFilePath ¶
NewFilePath constructs a new directory based path to read from.
func NewFilePathDimension ¶
NewFilePathDimension create a new FilePath, but with the option to set the dimension that chunks are loaded from.
Example. Dimension -1 == The Nether
Dimension 1 == The End
func (*FilePath) GetChunks ¶
GetChunks returns a list of all chunks within a region with coords x,z.
func (*FilePath) GetRegions ¶
GetRegions returns a list of region x,z coords of all generated regions.
func (*FilePath) ReadLevelDat ¶
ReadLevelDat returns the level data.
func (*FilePath) RemoveChunk ¶
RemoveChunk deletes the chunk at chunk coords x, z.
type FilePathSetError ¶
FilePathSetError is an error returned from SetChunk when some error is returned either from converting the nbt or saving it.
func (FilePathSetError) Error ¶
func (f FilePathSetError) Error() string
type Level ¶
type Level struct {
// contains filtered or unexported fields
}
Level is the base type for minecraft data, all data for a minecraft level is either store in, or accessed from, this type.
func (*Level) AllowCommands ¶
AllowCommands enables/disables the cheat commands.
func (*Level) BorderCenter ¶
BorderCenter sets the position of the center of the World Border.
func (*Level) BorderSize ¶
BorderSize sets the width of the border.
func (*Level) CommandBlockOutput ¶
CommandBlockOutput enables/disables chat echo for command blocks.
func (*Level) CommandFeedback ¶
CommandFeedback enables/disables the echo for player commands in the chat.
func (*Level) DayLightCycle ¶
DayLightCycle enables/disables the day/night cycle.
func (*Level) DeathMessages ¶
DeathMessages enables/disables the logging of player deaths to the chat.
func (*Level) DifficultyLocked ¶
DifficultyLocked locks the difficulty in game.
func (*Level) FireTick ¶
FireTick enables/disables fire updates, such as spreading and extinguishing.
func (*Level) GeneratorOptions ¶
GeneratorOptions sets the generator options for a flat or custom generator. The syntax is not checked.
func (*Level) GetHeight ¶
GetHeight returns the y coordinate for the highest non-transparent block at column x, z.
func (*Level) GetLevelName ¶
GetLevelName sets the given string to the name of the minecraft level.
func (*Level) HealthRegeneration ¶
HealthRegeneration enables/disables the regeneration of the players health when their hunger is high enough.
func (*Level) KeepInventory ¶
KeepInventory enables/disables the keeping of a players inventory upon death.
func (*Level) LogAdminCommands ¶
LogAdminCommands enables/disables the logging of admin commands to the log.
func (*Level) MapFeatures ¶
MapFeatures enables/disables map feature generation (villages, strongholds, mineshafts, etc.).
func (*Level) MobGriefing ¶
MobGriefing enables/disables the ability of mobs to destroy blocks.
func (*Level) MobSpawning ¶
MobSpawning enables/disables mob spawning.
func (*Level) SetBlock ¶
SetBlock sets the block at coordinates x, y, z. Also processes any lighting updates if applicable.
func (*Level) ThunderTime ¶
ThunderTime sets the tune until the thunder state changes.
func (*Level) Thundering ¶
Thundering sets the lightning/thunder on or off.
func (*Level) TicksExisted ¶
TicksExisted sets how many ticks have passed in game.
type LightBlockList ¶
LightBlockList is a map of block ids to the amount of light they give off.
func (LightBlockList) Add ¶
func (l LightBlockList) Add(blockID uint16, light uint8) bool
Add is a convenience method for the light block list. It adds a new block id to the list with its corresponding light level.
func (LightBlockList) Remove ¶
func (l LightBlockList) Remove(blockID uint16) bool
Remove is a convenience method to remove a block id from the light block list.
type MemPath ¶
type MemPath struct {
// contains filtered or unexported fields
}
MemPath is an in memory minecraft level format that implements the Path interface.
func (*MemPath) ReadLevelDat ¶
ReadLevelDat Returns the level data.
func (*MemPath) RemoveChunk ¶
RemoveChunk deletes the chunk at chunk coords x, z.
type MissingTagError ¶
type MissingTagError struct {
TagName string
}
MissingTagError is an error type returned when an expected tag is not found.
func (MissingTagError) Error ¶
func (m MissingTagError) Error() string
type MultiError ¶
type MultiError struct {
Errors []error
}
MultiError is an error type that contains multiple errors.
func (MultiError) Error ¶
func (m MultiError) Error() string
type Option ¶
type Option func(*Level)
Option is a function used to set an option for a minecraft level struct.
type Path ¶
type Path interface { // Returns an empty nbt.Tag (TagEnd) when chunk does not exists. GetChunk(int32, int32) (nbt.Tag, error) SetChunk(...nbt.Tag) error RemoveChunk(int32, int32) error ReadLevelDat() (nbt.Tag, error) WriteLevelDat(nbt.Tag) error }
The Path interface allows the minecraft level to be created from/saved to different formats.
type TransparentBlockList ¶
type TransparentBlockList []uint16
TransparentBlockList is a slice of the block ids that are transparent.
func (*TransparentBlockList) Add ¶
func (t *TransparentBlockList) Add(blockID uint16) bool
Add is a convenience method for the transparent block list. It adds a new block id to the list, making sure to not add duplicates.
func (*TransparentBlockList) Remove ¶
func (t *TransparentBlockList) Remove(blockID uint16) bool
Remove is a convenience method to remove a block id from the transparent block list.
type UnexpectedValue ¶
type UnexpectedValue struct {
TagName, Expecting, Got string
}
UnexpectedValue is an error returned from chunk loading during sanity checking.
func (UnexpectedValue) Error ¶
func (u UnexpectedValue) Error() string
type UnknownCompression ¶
type UnknownCompression struct {
Code byte
}
UnknownCompression is an error returned by path types when it encounters a compression scheme it is not prepared to handle or an unknown compression scheme.
func (UnknownCompression) Error ¶
func (u UnknownCompression) Error() string
type WrongTypeError ¶
WrongTypeError is an error returned when an nbt tag has an unexpected type.
func (WrongTypeError) Error ¶
func (w WrongTypeError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package nbt implements a full Named Binary Tag reader/writer, based on the specs at http://web.archive.org/web/20110723210920/http://www.minecraft.net/docs/NBT.txt
|
Package nbt implements a full Named Binary Tag reader/writer, based on the specs at http://web.archive.org/web/20110723210920/http://www.minecraft.net/docs/NBT.txt |