Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement
Ic translate
此条目的(部分)内容需要翻译。

你可以帮助我们来翻译此条目,但请勿使用机器翻译

区块(Chunks)以16*256*16立方块为单位存储地形和实体信息。为了提高Minecraft的运行效率,区块同时储存预处理的光照、等高线数据及其他元数据信息。

“区块”概念在Minecraft Infdev阶段时首次引进。 在Beta 1.3版本引进MCRegion之前, Minecraft以36进制编码的区块坐标为文件名,将区块信息储存在独立的“.dat”文件中(Alpha level format)。为了减少磁盘占用,MCRegion将地平面上32*32平方块内的所有区块打包存储在以十进制编码的区块坐标为文件名的“.mcr”文件中;这种存储方式降低了Minecraft运行时同时打开的文件数量。MCRegion后来被当下的铁砧文件格式取代,新格式沿用了MCRegion打包存储的方法,并使用了新的“.mca”文件格式。

铁砧文件格式相比MCRegion最大的改进是将区块分割,一个16*256*16大小的区块最多能分割出16个16*16*16的部分,所以全空区域的数据可以不被保存。支持的方块ID也从以前的0到255调整为0到4095,不过现在(2012年11月22日时)Minecraft还不能完美实现ID从0到4095的所有方块的存储,且256到4095的这些方块ID有很多已经被物品占用。

现在(2012年11月22日时),方块的辅助信息独立地被保存在区块信息内,特别的,天空光照(SkyLight)和(BlockLight)两个数组信息不在挂在方块ID后。铁砧文件格式出现后, 开发组在Notch原先设想的基础上对NBT格式(二进制命名标签格式)做出了改变,添加了一个和字节数组标签(byte array tag)相近的整数数组标签(integer array tag)——只有区块的等高线信息使用NBT格式存储。

NBT结构

See also: information from the Anvil format page

区块使用NBT格式存储时遵循以下结构:

  • 根标签
    •  Level: 区块数据
      •  xPos: 区块的X坐标
      •  zPos: 区块的Z坐标
      •  LastUpdate: 自该区块上次更新以来经过的刻。
      •  TerrainPopulated: 布尔值,指示区块内的地区存不存在特殊的事物,如矿石、特殊方块、树木、地牢、花、瀑布等。如果该值为“假”或“0” 则游戏会在已经存在的方块内生成这些事物。
      •  Biomes: 256字节的生物群系信息,有些区块可能不具备该信息。区块内垂直的一列占用一字节空间,生物群系ID可在数据值页面查看。如果这个数组不存在,游戏在加载和保存区块时会自动添加并赋值;若数组内任何数值为“-1”,游戏也会根据正确信息改正。
      •  HeightMap: 1024 bytes(256 TAG_Int) of heightmap data. 16 x 16. Each byte records the lowest level in each column where the light from the sky is at full strength. Speeds computing of the SkyLight. Note: This array's indexes are ordered ZX whereas the other array indexes are ordered XZ or YZX.
      •  Sections: List of Compound tags, each tag is a sub-chunk of sorts.
        •  Y: The Y index (not coordinate) of this section. Range 0 to 15 (bottom to top), with no duplicates but some sections may be missing if empty.
        •  Blocks: 4096 bytes of block IDs defining the terrain. 8 bits per block, plus the bits from the below Add tag. 3D order YZX.
        •  Add: May not exist. 2048 bytes of additional block ID data. The value to add to (combine with) the above block ID to form the true block ID in the range 0 to 4095. 4 bits per block. 3D order YZX. Combining is done by shifting this value to the left 8 bits and then adding it to the block ID from above.
        •  Data: 2048 bytes of block data additionally defining parts of the terrain. 4 bits per block. 3D order YZX.
        •  BlockLight: 2048 bytes recording the amount of block-emitted light in each block. Makes load times faster compared to recomputing at load time. 4 bits per block. 3D order YZX.
        •  SkyLight: 2048 bytes recording the amount of sun or moonlight hitting each block. Makes day/night transitions smoother compared to recomputing per level change. 4 bits per block. 3D order YZX.
      •  Entities: Each TAG_Compound in this list defines an entity in the chunk. See Entity Format below. If this list is empty it will be a list of Byte tags.
      •  TileEntities: Each TAG_Compound in this list defines a tile entity in the chunk. See Tile Entity Format below. If this list is empty it will be a list of Byte tags.
      •  TileTicks: May not exist. Each TAG_Compound in this list is an "active" block in this chunk waiting to be updated. These are used to save the state of redstone machines, falling sand or water, and other activity. See Tile Tick Format below. This tag may not exist.

