mcmap

package
v0.0.0-...-a6a7f2c Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2016 License: MIT Imports: 12 Imported by: 6

Documentation

Overview

Package mcmap provides functions to read and modify Minecraft maps.

Index

Constants

View Source
const (
	BioOcean                = 0
	BioPlains               = 1
	BioDesert               = 2
	BioExtremeHills         = 3
	BioForest               = 4
	BioTaiga                = 5
	BioSwampland            = 6
	BioRiver                = 7
	BioHell                 = 8
	BioSky                  = 9
	BioFrozenOcean          = 10
	BioFrozenRiver          = 11
	BioIcePlains            = 12
	BioIceMountains         = 13
	BioMushroomIsland       = 14
	BioMushroomIslandShore  = 15
	BioBeach                = 16
	BioDesertHills          = 17
	BioForestHills          = 18
	BioTaigaHills           = 19
	BioExtremeHillsEdge     = 20
	BioJungle               = 21
	BioJungleHills          = 22
	BioJungleEdge           = 23
	BioDeepOcean            = 24
	BioStoneBeach           = 25
	BioColdBeach            = 26
	BioBirchForest          = 27
	BioBirchForestHills     = 28
	BioRoofedForest         = 29
	BioColdTaiga            = 30
	BioColdTaigaHills       = 31
	BioMegaTaiga            = 32
	BioMegaTaigaHills       = 33
	BioExtremeHillsPlus     = 34
	BioSavanna              = 35
	BioSavannaPlateau       = 36
	BioMesa                 = 37
	BioMesaPlateauF         = 38
	BioMesaPlateau          = 39
	BioSunflowerPlains      = 129
	BioDesertM              = 130
	BioExtremeHillsM        = 131
	BioFlowerForest         = 132
	BioTaigaM               = 133
	BioSwamplandM           = 134
	BioIcePlainsSpikes      = 140
	BioIceMountainsSpikes   = 141
	BioJungleM              = 149
	BioJungleEdgeM          = 151
	BioBirchForestM         = 155
	BioBirchForestHillsM    = 156
	BioRoofedForestM        = 157
	BioColdTaigaM           = 158
	BioMegaSpruceTaiga      = 160
	BioMegaSpruceTaigaHills = 161
	BioExtremeHillsPlusM    = 162
	BioSavannaM             = 163
	BioSavannaPlateauM      = 164
	BioMesaBryce            = 165
	BioMesaPlateauFM        = 166
	BioMesaPlateauM         = 167
	BioUncalculated         = 0xff // (-1)
)

Valid values for Biome

