Bricklayer.Client.World.Map.PlaceTile C# (CSharp) Method

PlaceTile() public method

Places a tile at the specified position, WHILE taking into account it's TileType Mainly used for player block placement, if you are looking to place a block through the code Either use `Tiles[x,y,z] =` or, set sendMessage to false
public PlaceTile ( int x, int y, Layer layer, BlockType block, bool sendMessage ) : void
x int The X position on the grid
y int The Y position on the grid
layer Layer The layer, either background or foreground
block BlockType The block to place
sendMessage bool Should the block be sent to the server or not
return void
        public void PlaceTile(int x, int y, Layer layer, BlockType block, bool sendMessage)
        {
            int z = layer == Layer.Foreground ? 1 : 0;
            if (CanPlaceBlock(x, y, z, block))
            {
                //If the block has changed, and we should send a message, send one
                if (sendMessage && Tiles[x, y, z].Block.ID != block.ID)
                {
                    Game.NetManager.Send(new BlockMessage(block, x, y, z));
                }
                //Set the block
                switch (block.Type)
                {
                    case TileType.Default:
                        Tiles[x, y, z] = new Tile(block);
                        break;
                    case TileType.Animated:
                        Tiles[x, y, z] = new AnimatedTile(block);
                        break;
                }
            }
        }