方块格式

The information in this section may be incorrect; valid information is in the works.

In the Anvil format, block positions are ordered YZX for compression purposes.

The coordinate system is as follows:

  • X increases East, decreases West
  • Y increases upwards, decreases downwards
  • Z increases South, decreases North

Each section in a chunk is a 16x16x16-block area, with up to 16 sections in a chunk. Section 0 is the bottom section of the chunk, and section 15 is the top section of the chunk. To save space, completely empty sections are not saved. Within each section is a byte tag "Y" for the Y index of the section, 0 to 15, and then byte arrays for the blocks. The "Block" byte array has 4096 partial block IDs at 8 bits per block. Another byte array "Add" is used for block with IDs over 255, and is 2048 bytes of the other part of the 4096 block IDs at 4 bits per block. When both the "Block" and "Add" byte arrays exist, the partial ID from the "Add" array is shifted left 8 bits and added to the partial ID from the "Blocks" array to form the true Block ID. The "Data" byte array is also 2048 bytes for 4096 block data values at 4 bits per block. The "BlockLight" and "SkyLight" byte arrays are the same as the "Data" byte array but they are used for block light levels and sky light levels respectively. The "SkyLight" values represent how much sunlight/moonlight is reaching the block - these values do not change when the light level from the sky changes; these values act as a sort of percentage.

The pseudo-code below shows how to access individual block information from a single section. Hover over text to see additional information or comments.

byte Nibble4(byte[] arr, int index){ return index%2 == 0 ? arr[index/2]&0x0F : (arr[index/2]>>4)&0x0F; }
int BlockPos = y*16*16 + z*16 + x;
byte BlockID_a = Blocks[BlockPos];
byte BlockID_b = Nibble4(Add, BlockPos);
short BlockID = BlockID_a + (BlockID_b << 8);
byte BlockData = Nibble4(Data, BlockPos);
byte Blocklight = Nibble4(BlockLight, BlockPos);
byte Skylight = Nibble4(SkyLight, BlockPos);

实体格式

Every entity is an unnamed TAG_Compound contained in the Entities list of a chunk file. The sole exception is the Player entity, stored in level.dat, or in <player>.dat files on servers.

All entities share this base:

  • 实体数据
    •  id: 实体ID.玩家实体没有这个标签.
    •  Pos: 3个TAG_Doubles,用于描述这个实体目前的X,Y,Z坐标.
    •  Motion: 3 TAG_Doubles describing the current dX,dY,dZ velocity of the entity in meters per tick.
    •  Rotation: Two TAG_Floats representing rotation in degrees.
      • The entity's rotation clockwise around the Y axis (called yaw). Due west is 0. Can have large values because it accumulates all of the entity's lateral rotation throughout the game.
      • The entity's declination from the horizon (called pitch). Horizontal is 0. Positive values look downward. Does not exceed positive or negative 90 degrees.
    •  FallDistance: Distance the entity has fallen. Larger values cause more damage when the entity lands.
    •  Fire: Number of ticks until the fire is put out. Negative values reflect how long the entity can stand in fire before burning.
    •  Air: How much air the entity has, in ticks. Fills to a maximum of 200 in air, giving 10 seconds submerged before the entity starts to drown, and a total of up to 20 seconds before the entity dies. Decreases while underwater. If 0 while underwater, the entity loses 1 health per second.
    •  OnGround: 1 or 0 (true/false) - true if the entity is touching the ground.