View Source
const (
	BlkAir                        = 0
	BlkStone                      = 1
	BlkGrassBlock                 = 2
	BlkDirt                       = 3
	BlkCobblestone                = 4
	BlkWoodPlanks                 = 5
	BlkSaplings                   = 6
	BlkBedrock                    = 7
	BlkWater                      = 8
	BlkStationaryWater            = 9
	BlkLava                       = 10
	BlkStationaryLava             = 11
	BlkSand                       = 12
	BlkGravel                     = 13
	BlkGoldOre                    = 14
	BlkIronOre                    = 15
	BlkCoalOre                    = 16
	BlkWood                       = 17
	BlkLeaves                     = 18
	BlkSponge                     = 19
	BlkGlass                      = 20
	BlkLapisLazuliOre             = 21
	BlkLapisLazuliBlock           = 22
	BlkDispenser                  = 23
	BlkSandstone                  = 24
	BlkNoteBlock                  = 25
	BlkBed                        = 26
	BlkPoweredRail                = 27
	BlkDetectorRail               = 28
	BlkStickyPiston               = 29
	BlkCobweb                     = 30
	BlkGrass                      = 31
	BlkDeadBush                   = 32
	BlkPiston                     = 33
	BlkPistonExtension            = 34
	BlkWool                       = 35
	BlkBlockMovedByPiston         = 36
	BlkDandelion                  = 37
	BlkFlower                     = 38
	BlkBrownMushroom              = 39
	BlkRedMushroom                = 40
	BlkBlockOfGold                = 41
	BlkBlockOfIron                = 42
	BlkDoubleSlabs                = 43
	BlkSlabs                      = 44
	BlkBricks                     = 45
	BlkTNT                        = 46
	BlkBookshelf                  = 47
	BlkMossStone                  = 48
	BlkObsidian                   = 49
	BlkTorch                      = 50
	BlkFire                       = 51
	BlkMonsterSpawner             = 52
	BlkOakWoodStairs              = 53
	BlkChest                      = 54
	BlkRedstoneWire               = 55
	BlkDiamondOre                 = 56
	BlkBlockOfDiamond             = 57
	BlkCraftingTable              = 58
	BlkWheat                      = 59
	BlkFarmland                   = 60
	BlkFurnace                    = 61
	BlkBurningFurnace             = 62
	BlkSignPost                   = 63
	BlkWoodenDoor                 = 64
	BlkLadders                    = 65
	BlkRail                       = 66
	BlkCobblestoneStairs          = 67
	BlkWallSign                   = 68
	BlkLever                      = 69
	BlkStonePressurePlate         = 70
	BlkIronDoor                   = 71
	BlkWoodenPressurePlate        = 72
	BlkRedstoneOre                = 73
	BlkGlowingRedstoneOre         = 74
	BlkRedstoneTorchInactive      = 75
	BlkRedstoneTorchActive        = 76
	BlkStoneButton                = 77
	BlkSnow                       = 78
	BlkIce                        = 79
	BlkSnowBlock                  = 80
	BlkCactus                     = 81
	BlkClay                       = 82
	BlkSugarCane                  = 83
	BlkJukebox                    = 84
	BlkFence                      = 85
	BlkPumpkin                    = 86
	BlkNetherrack                 = 87
	BlkSoulSand                   = 88
	BlkGlowstone                  = 89
	BlkNetherPortal               = 90
	BlkJackOLantern               = 91
	BlkCakeBlock                  = 92
	BlkRedstoneRepeaterInactive   = 93
	BlkRedstoneRepeaterActive     = 94
	BlkStainedGlass               = 95
	BlkLockedChest                = 95
	BlkTrapdoor                   = 96
	BlkMonsterEgg                 = 97
	BlkStoneBricks                = 98
	BlkHugeBrownMushroom          = 99
	BlkHugeRedMushroom            = 100
	BlkIronBars                   = 101
	BlkGlassPane                  = 102
	BlkMelon                      = 103
	BlkPumpkinStem                = 104
	BlkMelonStem                  = 105
	BlkVines                      = 106
	BlkFenceGate                  = 107
	BlkBrickStairs                = 108
	BlkStoneBrickStairs           = 109
	BlkMycelium                   = 110
	BlkLilyPad                    = 111
	BlkNetherBrick                = 112
	BlkNetherBrickFence           = 113
	BlkNetherBrickStairs          = 114
	BlkNetherWart                 = 115
	BlkEnchantmentTable           = 116
	BlkBrewingStand               = 117
	BlkCauldron                   = 118
	BlkEndPortal                  = 119
	BlkEndPortalBlock             = 120
	BlkEndStone                   = 121
	BlkDragonEgg                  = 122
	BlkRedstoneLampInactive       = 123
	BlkRedstoneLampActive         = 124
	BlkWoodenDoubleSlab           = 125
	BlkWoodenSlab                 = 126
	BlkCocoa                      = 127
	BlkSandstoneStairs            = 128
	BlkEmeraldOre                 = 129
	BlkEnderChest                 = 130
	BlkTripwireHook               = 131
	BlkTripwire                   = 132
	BlkBlockOfEmerald             = 133
	BlkSpruceWoodStairs           = 134
	BlkBirchWoodStairs            = 135
	BlkJungleWoodStairs           = 136
	BlkCommandBlock               = 137
	BlkBeacon                     = 138
	BlkCobblestoneWall            = 139
	BlkFlowerPot                  = 140
	BlkCarrots                    = 141
	BlkPotatoes                   = 142
	BlkWoodenButton               = 143
	BlkMobHead                    = 144
	BlkAnvil                      = 145
	BlkTrappedChest               = 146
	BlkWeightedPressurePlateLight = 147
	BlkWeightedPressurePlateHeavy = 148
	BlkRedstoneComparatorInactive = 149
	BlkRedstoneComparatorActive   = 150
	BlkDaylightSensor             = 151
	BlkBlockOfRedstone            = 152
	BlkNetherQuartzOre            = 153
	BlkHopper                     = 154
	BlkBlockOfQuartz              = 155
	BlkQuartzStairs               = 156
	BlkActivatorRail              = 157
	BlkDropper                    = 158
	BlkStainedClay                = 159
	BlkStainedGlassPane           = 160
	BlkWood2                      = 162
	BlkAcaciaWoodStairs           = 163
	BlkDarkOakWoodStairs          = 164
	BlkSlimeBlock                 = 165
	BlkHayBlock                   = 170
	BlkCarpet                     = 171
	BlkHardenedClay               = 172
	BlkBlockOfCoal                = 173
	BlkPackedIce                  = 174
	BlkLargeFlower                = 175
	BlkBarrier                    = 166
	BlkIronTrapdoor               = 167
	BlkPrismarine                 = 168
	BlkSeaLantern                 = 169

	// Aliases
	BlkRose      = BlkFlower
	BlkPoppy     = BlkFlower
	BlkInvisible = BlkBarrier
)

