summaryrefslogtreecommitdiff
path: root/mcmap/block.go
blob: 449e25fc3e1f94eff322f29eb455e8e0ce4c2348 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
package mcmap

import (
	"github.com/kch42/gonbt/nbt"
)

type BlockID uint16

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 TileTick struct {
	i, t, p int32
	hasP    bool
}

func (tt *TileTick) I() int32 { return tt.i }
func (tt *TileTick) T() int32 { return tt.t }
func (tt *TileTick) P() int32 { return tt.p }

func (tt *TileTick) SetI(i int32) { tt.i = i }
func (tt *TileTick) SetT(t int32) { tt.t = t }

func (tt *TileTick) SetP(p int32) {
	tt.p = p
	tt.hasP = true
}

// Names and values from: http://www.minecraftwiki.net/wiki/Data_values

// Valid values for BlockID
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
	BlkRose                       = 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
	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
	BlkHayBlock                   = 170
	BlkCarpet                     = 171
	BlkHardenedClay               = 172
	BlkBlockOfCoal                = 173
)

var blockNames = map[BlockID]string{
	BlkAir:                        "Air",
	BlkStone:                      "Stone",
	BlkGrassBlock:                 "Grass Block",
	BlkDirt:                       "Dirt",
	BlkCobblestone:                "Cobblestone",
	BlkWoodPlanks:                 "Wood Planks",
	BlkSaplings:                   "Saplings",
	BlkBedrock:                    "Bedrock",
	BlkWater:                      "Water",
	BlkStationaryWater:            "Stationary water",
	BlkLava:                       "Lava",
	BlkStationaryLava:             "Stationary lava",
	BlkSand:                       "Sand",
	BlkGravel:                     "Gravel",
	BlkGoldOre:                    "Gold Ore",
	BlkIronOre:                    "Iron Ore",
	BlkCoalOre:                    "Coal Ore",
	BlkWood:                       "Wood",
	BlkLeaves:                     "Leaves",
	BlkSponge:                     "Sponge",
	BlkGlass:                      "Glass",
	BlkLapisLazuliOre:             "Lapis Lazuli Ore",
	BlkLapisLazuliBlock:           "Lapis Lazuli Block",
	BlkDispenser:                  "Dispenser",
	BlkSandstone:                  "Sandstone",
	BlkNoteBlock:                  "Note Block",
	BlkBed:                        "Bed",
	BlkPoweredRail:                "Powered Rail",
	BlkDetectorRail:               "Detector Rail",
	BlkStickyPiston:               "Sticky Piston",
	BlkCobweb:                     "Cobweb",
	BlkGrass:                      "Grass",
	BlkDeadBush:                   "Dead Bush",
	BlkPiston:                     "Piston",
	BlkPistonExtension:            "Piston Extension",
	BlkWool:                       "Wool",
	BlkBlockMovedByPiston:         "Block moved by Piston",
	BlkDandelion:                  "Dandelion",
	BlkRose:                       "Rose",
	BlkBrownMushroom:              "Brown Mushroom",
	BlkRedMushroom:                "Red Mushroom",
	BlkBlockOfGold:                "Block of Gold",
	BlkBlockOfIron:                "Block of Iron",
	BlkDoubleSlabs:                "Double Slabs",
	BlkSlabs:                      "Slabs",
	BlkBricks:                     "Bricks",
	BlkTNT:                        "TNT",
	BlkBookshelf:                  "Bookshelf",
	BlkMossStone:                  "Moss Stone",
	BlkObsidian:                   "Obsidian",
	BlkTorch:                      "Torch",
	BlkFire:                       "Fire",
	BlkMonsterSpawner:             "Monster Spawner",
	BlkOakWoodStairs:              "Oak Wood Stairs",
	BlkChest:                      "Chest",
	BlkRedstoneWire:               "Redstone Wire",
	BlkDiamondOre:                 "Diamond Ore",
	BlkBlockOfDiamond:             "Block of Diamond",
	BlkCraftingTable:              "Crafting Table",
	BlkWheat:                      "Wheat",
	BlkFarmland:                   "Farmland",
	BlkFurnace:                    "Furnace",
	BlkBurningFurnace:             "Burning Furnace",
	BlkSignPost:                   "Sign Post",
	BlkWoodenDoor:                 "Wooden Door",
	BlkLadders:                    "Ladders",
	BlkRail:                       "Rail",
	BlkCobblestoneStairs:          "Cobblestone Stairs",
	BlkWallSign:                   "Wall Sign",
	BlkLever:                      "Lever",
	BlkStonePressurePlate:         "Stone Pressure Plate",
	BlkIronDoor:                   "Iron Door",
	BlkWoodenPressurePlate:        "Wooden Pressure Plate",
	BlkRedstoneOre:                "Redstone Ore",
	BlkGlowingRedstoneOre:         "Glowing Redstone Ore",
	BlkRedstoneTorchInactive:      "Redstone Torch (inactive)",
	BlkRedstoneTorchActive:        "Redstone Torch (active)",
	BlkStoneButton:                "Stone Button",
	BlkSnow:                       "Snow",
	BlkIce:                        "Ice",
	BlkSnowBlock:                  "Snow Block",
	BlkCactus:                     "Cactus",
	BlkClay:                       "Clay",
	BlkSugarCane:                  "Sugar Cane",
	BlkJukebox:                    "Jukebox",
	BlkFence:                      "Fence",
	BlkPumpkin:                    "Pumpkin",
	BlkNetherrack:                 "Netherrack",
	BlkSoulSand:                   "Soul Sand",
	BlkGlowstone:                  "Glowstone",
	BlkNetherPortal:               "Nether Portal",
	BlkJackOLantern:               "Jack 'o' Lantern",
	BlkCakeBlock:                  "Cake Block",
	BlkRedstoneRepeaterInactive:   "Redstone Repeater (inactive)",
	BlkRedstoneRepeaterActive:     "Redstone Repeater (active)",
	BlkLockedChest:                "Locked Chest",
	BlkTrapdoor:                   "Trapdoor",
	BlkMonsterEgg:                 "Monster Egg",
	BlkStoneBricks:                "Stone Bricks",
	BlkHugeBrownMushroom:          "Huge Brown Mushroom",
	BlkHugeRedMushroom:            "Huge Red Mushroom",
	BlkIronBars:                   "Iron Bars",
	BlkGlassPane:                  "Glass Pane",
	BlkMelon:                      "Melon",
	BlkPumpkinStem:                "Pumpkin Stem",
	BlkMelonStem:                  "Melon Stem",
	BlkVines:                      "Vines",
	BlkFenceGate:                  "Fence Gate",
	BlkBrickStairs:                "Brick Stairs",
	BlkStoneBrickStairs:           "Stone Brick Stairs",
	BlkMycelium:                   "Mycelium",
	BlkLilyPad:                    "Lily Pad",
	BlkNetherBrick:                "Nether Brick",
	BlkNetherBrickFence:           "Nether Brick Fence",
	BlkNetherBrickStairs:          "Nether Brick Stairs",
	BlkNetherWart:                 "Nether Wart",
	BlkEnchantmentTable:           "Enchantment Table",
	BlkBrewingStand:               "Brewing Stand",
	BlkCauldron:                   "Cauldron",
	BlkEndPortal:                  "End Portal",
	BlkEndPortalBlock:             "End Portal Block",
	BlkEndStone:                   "End Stone",
	BlkDragonEgg:                  "Dragon Egg",
	BlkRedstoneLampInactive:       "Redstone Lamp (inactive)",
	BlkRedstoneLampActive:         "Redstone Lamp (active)",
	BlkWoodenDoubleSlab:           "Wooden Double Slab",
	BlkWoodenSlab:                 "Wooden Slab",
	BlkCocoa:                      "Cocoa",
	BlkSandstoneStairs:            "Sandstone Stairs",
	BlkEmeraldOre:                 "Emerald Ore",
	BlkEnderChest:                 "Ender Chest",
	BlkTripwireHook:               "Tripwire Hook",
	BlkTripwire:                   "Tripwire",
	BlkBlockOfEmerald:             "Block of Emerald",
	BlkSpruceWoodStairs:           "Spruce Wood Stairs",
	BlkBirchWoodStairs:            "Birch Wood Stairs",
	BlkJungleWoodStairs:           "Jungle Wood Stairs",
	BlkCommandBlock:               "Command Block",
	BlkBeacon:                     "Beacon",
	BlkCobblestoneWall:            "Cobblestone Wall",
	BlkFlowerPot:                  "Flower Pot",
	BlkCarrots:                    "Carrots",
	BlkPotatoes:                   "Potatoes",
	BlkWoodenButton:               "Wooden Button",
	BlkMobHead:                    "Mob Head",
	BlkAnvil:                      "Anvil",
	BlkTrappedChest:               "Trapped Chest",
	BlkWeightedPressurePlateLight: "Weighted Pressure Plate (Light)",
	BlkWeightedPressurePlateHeavy: "Weighted Pressure Plate (Heavy)",
	BlkRedstoneComparatorInactive: "Redstone Comparator (inactive)",
	BlkRedstoneComparatorActive:   "Redstone Comparator (active)",
	BlkDaylightSensor:             "Daylight Sensor",
	BlkBlockOfRedstone:            "Block of Redstone",
	BlkNetherQuartzOre:            "Nether Quartz Ore",
	BlkHopper:                     "Hopper",
	BlkBlockOfQuartz:              "Block of Quartz",
	BlkQuartzStairs:               "Quartz Stairs",
	BlkActivatorRail:              "Activator Rail",
	BlkDropper:                    "Dropper",
	BlkStainedClay:                "Stained Clay",
	BlkHayBlock:                   "Hay Block",
	BlkCarpet:                     "Carpet",
	BlkHardenedClay:               "Hardened Clay",
	BlkBlockOfCoal:                "Block of Coal",
}

func (b BlockID) String() string {
	if s, ok := blockNames[b]; ok {
		return s
	}

	return "(unused)"
}