生物

Mobs are a subclass of Entity with additional tags to store their health, attacking/damaged state, potion effects, and more depending on the mob. Players are a subclass of Mob.

Entity ID Name
Blaze Blaze
CaveSpider Cave Spider
Chicken1 Chicken
Cow1 Cow
Creeper Creeper
EnderDragon Ender Dragon
Enderman Enderman
Ghast Ghast
Giant Giant
LavaSlime Magma Cube
MushroomCow1 Mooshroom
Ozelot1 2 Ocelot
Pig1 Pig
PigZombie Zombie Pigman
Sheep1 Sheep
Silverfish Silverfish
Skeleton Skeleton
Slime Slime
SnowMan Snow Golem
Spider Spider
Squid Squid
Villager1 Villager
VillagerGolem Iron Golem
Wolf1 2 Wolf
Zombie Zombie
1Can breed 2Can be tamed
  • SkeletonFace Additional fields for Mobs:
    •  Health: Amount of health the entity has. A value of 1 is half a heart.
    •  AttackTime: Number of ticks the mob's "invincibility shield" lasts after the mob was last struck.
    •  HurtTime: Number of ticks the mob turns red for after being hit.
    •  DeathTime: Number of ticks the mob has been dead for. Controls death animations.
    •  ActiveEffects: The list of potion effects on this mob. May not exist.
      • A potion effect
        •  Id: The effect ID.
        •  Amplifier: The potion effect level. 0 is level 1.
        •  Duration: The number of ticks before the effect wears off.
  • Heart Additional fields for mobs that can breed:
    •  InLove: Number of ticks until the mob loses its breeding hearts and stops searching for a mate.
    •  Age: Represents the age of the mob in ticks; when negative, the mob is a baby. When 0 or above, the mob is an adult. When above 0, represents the number of ticks before this mob can breed again.
  • Bone Additional fields for mobs that can be tamed by players:
    •  Owner: Name of the player that owns this mob. Empty string if no owner.
    •  Sitting: 1 or 0 (true/false) - true if the mob is sitting.
  • CreeperFace Creeper has one additional field:
    •  powered: 1 or 0 (true/false) - May not exist. True if the creeper is charged from being struck by lightning.
  • EndermanFace Enderman has two additional fields:
    •  carried: Id of the block carried by the Enderman.
    •  carriedData: Additional data about the block carried by the Enderman.
  • OcelotFace Ozelot has one additional field:
    •  CatType: The ID of the skin the tamed ocelot has.
  • PigFace Pig has one additional field:
    •  Saddle: 1 or 0 (true/false) - true if there is a saddle on the pig.
  • ZombiePigmanFace PigZombie has one additional field:
    •  Anger: Anger level. Determines the aggressivity of the creature towards players.
  • SheepFace Sheep has two additional fields:
    •  Sheared: 1 or 0 (true/false) - true if the sheep has been shorn.
    •  Color: 0 to 15 - see wool data values for a mapping to colors.
  • WolfFace Wolf has one additional field:
    •  Angry: 1 or 0 (true/false) - true if the wolf is angry.
  • Villagerhead Villager has 3 additional fields:
    •  Profession: The ID of the texture used for this villager. This also influences trading options.
    •  Riches: Unknown, but starts at 0 and increases when trading for diamonds.
    •  Offers: May not exist.
      •  Recipes: List of trade options.
        • A trade option.
          •  uses: The number of times this trade has been used.
          •  buy: The first 'cost' item.
            • Same as an Item's structure, but without the Slot tag.
          •  buyB: May not exist. The second 'cost' item.
            • Same as an Item's structure, but without the Slot tag.
          •  sell: The item being sold for each set of cost items.
            • Same as an Item's structure, but without the Slot tag.

抛出物