Valid values for BlockID

View Source
const (
	ChunkSizeXZ = 16
	ChunkSizeY  = 256
	ChunkRectXZ = ChunkSizeXZ * ChunkSizeXZ
	ChunkSize   = ChunkRectXZ * ChunkSizeY
)

Variables

View Source
var (
	NotAvailable = errors.New("Chunk or Superchunk not available")
	AlreadyThere = errors.New("Chunk is already there")
)
View Source
var (
	UnknownCompression = errors.New("Unknown chunk compression")
)

Functions

func BlockToChunk

func BlockToChunk(bx, bz int) (cx, cz, rbx, rbz int)

BlockToChunk calculates the chunk (cx, cz) and the block position in this chunk(rbx, rbz) of a block position given global coordinates.

func ChunkToBlock

func ChunkToBlock(cx, cz, rbx, rbz int) (bx, bz int)

ChunkToBlock calculates the global position of a block, given the chunk position (cx, cz) and the plock position in that chunk (rbx, rbz).

Types

type Biome

type Biome uint8

func (Biome) String

func (b Biome) String() string

type Block

type Block struct {
	ID                   BlockID
	Data                 byte            // Actually only a half-byte.
	BlockLight, SkyLight byte            // Also, only half-bytes.
	TileEntity           nbt.TagCompound // The x, y and z values in here can be ignored, will automatically be fixed on saving. Will be nil, if no TileEntity is available.
	Tick                 *TileTick       // If nil, no TileTick info is available for this block
}

type BlockID

type BlockID uint16

func (BlockID) String

func (b BlockID) String() string

type Chunk

type Chunk struct {
	Entities []nbt.TagCompound
	// contains filtered or unexported fields
}

Chunk represents a 16*16*256 Chunk of the region.

func (*Chunk) Biome

func (c *Chunk) Biome(x, z int) Biome

Biome gets the Biome at x,z.

func (*Chunk) Block

func (c *Chunk) Block(x, y, z int) *Block

Block gives you a reference to the Block located at x, y, z. If you modify the block data, you need to call the MarkModified() function of the chunk.

x and z must be in [0, 15], y in [0, 255]. Otherwise a nil pointer is returned.

func (*Chunk) Coords

func (c *Chunk) Coords() (X, Z int32)

Coords returns the Chunk's coordinates.

func (*Chunk) Height

func (c *Chunk) Height(x, z int) int

