Skip to content

Latest commit

 

History

History
30 lines (29 loc) · 1.29 KB

CONTRIBUTING.md

File metadata and controls

30 lines (29 loc) · 1.29 KB

Contributing

Guidelines for contributing

...

Adding new blocks

  1. Create class which extends Block *If your new block is a simple cube, you can extend CubeBlock instead
  2. Override required properties and methods
  • TexturePaths should return a string[] of paths to the textures used by the block. For example:
public override string[] TexturePaths { get { return new[] { "res://Images/grass_top.png", "res://Images/grass_side.png" }; } }
  • GetTextureIndex should return an integer index into the TexturePaths array, for the provided BlockFace. For example:
public override int GetTextureIndex(BlockFace face)
{
  switch(face)
  {
    case BlockFace.Top:
    case BlockFace.Bottom:
      return 0;
    default:
      return 1;
  }
}
  • Add<[Pos/Neg][X/Y/Z]>Face should write the given face to the SurfaceTool supplied. See CubeBlock for an example.
  1. Register the block in Game construction, with Game.RegisterBlock(new MyNewBlockType())
  2. The block can now be used elsewhere in code. If you need it's byte id, you can use Game.GetBlockId<BlockType>(). Please bear in mind this is a comparitively expensive operation, so you should cache the result.
    If you need to get a Block, given an id, use Game.GetBlock(byte id)