Projectiles are a subclass of Entity and have very obscure tags such as X,Y,Z coordinate tags despite Entity Pos tag, inTile despite inGround, and shake despite most projectiles not being arrows.

Entity ID Name
Arrow Arrow
Snowball Snowball
Egg Egg
Fireball Ghast Fireball
SmallFireball Blaze Fireball/Fire Charge
ThrownEnderpearl Ender Pearl
  • ArrowSnowballFile:Egg2.pngFile:Magmaball.pngEnder Pearl Additional fields for Projectiles:
    •  xTile: X coordinate of the item's position in the chunk.
    •  yTile: Y coordinate of the item's position in the chunk.
    •  zTile: Z coordinate of the item's position in the chunk.
    •  inTile: For arrows being stuck into blocks.
    •  shake: The "shake" when arrows hit a block.
    •  inGround: 1 or 0 (true/false) - Unknown
  • Arrow Additional fields for Arrow:
    •  inData: Unknown.
    •  pickup: Unknown, not a boolean value. Affects whether the arrow can be picked up (e.g. fired in survival, fired in creative, fired from infinity bow, fired from skeleton, etc...)
    •  damage: Unknown how this affects actual damage inflicted by the arrow. May not be a whole number.

物品

Items are a subclass of Entity.

Entity ID Name
Item Dropped Item
XPOrb XP Orb
  • Stone Additional fields for items:
    •  Health: The health of the item, which starts at 5. Items take damage from fire, lava, and explosions. The item is destroyed when its health reaches 0.
    •  Age: The number of ticks the item has been "untouched". After 6000 ticks (5 minutes [1]) the item is destroyed.
  • Cobblestone Additional fields for Item:
    •  Item: The inventory item, without the Slot tag.
      • See Item Format.
  • File:Experience Orb.png Additional field for XPOrb:
    •  Value: The amount of experience the orb gives when picked up.

载具

Vehicles are subclasses of Entity.

Entity ID Name
Boat Boat
Minecart Minecart, Storage Minecart, Furnace Minecart
  • Minecart Additional fields for Minecart:
    •  Type: The type of the cart: 0 - empty, 1 - with a chest, 2 - with a furnace.
  • File:Storage Minecart.png For a minecart with a chest there is one additional field:
    •  Items: List of items.
      • An item, including the Slot tag. Slots are numbered 0 to 26.
        • See Item Format
  • File:Powered Minecart.png For a minecart with a furnace there are three additional fields:
    •  PushX: Force along X axis, used for smooth acceleration/deceleration.
    •  PushZ: Force along Z axis, used for smooth acceleration/deceleration.
    •  Fuel: The number of ticks until the minecart runs out of fuel.

动态方块

Dynamic tiles are a subclass of Entity and are used to simulate realistically moving blocks.

Entity ID Name
PrimedTnt TNT
FallingSand Dynamic Tile
  • TNT Additional fields for PrimedTnt
    •  Fuse: Ticks until explosion.
  • Gravel Additional fields for FallingSand:
    •  Tile: Block ID. Not limited to only sand or gravel.

其它

Other entity types that are a subclass of Entity but do not fit into any of the above categories.

Entity ID Name
EnderCrystal Ender Crystal
EyeOfEnderSignal Eye of Ender
Painting Painting
  • Painting Additional fields for Painting:
    •  Dir: Direction the painting faces: 0 is east, 1 is north, 2 is west, and 3 is south.
    •  Motive: The name of this Painting's art.
    •  TileX: X coordinate of the block the painting is hanging on.
    •  TileY: Y coordinate of the block the painting is hanging on.
    •  TileZ: Z coordinate of the block the painting is hanging on.

实体附加值格式

Tile Entities (not related to Entities) are used by Minecraft to store information about blocks that can't be stored in the 4-bits of block data the block has.

Tile Entity ID Associated Block
Airportal End Portal
Cauldron Brewing Stand
Chest Chest
EnchantTable Enchantment Table
Furnace Furnace
MobSpawner Monster Spawner
Music Note Block
Piston Piston Moving
RecordPlayer Jukebox
Sign Sign
Trap Dispenser