Height returns the height at x, z.

x and z must be in [0, 15]. Height will panic, if this is violated!

func (*Chunk) Iter

func (c *Chunk) Iter(fx func(int, int, int, *Block))

Iter iterates ofer all blocks of this chunk and calls the function fx with the coords (x,y,z) and a pointer to the block.

func (*Chunk) MarkDeleted

func (c *Chunk) MarkDeleted()

MarkDeleted marks this chunk as deleted. After marking it as unused, it will be deleted and can no longer be used.

func (*Chunk) MarkModified

func (c *Chunk) MarkModified()

MarkModified needs to be called, if some data of the chunk was modified.

func (*Chunk) MarkUnused

func (c *Chunk) MarkUnused() error

MarkUnused marks the chunk as unused. If all chunks of a superchunk are marked as unused, the underlying superchunk will be unloaded and saved (if needed).

You must not use the chunk any longer, after you called this function.

If the chunk was modified, call MarkModified BEFORE.

func (*Chunk) RecalcHeightMap

func (c *Chunk) RecalcHeightMap()

RecalcHeightMap recalculates the internal height map.

You should use this function before marking the chunk as unused, if you modified the chunk (unless you know, your changes wouldn't affect the height map).

func (*Chunk) SetBiome

func (c *Chunk) SetBiome(x, z int, bio Biome)

SetBiome sets the biome at x,z.

type Region

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

func OpenRegion

func OpenRegion(path string, autosave bool) (*Region, error)

OpenRegion opens a region directory. If autosave is true, mcmap will save modified and unloaded chunks automatically to reduce memory usage. You still have to call Save at the end.

You can also use OpenRegion to create a new region. Yust make sure the path exists.

func (*Region) AllChunks

func (reg *Region) AllChunks() <-chan XZPos

AllChunks returns a channel that will give you the positions of all possibly available chunks in an efficient order.

Note the "possibly available", you still have to check, if the chunk could actually be loaded.

func (*Region) Chunk

func (reg *Region) Chunk(x, z int) (*Chunk, error)

Chunk returns the chunk at x, z. If no chunk could be found, the error NotAvailable will be returned. Other errors indicate an internal error (I/O error, file format violated, ...)

func (*Region) MaxDims

func (reg *Region) MaxDims() (xmin, xmax, zmin, zmax int)

MaxDims calculates the approximate maximum x, z dimensions of this region in number of chunks. The actual maximum dimensions might be a bit smaller.

func (*Region) NewChunk

func (reg *Region) NewChunk(cx, cz int) (*Chunk, error)

NewChunk adds a new, blank chunk. If the Chunk is already there, error AlreadyThere will be returned. Other errors indicate internal errors.

func (*Region) Save

func (reg *Region) Save() error

Save saves modified and unused chunks.

type TileTick

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

func (*TileTick) I

func (tt *TileTick) I() int32

func (*TileTick) P

func (tt *TileTick) P() int32

func (*TileTick) SetI

func (tt *TileTick) SetI(i int32)

func (*TileTick) SetP

func (tt *TileTick) SetP(p int32)

func (*TileTick) SetT

func (tt *TileTick) SetT(t int32)

func (*TileTick) T

func (tt *TileTick) T() int32

type XZPos

type XZPos struct {
	X, Z int
}

Directories

Path Synopsis
examples
addchunk
addchunk adds a chunk at 200, 200 that consists of sandstone.
addchunk adds a chunk at 200, 200 that consists of sandstone.
delchunk
delchunk deletes the chunk at 200, 200
delchunk deletes the chunk at 200, 200
emeraldfinder
emeraldfinder is a gomcmap demo program to find emerald ores in a Minecraft map.
emeraldfinder is a gomcmap demo program to find emerald ores in a Minecraft map.
mapper
mapper is a very simple map renderer.
mapper is a very simple map renderer.
replace
replace replaces all iron blocks with diamond blocks.
replace replaces all iron blocks with diamond blocks.

Jump to

Keyboard shortcuts

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