All tile entities share this base:

  • Tile entity data
    •  id: Tile entity ID
    •  x: X coordinate of the Tile Entity.
    •  y: Y coordinate of the Tile Entity.
    •  z: Z coordinate of the Tile Entity.
  • Furnace Additional fields for Furnace:
    •  BurnTime: Number of ticks left before the current fuel runs out.
    •  CookTime: Number of ticks the item has been smelting for. The item finishes smelting when this value reaches 200 (10 seconds). Is reset to 0 if BurnTime reaches 0.
    •  Items: List of items in the furnace slots. Each item is a TAG_Compound as described in Item Format, but without the Slot tag.
      • 0: The item(s) being smeted.
      • 1: The item(s) to use as the next fuel source.
      • 2: The item(s) in the result slot.

The original maximum burning time for the current fuel isn't stored, thus the current time left is assumed to be the maximum when this Tile Entity is loaded into memory.

  • Sign Additional fields for Sign:
    •  Text1: First row of text.
    •  Text2: Second row of text.
    •  Text3: Third row of text.
    •  Text4: Fourth row of text.

Only the first 16 characters of each line are read, the rest are discarded.

  • Monster Spawner Additional fields for MobSpawner:
    •  EntityId: The Entity ID of the mob. Only Mob Entity IDs will work.
    •  SpawnCount: How many mobs to spawn each time.
    •  SpawnData: The tags to replace the default tags; any of the Entity or Mob tags may be used, including the Pos tag.[2]
    •  Delay: Ticks until next spawn.
    •  MinSpawnDelay: The minimum random delay for the next spawn delay.
    •  MaxSpawnDelay: The maximum random delay for the next spawn delay. Warning: Setting this value to 0 crashes Minecraft. Set to at least 1.
  • Chest Additional fields for Chest:
    •  Items: List of items in the chest. Each item is a TAG_Compound as described in Item Format, including the Slot tag. Chest slots are numbered 0-26 with 0 in the top left corner.

Double chests are simply two Chest tile entities next to each other.

  • Note Block Additional fields for Music:
    •  note: Pitch (number of right-clicks).
  • Dispenser Additional fields for Trap:
    •  Items: List of items in the dispenser, each item includes the Slot tag. Slots are numbered 0-8.
  • Jukebox Additional fields for RecordPlayer:
    •  Record: Record currently playing. 0 is no record. Otherwise, it is the item ID of the record (e.g. 2261 for the "mall" record). Other IDs can be used to make other items or blocks pop out with a data value of 0.
  • Piston Additional fields for Piston:
    •  blockId: Block_IDs of the block being moved.
    •  blockData: Data value of the block being moved.
    •  facing: Direction in which the block will be pushed.
    •  progress: How far the block has been moved.
    •  extending: 1 or 0 (true/false) - true if the block is being pushed.
  • Brewing Stand Additional fields for Cauldron:
    •  Items: List of items in the brewing stand. Each item is a TAG_Compound as described in Item Format, including the Slot tag. The slots are numbered 0 to 3.
    •  BrewTime: The number of ticks the potions have been brewing for.

Tile Tick Format

Tile Ticks represent block updates that need to happen because they could not happen before the chunk was saved. Examples reasons for tile ticks include redstone circuits needing to continue updating, water and lava that should continue flowing, recently placed sand or gravel that should fall, etc. Tile ticks are not used for purposes such as leaf decay, where the decay information is stored in the leaf block data values and handled by Minecraft when the chunk loads. For map makers, tile ticks can be used to update blocks after a period of time has passed with the chunk loaded into memory.

  • A Tile Tick
    •  i: The ID of the block; used to activate the correct block update procedure.
    •  t: The number of ticks until processing should occur. May be negative when processing is overdue.
    •  x: X position
    •  y: Y position
    •  z: Z position

参考

Advertisement